Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VisManager.cc
이 파일의 문서화 페이지로 가기
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 // $Id: G4VisManager.cc 110513 2018-05-28 07:37:38Z gcosmo $
27 //
28 //
29 // GEANT4 Visualization Manager - John Allison 02/Jan/1996.
30 
31 #include "G4VisManager.hh"
32 
33 #include "G4VisCommands.hh"
34 #include "G4VisCommandsCompound.hh"
35 #include "G4VisCommandsGeometry.hh"
38 #include "G4VisCommandsSet.hh"
39 #include "G4VisCommandsScene.hh"
40 #include "G4VisCommandsSceneAdd.hh"
44 #include "G4VisCommandsViewer.hh"
47 #include "G4UImanager.hh"
48 #include "G4VisStateDependent.hh"
49 #include "G4UIdirectory.hh"
50 #include "G4VGraphicsSystem.hh"
51 #include "G4VSceneHandler.hh"
52 #include "G4VViewer.hh"
53 #include "G4VPhysicalVolume.hh"
54 #include "G4LogicalVolume.hh"
55 #include "G4VSolid.hh"
56 #include "G4Vector3D.hh"
57 #include "G4Point3D.hh"
58 #include "G4RotationMatrix.hh"
59 #include "G4Polyline.hh"
60 #include "G4Polyhedron.hh"
61 #include "G4NullModel.hh"
62 #include "G4ModelingParameters.hh"
66 #include "G4VisModelManager.hh"
67 #include "G4VModelFactory.hh"
68 #include "G4VisFilterManager.hh"
69 #include "G4VTrajectoryModel.hh"
71 #include "Randomize.hh"
72 #include "G4RunManager.hh"
73 #include "G4EventManager.hh"
74 #include "G4Run.hh"
75 #include "G4Event.hh"
76 #include <map>
77 #include <set>
78 #include <vector>
79 #include <sstream>
80 
81 #ifdef G4MULTITHREADED
82 #include "G4MTRunManager.hh"
83 #include "G4Threading.hh"
84 #include "G4AutoLock.hh"
86 #include "G4SolidsWorkspacePool.hh"
87 #include <deque>
88 #include <typeinfo>
89 #ifdef G4VIS_USE_STD11
90 #include <chrono>
91 #include <thread>
92 #endif
93 #endif
94 
96 
98 
99 G4VisManager::G4VisManager (const G4String& verbosityString):
100  fVerbose (1),
101  fInitialised (false),
102  fpGraphicsSystem (0),
103  fpScene (0),
104  fpSceneHandler (0),
105  fpViewer (0),
106  fpStateDependent (0),
107  fEventRefreshing (false),
108  fTransientsDrawnThisRun (false),
109  fTransientsDrawnThisEvent (false),
110  fNoOfEventsDrawnThisRun (0),
111  fNKeepRequests (0),
112  fEventKeepingSuspended (false),
113  fKeptLastEvent (false),
114  fDrawEventOnlyIfToBeKept (false),
115  fpRequestedEvent (0),
116  fAbortReviewKeptEvents (false),
117  fIsDrawGroup (false),
118  fDrawGroupNestingDepth (0),
119  fIgnoreStateChanges (false)
120 #ifdef G4MULTITHREADED
121 , fMaxEventQueueSize (100)
122 , fWaitOnEventQueueFull (true)
123 #endif
124  // All other objects use default constructors.
125 {
126  fpTrajDrawModelMgr = new G4VisModelManager<G4VTrajectoryModel>("/vis/modeling/trajectories");
127  fpTrajFilterMgr = new G4VisFilterManager<G4VTrajectory>("/vis/filtering/trajectories");
128  fpHitFilterMgr = new G4VisFilterManager<G4VHit>("/vis/filtering/hits");
129  fpDigiFilterMgr = new G4VisFilterManager<G4VDigi>("/vis/filtering/digi");
130 
131  VerbosityGuidanceStrings.push_back
132  ("Simple graded message scheme - digit or string (1st character defines):");
133  VerbosityGuidanceStrings.push_back
134  (" 0) quiet, // Nothing is printed.");
135  VerbosityGuidanceStrings.push_back
136  (" 1) startup, // Startup and endup messages are printed...");
137  VerbosityGuidanceStrings.push_back
138  (" 2) errors, // ...and errors...");
139  VerbosityGuidanceStrings.push_back
140  (" 3) warnings, // ...and warnings...");
141  VerbosityGuidanceStrings.push_back
142  (" 4) confirmations, // ...and confirming messages...");
143  VerbosityGuidanceStrings.push_back
144  (" 5) parameters, // ...and parameters of scenes and views...");
145  VerbosityGuidanceStrings.push_back
146  (" 6) all // ...and everything available.");
147 
148  if (fpInstance) {
150  ("G4VisManager::G4VisManager",
151  "visman0001", FatalException,
152  "Attempt to Construct more than one VisManager");
153  }
154 
155  fpInstance = this;
156  SetConcreteInstance(this);
157 
159  // No need to delete this; G4StateManager does this.
160 
161  fVerbosity = GetVerbosityValue(verbosityString);
162  if (fVerbosity >= startup) {
163  G4cout
164  << "Visualization Manager instantiating with verbosity \""
166  << "\"..." << G4endl;
167  }
168 
169  // Note: The specific graphics systems must be instantiated in a
170  // higher level library to avoid circular dependencies. Also,
171  // some specifically need additional external libararies that the
172  // user must supply. Therefore we ask the user to implement
173  // RegisterGraphicsSystems() and RegisterModelFactories()
174  // in a subclass. We have to wait for the subclass to instantiate
175  // so RegisterGraphicsSystems() cannot be called from this
176  // constructor; it is called from Initialise(). So we ask the
177  // user:
178  // (a) to write a subclass and implement RegisterGraphicsSystems()
179  // and RegisterModelFactories(). See
180  // visualization/include/G4VisExecutive.hh/icc as an example.
181  // (b) instantiate the subclass.
182  // (c) invoke the Initialise() method of the subclass.
183  // For example:
184  // ...
185  // #ifdef G4VIS_USE
186  // // Instantiate and initialise Visualization Manager.
187  // G4VisManager* visManager = new G4VisExecutive;
188  // visManager -> SetVerboseLevel (Verbose);
189  // visManager -> Initialise ();
190  // #endif
191  // // (Don't forget to delete visManager;)
192  // ...
193 
194  // Make top level command directory...
195  // Vis commands should *not* be broadcast to threads (2nd argument).
196  G4UIcommand* directory = new G4UIdirectory ("/vis/",false);
197  directory -> SetGuidance ("Visualization commands.");
198  fDirectoryList.push_back (directory);
199 
200  // Instantiate *basic* top level commands so that they can be used
201  // immediately after instantiation of the vis manager. Other top
202  // level and lower level commands are instantiated later in
203  // RegisterMessengers.
204  G4VVisCommand::SetVisManager (this); // Sets shared pointer
207 }
208 
210  fpInstance = 0;
211  size_t i;
212  for (i = 0; i < fSceneList.size (); ++i) {
213  delete fSceneList[i];
214  }
215  for (i = 0; i < fAvailableSceneHandlers.size (); ++i) {
216  if (fAvailableSceneHandlers[i] != NULL) {
217  delete fAvailableSceneHandlers[i];
218  }
219  }
220  for (i = 0; i < fAvailableGraphicsSystems.size (); ++i) {
221  if (fAvailableGraphicsSystems[i]) {
222  delete fAvailableGraphicsSystems[i];
223  }
224  }
225  if (fVerbosity >= startup) {
226  G4cout << "Graphics systems deleted." << G4endl;
227  G4cout << "Visualization Manager deleting..." << G4endl;
228  }
229  for (i = 0; i < fMessengerList.size (); ++i) {
230  delete fMessengerList[i];
231  }
232  for (i = 0; i < fDirectoryList.size (); ++i) {
233  delete fDirectoryList[i];
234  }
235 
236  delete fpDigiFilterMgr;
237  delete fpHitFilterMgr;
238  delete fpTrajFilterMgr;
239  delete fpTrajDrawModelMgr;
240 }
241 
243  if (!fpInstance) {
245  ("G4VisManager::GetInstance",
246  "visman0002", FatalException, "VisManager not yet instantiated");
247  }
248  return fpInstance;
249 }
250 
252 
253  if (fInitialised && fVerbosity >= warnings) {
254  G4cout << "WARNING: G4VisManager::Initialise: already initialised."
255  << G4endl;
256  return;
257  }
258 
259  if (fVerbosity >= startup) {
260  G4cout << "Visualization Manager initialising..." << G4endl;
261  }
262 
263  if (fVerbosity >= parameters) {
264  G4cout <<
265  "\nYou have instantiated your own Visualization Manager, inheriting"
266  "\n G4VisManager and implementing RegisterGraphicsSystems(), in which"
267  "\n you should, normally, instantiate drivers which do not need"
268  "\n external packages or libraries, and, optionally, drivers under"
269  "\n control of environment variables."
270  "\n Also you should implement RegisterModelFactories()."
271  "\n See visualization/management/include/G4VisExecutive.hh/icc, for example."
272  "\n In your main() you will have something like:"
273  "\n #ifdef G4VIS_USE"
274  "\n G4VisManager* visManager = new G4VisExecutive;"
275  "\n visManager -> SetVerboseLevel (Verbose);"
276  "\n visManager -> Initialize ();"
277  "\n #endif"
278  "\n (Don't forget to delete visManager;)"
279  "\n"
280  << G4endl;
281  }
282 
283  if (fVerbosity >= startup) {
284  G4cout << "Registering graphics systems..." << G4endl;
285  }
286 
288 
289  if (fVerbosity >= startup) {
290  G4cout <<
291  "\nYou have successfully registered the following graphics systems."
292  << G4endl;
294  G4cout << G4endl;
295  }
296 
297  // Make command directories for commands instantiated in the
298  // modeling subcategory...
299  G4UIcommand* directory;
300  directory = new G4UIdirectory ("/vis/modeling/");
301  directory -> SetGuidance ("Modeling commands.");
302  fDirectoryList.push_back (directory);
303  directory = new G4UIdirectory ("/vis/modeling/trajectories/");
304  directory -> SetGuidance ("Trajectory model commands.");
305  fDirectoryList.push_back (directory);
306  directory = new G4UIdirectory ("/vis/modeling/trajectories/create/");
307  directory -> SetGuidance ("Create trajectory models and messengers.");
308  fDirectoryList.push_back (directory);
309 
310  // Filtering command directory
311  directory = new G4UIdirectory ("/vis/filtering/");
312  directory -> SetGuidance ("Filtering commands.");
313  fDirectoryList.push_back (directory);
314  directory = new G4UIdirectory ("/vis/filtering/trajectories/");
315  directory -> SetGuidance ("Trajectory filtering commands.");
316  fDirectoryList.push_back (directory);
317  directory = new G4UIdirectory ("/vis/filtering/trajectories/create/");
318  directory -> SetGuidance ("Create trajectory filters and messengers.");
319  fDirectoryList.push_back (directory);
320  directory = new G4UIdirectory ("/vis/filtering/hits/");
321  directory -> SetGuidance ("Hit filtering commands.");
322  fDirectoryList.push_back (directory);
323  directory = new G4UIdirectory ("/vis/filtering/hits/create/");
324  directory -> SetGuidance ("Create hit filters and messengers.");
325  fDirectoryList.push_back (directory);
326  directory = new G4UIdirectory ("/vis/filtering/digi/");
327  directory -> SetGuidance ("Digi filtering commands.");
328  fDirectoryList.push_back (directory);
329  directory = new G4UIdirectory ("/vis/filtering/digi/create/");
330  directory -> SetGuidance ("Create digi filters and messengers.");
331  fDirectoryList.push_back (directory);
332 
334 
335  if (fVerbosity >= startup) {
336  G4cout << "Registering model factories..." << G4endl;
337  }
338 
340 
341  if (fVerbosity >= startup) {
342  G4cout <<
343  "\nYou have successfully registered the following model factories."
344  << G4endl;
346  G4cout << G4endl;
347  }
348 
349  if (fVerbosity >= startup) {
351  G4cout << G4endl;
352  }
353 
355 
356  if (fVerbosity >= startup) {
357  G4cout <<
358  "Some /vis commands (optionally) take a string to specify colour."
359  "\n\"/vis/list\" to see available colours."
360  << G4endl;
361  }
362 
363  fInitialised = true;
364 }
365 
367 {
368  G4Colour::InitialiseColourMap(); // Initialises (if not already initialised)
369 
370  // our forever 65 named colors taken long time ago from X11.
371  // Extracted from g4tools/include/tools/colors
372  // Copyright (C) 2010, Guy Barrand. All rights reserved.
373  // See the file tools.license for terms.
374 
375 #define TOOLS_COLORS_STAT(name,r,g,b) \
376 G4Colour::AddToMap(#name, G4Colour(r,g,b));
377 
378  //0-9
379  TOOLS_COLORS_STAT(aquamarine,0.496101F,0.996109F,0.828138F)
380  TOOLS_COLORS_STAT(mediumaquamarine,0.398444F,0.800793F,0.664073F)
381  // TOOLS_COLORS_STAT(black,0,0,0) (already defined)
382  // TOOLS_COLORS_STAT(blue,0,0,1) (already defined)
383  TOOLS_COLORS_STAT(cadetblue,0.371099F,0.617197F,0.62501F)
384  TOOLS_COLORS_STAT(cornflowerblue,0.390631F,0.58204F,0.925795F)
385  TOOLS_COLORS_STAT(darkslateblue,0.281254F,0.238285F,0.542977F)
386  TOOLS_COLORS_STAT(lightblue,0.675792F,0.843763F,0.898451F)
387  TOOLS_COLORS_STAT(lightsteelblue,0.68751F,0.765637F,0.867201F)
388  TOOLS_COLORS_STAT(mediumblue,0,0,0.800793F)
389 
390  //10-19
391  TOOLS_COLORS_STAT(mediumslateblue,0.480476F,0.406256F,0.929702F)
392  TOOLS_COLORS_STAT(midnightblue,0.0976577F,0.0976577F,0.437507F)
393  TOOLS_COLORS_STAT(navyblue,0,0,0.500008F)
394  TOOLS_COLORS_STAT(navy,0,0,0.500008F)
395  TOOLS_COLORS_STAT(skyblue,0.527352F,0.8047F,0.917983F)
396  TOOLS_COLORS_STAT(slateblue,0.414069F,0.351568F,0.800793F)
397  TOOLS_COLORS_STAT(steelblue,0.273442F,0.50782F,0.703136F)
398  TOOLS_COLORS_STAT(coral,0.996109F,0.496101F,0.312505F)
399  // TOOLS_COLORS_STAT(cyan,0,1,1) (already defined)
400  TOOLS_COLORS_STAT(firebrick,0.695323F,0.132815F,0.132815F)
401 
402  //20-29
403  // TOOLS_COLORS_STAT(brown,0.644541F,0.164065F,0.164065F) (already defined)
404  TOOLS_COLORS_STAT(gold,0.996109F,0.839857F,0)
405  TOOLS_COLORS_STAT(goldenrod,0.851575F,0.644541F,0.125002F)
406  // TOOLS_COLORS_STAT(green,0,1,0) (already defined)
407  TOOLS_COLORS_STAT(darkgreen,0,0.390631F,0)
408  TOOLS_COLORS_STAT(darkolivegreen,0.332036F,0.417975F,0.183597F)
409  TOOLS_COLORS_STAT(forestgreen,0.132815F,0.542977F,0.132815F)
410  TOOLS_COLORS_STAT(limegreen,0.195315F,0.800793F,0.195315F)
411  TOOLS_COLORS_STAT(mediumseagreen,0.234379F,0.699229F,0.441413F)
412  TOOLS_COLORS_STAT(mediumspringgreen,0,0.976577F,0.601572F)
413 
414  //30-39
415  TOOLS_COLORS_STAT(palegreen,0.593759F,0.980484F,0.593759F)
416  TOOLS_COLORS_STAT(seagreen,0.17969F,0.542977F,0.339849F)
417  TOOLS_COLORS_STAT(springgreen,0,0.996109F,0.496101F)
418  TOOLS_COLORS_STAT(yellowgreen,0.601572F,0.800793F,0.195315F)
419  TOOLS_COLORS_STAT(darkslategrey,0.183597F,0.308598F,0.308598F)
420  TOOLS_COLORS_STAT(dimgrey,0.410163F,0.410163F,0.410163F)
421  TOOLS_COLORS_STAT(lightgrey,0.824231F,0.824231F,0.824231F)
422  // TOOLS_COLORS_STAT(grey,0.750011F,0.750011F,0.750011F) (already defined)
423  TOOLS_COLORS_STAT(khaki,0.937514F,0.898451F,0.546883F)
424  // TOOLS_COLORS_STAT(magenta,1,0,1) (already defined)
425 
426  //40-49
427  TOOLS_COLORS_STAT(maroon,0.68751F,0.187503F,0.375006F)
428  TOOLS_COLORS_STAT(orange,0.996109F,0.644541F,0)
429  TOOLS_COLORS_STAT(orchid,0.851575F,0.437507F,0.83595F)
430  TOOLS_COLORS_STAT(darkorchid,0.597665F,0.195315F,0.796887F)
431  TOOLS_COLORS_STAT(mediumorchid,0.726574F,0.332036F,0.824231F)
432  TOOLS_COLORS_STAT(pink,0.996109F,0.750011F,0.792981F)
433  TOOLS_COLORS_STAT(plum,0.863294F,0.62501F,0.863294F)
434  // TOOLS_COLORS_STAT(red,1,0,0) (already defined)
435  TOOLS_COLORS_STAT(indianred,0.800793F,0.35938F,0.35938F)
436  TOOLS_COLORS_STAT(mediumvioletred,0.777356F,0.0820325F,0.519539F)
437 
438  //50-59
439  TOOLS_COLORS_STAT(orangered,0.996109F,0.269535F,0)
440  TOOLS_COLORS_STAT(violetred,0.812512F,0.125002F,0.562509F)
441  TOOLS_COLORS_STAT(salmon,0.976577F,0.500008F,0.445319F)
442  TOOLS_COLORS_STAT(sienna,0.62501F,0.320317F,0.175784F)
443  TOOLS_COLORS_STAT(tan,0.820325F,0.703136F,0.546883F)
444  TOOLS_COLORS_STAT(thistle,0.843763F,0.746105F,0.843763F)
445  TOOLS_COLORS_STAT(turquoise,0.250004F,0.875013F,0.812512F)
446  TOOLS_COLORS_STAT(darkturquoise,0,0.8047F,0.816419F)
447  TOOLS_COLORS_STAT(mediumturquoise,0.281254F,0.816419F,0.796887F)
448  TOOLS_COLORS_STAT(violet,0.929702F,0.50782F,0.929702F)
449 
450  //60-64
451  TOOLS_COLORS_STAT(blueviolet,0.539071F,0.167971F,0.882826F)
452  TOOLS_COLORS_STAT(wheat,0.957046F,0.867201F,0.699229F)
453  // TOOLS_COLORS_STAT(white,1,1,1) (already defined)
454  // TOOLS_COLORS_STAT(yellow,1,1,0) (already defined)
455  TOOLS_COLORS_STAT(greenyellow,0.675792F,0.996109F,0.18359F)
456 
457 #undef TOOLS_COLORS_STAT
458 }
459 
461 
462  // Instantiate individual messengers/commands (often - but not
463  // always - one command per messenger).
464 
465  G4UIcommand* directory;
466 
467  // *Basic* top level commands were instantiated in the constructor
468  // so that they can be used immediately after instantiation of the
469  // vis manager. Other top level and lower level commands are
470  // instantiated here.
471 
472  // Other top level commands...
478 
479  // Compound commands...
486 
487  directory = new G4UIdirectory ("/vis/geometry/");
488  directory -> SetGuidance("Operations on vis attributes of Geant4 geometry.");
489  fDirectoryList.push_back (directory);
492 
493  directory = new G4UIdirectory ("/vis/geometry/set/");
494  directory -> SetGuidance("Set vis attributes of Geant4 geometry.");
495  fDirectoryList.push_back (directory);
505 
506 #ifdef G4MULTITHREADED
507  directory = new G4UIdirectory ("/vis/multithreading/");
508  directory -> SetGuidance("Commands unique to multithreading mode.");
509  fDirectoryList.push_back (directory);
510  RegisterMessenger(new G4VisCommandMultithreadingActionOnEventQueueFull);
511  RegisterMessenger(new G4VisCommandMultithreadingMaxEventQueueSize);
512 #endif
513 
514  directory = new G4UIdirectory ("/vis/set/");
515  directory -> SetGuidance
516  ("Set quantities for use in future commands where appropriate.");
517  fDirectoryList.push_back (directory);
525 
526  directory = new G4UIdirectory ("/vis/scene/");
527  directory -> SetGuidance ("Operations on Geant4 scenes.");
528  fDirectoryList.push_back (directory);
536 
537  directory = new G4UIdirectory ("/vis/scene/add/");
538  directory -> SetGuidance ("Add model to current scene.");
539  fDirectoryList.push_back (directory);
563 
564  directory = new G4UIdirectory ("/vis/sceneHandler/");
565  directory -> SetGuidance ("Operations on Geant4 scene handlers.");
566  fDirectoryList.push_back (directory);
571 
572  directory = new G4UIdirectory ("/vis/touchable/");
573  directory -> SetGuidance ("Operations on touchables.");
574  fDirectoryList.push_back (directory);
576 
577  directory = new G4UIdirectory ("/vis/touchable/set/");
578  directory -> SetGuidance ("Set vis attributes of current touchable.");
579  fDirectoryList.push_back (directory);
581 
582  directory = new G4UIdirectory ("/vis/viewer/");
583  directory -> SetGuidance ("Operations on Geant4 viewers.");
584  fDirectoryList.push_back (directory);
608 
609  directory = new G4UIdirectory ("/vis/viewer/default/");
610  directory -> SetGuidance("Set default values for future viewers.");
611  fDirectoryList.push_back (directory);
614 
615  directory = new G4UIdirectory ("/vis/viewer/set/");
616  directory -> SetGuidance ("Set view parameters of current viewer.");
617  fDirectoryList.push_back (directory);
619 
620  // List manager commands
625 
626  // Trajectory filter manager commands
631 
632  // Hit filter manager commands
637 
638  // Digi filter manager commands
643 }
644 
646  if (IsValidView ()) {
647  SetConcreteInstance(this);
648  if (fVerbosity >= confirmations) {
649  G4cout << "G4VisManager::Enable: visualization enabled." << G4endl;
650  }
651  if (fVerbosity >= warnings) {
652  G4int nKeptEvents = 0;
654  if (run) nKeptEvents = run->GetEventVector()->size();
655  G4cout <<
656  "There are " << nKeptEvents << " kept events."
657  "\n \"/vis/reviewKeptEvents\" to review them one by one."
658  "\n \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
659  << G4endl;
660  }
661  }
662  else {
663  if (fVerbosity >= warnings) {
664  G4cout <<
665  "G4VisManager::Enable: WARNING: visualization remains disabled for"
666  "\n above reasons. Rectifying with valid vis commands will"
667  "\n automatically enable."
668  << G4endl;
669  }
670  }
671 }
672 
675  if (fVerbosity >= confirmations) {
676  G4cout <<
677  "G4VisManager::Disable: visualization disabled."
678  "\n The pointer returned by GetConcreteInstance will be zero."
679  "\n Note that it will become enabled after some valid vis commands."
680  << G4endl;
681  }
682  if (fVerbosity >= warnings) {
683  G4int currentTrajectoryType =
685  if (currentTrajectoryType > 0) {
686  G4cout <<
687  "You may wish to disable trajectory production too:"
688  "\n \"/tracking/storeTrajectory 0\""
689  "\nbut don't forget to re-enable with"
690  "\n \"/vis/enable\""
691  "\n \"/tracking/storeTrajectory " << currentTrajectoryType << "\" (for your case)."
692  << G4endl;
693  }
694  }
695 }
696 
698  G4int nSystems = fAvailableGraphicsSystems.size ();
699  if (nSystems == 0) {
700  if (fVerbosity >= warnings) {
701  G4cout << "G4VisManager::GetAvailableGraphicsSystems: WARNING: no"
702  "\n graphics system available!"
703  "\n 1) Did you have environment variables G4VIS_BUILD_xxxx_DRIVER set"
704  "\n when you compiled/built the visualization code?"
705  "\n 2) Did you instantiate your own Visualization Manager and forget"
706  "\n to implement RegisterGraphicsSystems correctly?"
707  "\n 3) You can register your own graphics system, e.g.,"
708  "\n visManager->RegisterGraphicsSystem(new MyGraphicsSystem);)"
709  "\n after instantiating your vis manager and before"
710  "\n visManager->Initialize()."
711  << G4endl;
712  }
713  }
715 }
716 
718  G4bool happy = true;
719  if (pSystem) {
720  fAvailableGraphicsSystems.push_back (pSystem);
721  if (fVerbosity >= confirmations) {
722  G4cout << "G4VisManager::RegisterGraphicsSystem: "
723  << pSystem -> GetName ();
724  if (pSystem -> GetNickname () != "") {
725  G4cout << " (" << pSystem -> GetNickname () << ")";
726  }
727  G4cout << " registered." << G4endl;
728  }
729  }
730  else {
731  if (fVerbosity >= errors) {
732  G4cout << "G4VisManager::RegisterGraphicsSystem: null pointer!"
733  << G4endl;
734  }
735  happy=false;
736  }
737  return happy;
738 }
739 
740 const G4VTrajectoryModel*
742 {
743  assert (0 != fpTrajDrawModelMgr);
744 
746 
747  if (0 == model) {
748  // No model was registered with the trajectory model manager.
749  // Use G4TrajectoryDrawByCharge as a fallback.
751  if (fVerbosity >= warnings) {
752  G4cout<<"G4VisManager: Using G4TrajectoryDrawByCharge as fallback trajectory model."<<G4endl;
753  G4cout<<"See commands in /vis/modeling/trajectories/ for other options."<<G4endl;
754  }
755  }
756 
757  model = fpTrajDrawModelMgr->Current();
758  assert (0 != model); // Should definitely exist now
759 
760  return model;
761 }
762 
764 {
766 }
767 
768 void
770 {
771  fpTrajDrawModelMgr->Register(factory);
772 }
773 
775 {
776  fpTrajFilterMgr->Register(model);
777 }
778 
779 void
781 {
782  fpTrajFilterMgr->Register(factory);
783 }
784 
786 {
787  fpHitFilterMgr->Register(model);
788 }
789 
790 void
792 {
793  fpHitFilterMgr->Register(factory);
794 }
795 
797 {
798  fpDigiFilterMgr->Register(model);
799 }
800 
801 void
803 {
804  fpDigiFilterMgr->Register(factory);
805 }
806 
808 {
810 }
811 
812 void G4VisManager::BeginDraw (const G4Transform3D& objectTransform)
813 {
814 #ifdef G4MULTITHREADED
815  if (G4Threading::IsWorkerThread()) return;
816 #endif
818  if (fDrawGroupNestingDepth > 1) {
820  ("G4VisManager::BeginDraw",
821  "visman0008", JustWarning,
822  "Nesting detected. It is illegal to nest Begin/EndDraw."
823  "\n Ignored");
824  return;
825  }
826  if (IsValidView ()) {
828  fpSceneHandler -> BeginPrimitives (objectTransform);
829  fIsDrawGroup = true;
830  }
831 }
832 
834 {
835 #ifdef G4MULTITHREADED
836  if (G4Threading::IsWorkerThread()) return;
837 #endif
839  if (fDrawGroupNestingDepth != 0) {
841  return;
842  }
843  if (IsValidView ()) {
844  fpSceneHandler -> EndPrimitives ();
845  }
846  fIsDrawGroup = false;
847 }
848 
849 void G4VisManager::BeginDraw2D (const G4Transform3D& objectTransform)
850 {
851 #ifdef G4MULTITHREADED
852  if (G4Threading::IsWorkerThread()) return;
853 #endif
855  if (fDrawGroupNestingDepth > 1) {
857  ("G4VisManager::BeginDraw2D",
858  "visman0009", JustWarning,
859  "Nesting detected. It is illegal to nest Begin/EndDraw2D."
860  "\n Ignored");
861  return;
862  }
863  if (IsValidView ()) {
865  fpSceneHandler -> BeginPrimitives2D (objectTransform);
866  fIsDrawGroup = true;
867  }
868 }
869 
871 {
872 #ifdef G4MULTITHREADED
873  if (G4Threading::IsWorkerThread()) return;
874 #endif
876  if (fDrawGroupNestingDepth != 0) {
878  return;
879  }
880  if (IsValidView ()) {
881  fpSceneHandler -> EndPrimitives2D ();
882  }
883  fIsDrawGroup = false;
884 }
885 
886 template <class T> void G4VisManager::DrawT
887 (const T& graphics_primitive, const G4Transform3D& objectTransform) {
888 #ifdef G4MULTITHREADED
889  if (G4Threading::IsWorkerThread()) return;
890 #endif
891  if (fIsDrawGroup) {
892  if (objectTransform != fpSceneHandler->GetObjectTransformation()) {
894  ("G4VSceneHandler::DrawT",
895  "visman0010", FatalException,
896  "Different transform detected in Begin/EndDraw group.");
897  }
898  fpSceneHandler -> AddPrimitive (graphics_primitive);
899  } else {
900  if (IsValidView ()) {
901  ClearTransientStoreIfMarked();
902  fpSceneHandler -> BeginPrimitives (objectTransform);
903  fpSceneHandler -> AddPrimitive (graphics_primitive);
904  fpSceneHandler -> EndPrimitives ();
905  }
906  }
907 }
908 
909 template <class T> void G4VisManager::DrawT2D
910 (const T& graphics_primitive, const G4Transform3D& objectTransform) {
911 #ifdef G4MULTITHREADED
912  if (G4Threading::IsWorkerThread()) return;
913 #endif
914  if (fIsDrawGroup) {
915  if (objectTransform != fpSceneHandler->GetObjectTransformation()) {
917  ("G4VSceneHandler::DrawT",
918  "visman0011", FatalException,
919  "Different transform detected in Begin/EndDraw2D group.");
920  }
921  fpSceneHandler -> AddPrimitive (graphics_primitive);
922  } else {
923  if (IsValidView ()) {
924  ClearTransientStoreIfMarked();
925  fpSceneHandler -> BeginPrimitives2D (objectTransform);
926  fpSceneHandler -> AddPrimitive (graphics_primitive);
927  fpSceneHandler -> EndPrimitives2D ();
928  }
929  }
930 }
931 
932 void G4VisManager::Draw (const G4Circle& circle,
933  const G4Transform3D& objectTransform)
934 {
935  DrawT (circle, objectTransform);
936 }
937 
938 void G4VisManager::Draw (const G4Polyhedron& polyhedron,
939  const G4Transform3D& objectTransform)
940 {
941  DrawT (polyhedron, objectTransform);
942 }
943 
944 void G4VisManager::Draw (const G4Polyline& line,
945  const G4Transform3D& objectTransform)
946 {
947  DrawT (line, objectTransform);
948 }
949 
950 void G4VisManager::Draw (const G4Polymarker& polymarker,
951  const G4Transform3D& objectTransform)
952 {
953  DrawT (polymarker, objectTransform);
954 }
955 
957  const G4Transform3D& objectTransform)
958 {
959  DrawT (scale, objectTransform);
960 }
961 
962 void G4VisManager::Draw (const G4Square& square,
963  const G4Transform3D& objectTransform)
964 {
965  DrawT (square, objectTransform);
966 }
967 
968 void G4VisManager::Draw (const G4Text& text,
969  const G4Transform3D& objectTransform)
970 {
971  DrawT (text, objectTransform);
972 }
973 
974 void G4VisManager::Draw2D (const G4Circle& circle,
975  const G4Transform3D& objectTransform)
976 {
977  DrawT2D (circle, objectTransform);
978 }
979 
980 void G4VisManager::Draw2D (const G4Polyhedron& polyhedron,
981  const G4Transform3D& objectTransform)
982 {
983  DrawT2D (polyhedron, objectTransform);
984 }
985 
987  const G4Transform3D& objectTransform)
988 {
989  DrawT2D (line, objectTransform);
990 }
991 
992 void G4VisManager::Draw2D (const G4Polymarker& polymarker,
993  const G4Transform3D& objectTransform)
994 {
995  DrawT2D (polymarker, objectTransform);
996 }
997 
998 void G4VisManager::Draw2D (const G4Square& square,
999  const G4Transform3D& objectTransform)
1000 {
1001  DrawT2D (square, objectTransform);
1002 }
1003 
1004 void G4VisManager::Draw2D (const G4Text& text,
1005  const G4Transform3D& objectTransform)
1006 {
1007  DrawT2D (text, objectTransform);
1008 }
1009 
1010 void G4VisManager::Draw (const G4VHit& hit) {
1011 #ifdef G4MULTITHREADED
1012  if (G4Threading::IsWorkerThread()) return;
1013 #endif
1014  if (fIsDrawGroup) {
1015  fpSceneHandler -> AddCompound (hit);
1016  } else {
1017  if (IsValidView ()) {
1019  fpSceneHandler -> AddCompound (hit);
1020  }
1021  }
1022 }
1023 
1024 void G4VisManager::Draw (const G4VDigi& digi) {
1025 #ifdef G4MULTITHREADED
1026  if (G4Threading::IsWorkerThread()) return;
1027 #endif
1028  if (fIsDrawGroup) {
1029  fpSceneHandler -> AddCompound (digi);
1030  } else {
1031  if (IsValidView ()) {
1033  fpSceneHandler -> AddCompound (digi);
1034  }
1035  }
1036 }
1037 
1038 void G4VisManager::Draw (const G4VTrajectory& traj) {
1039 #ifdef G4MULTITHREADED
1040  if (G4Threading::IsWorkerThread()) return;
1041 #endif
1042  // A trajectory needs a trajectories model to provide G4Atts, etc.
1043  static G4TrajectoriesModel trajectoriesModel;
1044  trajectoriesModel.SetCurrentTrajectory(&traj);
1045  G4RunManager* runManager = G4RunManager::GetRunManager();
1046 #ifdef G4MULTITHREADED
1048  runManager = G4MTRunManager::GetMasterRunManager();
1049  }
1050 #endif
1051  const G4Run* currentRun = runManager->GetCurrentRun();
1052  if (currentRun) {
1053  trajectoriesModel.SetRunID(currentRun->GetRunID());
1054  }
1055  const G4Event* currentEvent =
1057  if (currentEvent) {
1058  trajectoriesModel.SetEventID(currentEvent->GetEventID());
1059  }
1060  if (fIsDrawGroup) {
1061  fpSceneHandler -> SetModel (&trajectoriesModel);
1062  fpSceneHandler -> AddCompound (traj);
1063  fpSceneHandler -> SetModel (0);
1064  } else {
1065  if (IsValidView ()) {
1067  fpSceneHandler -> SetModel (&trajectoriesModel);
1068  fpSceneHandler -> AddCompound (traj);
1069  fpSceneHandler -> SetModel (0);
1070  }
1071  }
1072 }
1073 
1074 void G4VisManager::Draw (const G4LogicalVolume& logicalVol,
1075  const G4VisAttributes& attribs,
1076  const G4Transform3D& objectTransform) {
1077 #ifdef G4MULTITHREADED
1078  if (G4Threading::IsWorkerThread()) return;
1079 #endif
1080  // Find corresponding solid.
1081  G4VSolid* pSol = logicalVol.GetSolid ();
1082  Draw (*pSol, attribs, objectTransform);
1083 }
1084 
1085 void G4VisManager::Draw (const G4VSolid& solid,
1086  const G4VisAttributes& attribs,
1087  const G4Transform3D& objectTransform) {
1088 #ifdef G4MULTITHREADED
1089  if (G4Threading::IsWorkerThread()) return;
1090 #endif
1091  if (fIsDrawGroup) {
1092  fpSceneHandler -> PreAddSolid (objectTransform, attribs);
1094  fpSceneHandler -> PostAddSolid ();
1095  } else {
1096  if (IsValidView ()) {
1098  fpSceneHandler -> PreAddSolid (objectTransform, attribs);
1100  fpSceneHandler -> PostAddSolid ();
1101  }
1102  }
1103 }
1104 
1105 void G4VisManager::Draw (const G4VPhysicalVolume& physicalVol,
1106  const G4VisAttributes& attribs,
1107  const G4Transform3D& objectTransform) {
1108 #ifdef G4MULTITHREADED
1109  if (G4Threading::IsWorkerThread()) return;
1110 #endif
1111  // Note: It is tempting to use a temporary model here, as for
1112  // trajectories, in order to get at the G4Atts of the physical
1113  // volume. I tried it (JA). But it's not easy to pass the
1114  // vis attributes. Also other aspects of the model seem not to
1115  // be properly set up. So, the idea has been abandoned for the time
1116  // being. The model pointer will be null. So when picking there
1117  // will be no G4Atts from this physical volume.
1118  //
1119  // If this is called from DrawHit, for example, the user may G4Atts to the
1120  // hit and these will be available with "/vis/scene/add/hits".
1121  //
1122  // Find corresponding logical volume and solid.
1123  G4LogicalVolume* pLV = physicalVol.GetLogicalVolume ();
1124  G4VSolid* pSol = pLV -> GetSolid ();
1125  Draw (*pSol, attribs, objectTransform);
1126 }
1127 
1129  if (!fInitialised) Initialise ();
1130  if (fpGraphicsSystem) {
1131  G4VSceneHandler* pSceneHandler =
1133  if (pSceneHandler) {
1134  fAvailableSceneHandlers.push_back (pSceneHandler);
1135  fpSceneHandler = pSceneHandler; // Make current.
1136  }
1137  else {
1138  if (fVerbosity >= errors) {
1139  G4cout << "ERROR in G4VisManager::CreateSceneHandler during "
1140  << fpGraphicsSystem -> GetName ()
1141  << " scene handler creation.\n No action taken."
1142  << G4endl;
1143  }
1144  }
1145  }
1146  else PrintInvalidPointers ();
1147 }
1148 
1150 (const G4String& name, const G4String& XGeometry)
1151 {
1152 
1153  if (!fInitialised) Initialise ();
1154 
1155  if (!fpSceneHandler) {
1156  PrintInvalidPointers ();
1157  return;
1158  }
1159 
1160  G4VViewer* p = fpGraphicsSystem -> CreateViewer (*fpSceneHandler, name);
1161 
1162  if (!p) {
1163  if (fVerbosity >= errors) {
1164  G4cerr << "ERROR in G4VisManager::CreateViewer: null pointer during "
1165  << fpGraphicsSystem -> GetName ()
1166  << " viewer creation.\n No action taken."
1167  << G4endl;
1168  }
1169  return;
1170  }
1171 
1172  if (p -> GetViewId() < 0) {
1173  if (fVerbosity >= errors) {
1174  G4cerr << "ERROR in G4VisManager::CreateViewer during "
1175  << fpGraphicsSystem -> GetName ()
1176  << " viewer instantiation.\n No action taken."
1177  << G4endl;
1178  }
1179  return;
1180  }
1181 
1182  // Viewer is created, now we can set geometry parameters
1183  // Before 12/2008, it was done in G4VViewer.cc but it did not have to be there!
1184 
1185  G4ViewParameters initialvp = p -> GetViewParameters();
1186  initialvp.SetXGeometryString(XGeometry); //parse string and store parameters
1187  p -> SetViewParameters(initialvp);
1188  p -> Initialise (); // (Viewer itself may change view parameters further.)
1189  if (p -> GetViewId() < 0) {
1190  if (fVerbosity >= errors) {
1191  G4cerr << "ERROR in G4VisManager::CreateViewer during "
1192  << fpGraphicsSystem -> GetName ()
1193  << " viewer initialisation.\n No action taken."
1194  << G4endl;
1195  }
1196  return;
1197  }
1198 
1199  fpViewer = p; // Make current.
1200  fpSceneHandler -> AddViewerToList (fpViewer);
1201  fpSceneHandler -> SetCurrentViewer (fpViewer);
1202  if (fVerbosity >= confirmations) {
1203  G4cout << "G4VisManager::CreateViewer: new viewer created."
1204  << G4endl;
1205  }
1206 
1207  const G4ViewParameters& vp = fpViewer->GetViewParameters();
1208  if (fVerbosity >= parameters) {
1209  G4cout << " view parameters are:\n " << vp << G4endl;
1210  }
1211 
1212  if (vp.IsCulling () && vp.IsCullingInvisible ()) {
1213  static G4bool warned = false;
1214  if (fVerbosity >= confirmations) {
1215  if (!warned) {
1216  G4cout <<
1217  "NOTE: objects with visibility flag set to \"false\""
1218  " will not be drawn!"
1219  "\n \"/vis/viewer/set/culling global false\" to Draw such objects."
1220  "\n Also see other \"/vis/viewer/set\" commands."
1221  << G4endl;
1222  warned = true;
1223  }
1224  }
1225  }
1226  if (vp.IsCullingCovered ()) {
1227  static G4bool warned = false;
1228  if (fVerbosity >= warnings) {
1229  if (!warned) {
1230  G4cout <<
1231  "WARNING: covered objects in solid mode will not be rendered!"
1232  "\n \"/vis/viewer/set/culling coveredDaughters false\" to reverse this."
1233  "\n Also see other \"/vis/viewer/set\" commands."
1234  << G4endl;
1235  warned = true;
1236  }
1237  }
1238  }
1239 }
1240 
1242  if (fVerbosity >= confirmations) {
1243  G4cout << "G4VisManager::GeometryHasChanged() called." << G4endl;
1244  }
1245 
1246  // Change the world...
1247  G4VPhysicalVolume* pWorld =
1249  -> GetNavigatorForTracking () -> GetWorldVolume ();
1250  if (!pWorld) {
1251  if (fVerbosity >= warnings) {
1252  G4cout << "WARNING: There is no world volume!" << G4endl;
1253  }
1254  }
1255 
1256  // Check scenes.
1257  G4SceneList& sceneList = fSceneList;
1258  G4int iScene, nScenes = sceneList.size ();
1259  for (iScene = 0; iScene < nScenes; iScene++) {
1260  G4Scene* pScene = sceneList [iScene];
1261  std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
1262  if (modelList.size ()) {
1263  G4bool modelInvalid;
1264  do { // Remove, if required, one at a time.
1265  modelInvalid = false;
1266  std::vector<G4Scene::Model>::iterator iterModel;
1267  for (iterModel = modelList.begin();
1268  iterModel != modelList.end();
1269  ++iterModel) {
1270  modelInvalid = !(iterModel->fpModel->Validate(fVerbosity>=warnings));
1271  if (modelInvalid) {
1272  // Model invalid - remove and break.
1273  if (fVerbosity >= warnings) {
1274  G4cout << "WARNING: Model \""
1275  << iterModel->fpModel->GetGlobalDescription ()
1276  <<
1277  "\" is no longer valid - being removed\n from scene \""
1278  << pScene -> GetName () << "\""
1279  << G4endl;
1280  }
1281  modelList.erase (iterModel);
1282  break;
1283  }
1284  }
1285  } while (modelInvalid);
1286 
1287  if (modelList.size () == 0) {
1288  if (fVerbosity >= warnings) {
1289  G4cout << "WARNING: No models left in this scene \""
1290  << pScene -> GetName ()
1291  << "\"."
1292  << G4endl;
1293  }
1294  }
1295  else {
1296  pScene->CalculateExtent();
1298  ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName()));
1299  }
1300  }
1301  }
1302 
1303  // Check the manager's current scene...
1304  if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) {
1305  if (fVerbosity >= warnings) {
1306  G4cout << "WARNING: The current scene \""
1307  << fpScene -> GetName ()
1308  << "\" has no models."
1309  << G4endl;
1310  }
1311  }
1312 }
1313 
1315 
1316  if (fVerbosity >= confirmations) {
1317  G4cout << "G4VisManager::NotifyHandler() called." << G4endl;
1318  }
1319 
1320  // Check scenes.
1321  G4SceneList& sceneList = fSceneList;
1322  G4int iScene, nScenes = sceneList.size ();
1323  for (iScene = 0; iScene < nScenes; iScene++) {
1324  G4Scene* pScene = sceneList [iScene];
1325  std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
1326 
1327  if (modelList.size ()) {
1328  pScene->CalculateExtent();
1330  ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName()));
1331  }
1332  }
1333 
1334  // Check the manager's current scene...
1335  if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) {
1336  if (fVerbosity >= warnings) {
1337  G4cout << "WARNING: The current scene \""
1338  << fpScene -> GetName ()
1339  << "\" has no models."
1340  << G4endl;
1341  }
1342  }
1343 }
1344 
1346 {
1347  return fpTrajFilterMgr->Accept(trajectory);
1348 }
1349 
1351 {
1352  return fpHitFilterMgr->Accept(hit);
1353 }
1354 
1356 {
1357  return fpDigiFilterMgr->Accept(digi);
1358 }
1359 
1361 {
1362  G4bool visible(true);
1363 
1364  // See if trajectory passes filter
1365  G4bool passed = FilterTrajectory(trajectory);
1366 
1367  if (!passed) {
1368  // Draw invisible trajectory if trajectory failed filter and
1369  // are filtering in soft mode
1370  if (fpTrajFilterMgr->GetMode() == FilterMode::Soft) visible = false;
1371  else {return;}
1372  }
1373 
1374  // Go on to draw trajectory
1375  assert (0 != fpTrajDrawModelMgr);
1376 
1377  const G4VTrajectoryModel* trajectoryModel = CurrentTrajDrawModel();
1378 
1379  assert (0 != trajectoryModel); // Should exist
1380 
1381  if (IsValidView()) {
1382  trajectoryModel->Draw(trajectory, visible);
1383  }
1384 }
1385 
1387 (G4VUserVisAction* pVisAction,
1388  const G4VisExtent& extent) {
1389  if (fVerbosity >= warnings) {
1390  G4cout <<
1391  "WARNING: SetUserAction is deprecated. Use RegisterRunDurationUserVisAction."
1392  << G4endl;
1393  }
1394  RegisterRunDurationUserVisAction("SetUserAction",pVisAction,extent);
1395 }
1396 
1398 (const G4String& name,
1399  G4VUserVisAction* pVisAction,
1400  const G4VisExtent& extent) {
1401  fRunDurationUserVisActions.push_back(UserVisAction(name,pVisAction));
1402  if (extent.GetExtentRadius() > 0.) {
1403  fUserVisActionExtents[pVisAction] = extent;
1404  } else {
1405  if (fVerbosity >= warnings) {
1406  G4cout <<
1407  "WARNING: No extent set for user vis action \"" << name << "\"."
1408  << G4endl;
1409  }
1410  }
1411 }
1412 
1414 (const G4String& name,
1415  G4VUserVisAction* pVisAction,
1416  const G4VisExtent& extent) {
1417  fEndOfEventUserVisActions.push_back(UserVisAction(name,pVisAction));
1418  if (extent.GetExtentRadius() > 0.) {
1419  fUserVisActionExtents[pVisAction] = extent;
1420  } else {
1421  if (fVerbosity >= warnings) {
1422  G4cout <<
1423  "WARNING: No extent set for user vis action \"" << name << "\"."
1424  << G4endl;
1425  }
1426  }
1427 }
1428 
1430 (const G4String& name,
1431  G4VUserVisAction* pVisAction,
1432  const G4VisExtent& extent) {
1433  fEndOfRunUserVisActions.push_back(UserVisAction(name,pVisAction));
1434  if (extent.GetExtentRadius() > 0.) {
1435  fUserVisActionExtents[pVisAction] = extent;
1436  } else {
1437  if (fVerbosity >= warnings) {
1438  G4cout <<
1439  "WARNING: No extent set for user vis action \"" << name << "\"."
1440  << G4endl;
1441  }
1442  }
1443 }
1444 
1446  if (pScene != fpScene) {
1447  // A change of scene. Therefore reset transients drawn flags. All
1448  // memory of previous transient proceessing thereby erased...
1450  }
1451  fpScene = pScene;
1452 }
1453 
1455  fpGraphicsSystem = pSystem;
1456  if (fVerbosity >= confirmations) {
1457  G4cout << "G4VisManager::SetCurrentGraphicsSystem: system now "
1458  << pSystem -> GetName () << G4endl;
1459  }
1460  // If current scene handler is of same graphics system, leave unchanged.
1461  // Else find the most recent scene handler of same graphics system.
1462  // Or clear pointers.
1463  if (!(fpSceneHandler && fpSceneHandler -> GetGraphicsSystem () == pSystem)) {
1464  const G4SceneHandlerList& sceneHandlerList = fAvailableSceneHandlers;
1465  G4int nSH = sceneHandlerList.size (); // No. of scene handlers.
1466  G4int iSH;
1467  for (iSH = nSH - 1; iSH >= 0; iSH--) {
1468  if (sceneHandlerList [iSH] -> GetGraphicsSystem () == pSystem) break;
1469  }
1470  if (iSH >= 0) {
1471  fpSceneHandler = sceneHandlerList [iSH];
1472  if (fVerbosity >= confirmations) {
1473  G4cout << " Scene Handler now "
1474  << fpSceneHandler -> GetName () << G4endl;
1475  }
1476  if (fpScene != fpSceneHandler -> GetScene ()) {
1477  fpScene = fpSceneHandler -> GetScene ();
1478  if (fVerbosity >= confirmations) {
1479  G4cout << " Scene now \""
1480  << fpScene -> GetName () << "\"" << G4endl;
1481  }
1482  }
1483  const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList ();
1484  if (viewerList.size ()) {
1485  fpViewer = viewerList [0];
1486  if (fVerbosity >= confirmations) {
1487  G4cout << " Viewer now " << fpViewer -> GetName () << G4endl;
1488  }
1489  }
1490  else {
1491  fpViewer = 0;
1492  }
1493  }
1494  else {
1495  fpSceneHandler = 0;
1496  fpViewer = 0;
1497  }
1498  }
1499 }
1500 
1502  fpSceneHandler = pSceneHandler;
1503  if (fVerbosity >= confirmations) {
1504  G4cout << "G4VisManager::SetCurrentSceneHandler: scene handler now \""
1505  << pSceneHandler -> GetName () << "\"" << G4endl;
1506  }
1507  if (fpScene != fpSceneHandler -> GetScene ()) {
1508  fpScene = fpSceneHandler -> GetScene ();
1509  if (fVerbosity >= confirmations) {
1510  G4cout << " Scene now \""
1511  << fpScene -> GetName () << "\"" << G4endl;
1512  }
1513  }
1514  if (fpGraphicsSystem != pSceneHandler -> GetGraphicsSystem ()) {
1515  fpGraphicsSystem = pSceneHandler -> GetGraphicsSystem ();
1516  if (fVerbosity >= confirmations) {
1517  G4cout << " Graphics system now \""
1518  << fpGraphicsSystem -> GetName () << "\"" << G4endl;
1519  }
1520  }
1521  const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList ();
1522  G4int nViewers = viewerList.size ();
1523  if (nViewers) {
1524  G4int iViewer;
1525  for (iViewer = 0; iViewer < nViewers; iViewer++) {
1526  if (fpViewer == viewerList [iViewer]) break;
1527  }
1528  if (iViewer >= nViewers) {
1529  fpViewer = viewerList [0];
1530  if (fVerbosity >= confirmations) {
1531  G4cout << " Viewer now \"" << fpViewer -> GetName () << "\""
1532  << G4endl;
1533  }
1534  }
1535  if (!IsValidView ()) {
1536  if (fVerbosity >= warnings) {
1537  G4cout <<
1538  "WARNING: Problem setting scene handler - please report circumstances."
1539  << G4endl;
1540  }
1541  }
1542  }
1543  else {
1544  fpViewer = 0;
1545  if (fVerbosity >= warnings) {
1546  G4cout <<
1547  "WARNING: No viewers for this scene handler - please create one."
1548  << G4endl;
1549  }
1550  }
1551 }
1552 
1554  fpViewer = pViewer;
1555  if (fVerbosity >= confirmations) {
1556  G4cout << "G4VisManager::SetCurrentViewer: viewer now "
1557  << pViewer -> GetName ()
1558  << G4endl;
1559  }
1560  fpSceneHandler = fpViewer -> GetSceneHandler ();
1561  if (!fpSceneHandler) {
1562  if (fVerbosity >= warnings) {
1563  G4cout <<
1564  "WARNING: No scene handler for this viewer - please create one."
1565  << G4endl;
1566  }
1567  return;
1568  }
1569  fpViewer->SetView();
1570  fpSceneHandler -> SetCurrentViewer (pViewer);
1571  fpScene = fpSceneHandler -> GetScene ();
1572  fpGraphicsSystem = fpSceneHandler -> GetGraphicsSystem ();
1573  if (!IsValidView ()) {
1574  if (fVerbosity >= warnings) {
1575  G4cout <<
1576  "WARNING: Problem setting viewer - please report circumstances."
1577  << G4endl;
1578  }
1579  }
1580 }
1581 
1583 {
1584  G4cout << "Current available graphics systems are:\n";
1585  if (fAvailableGraphicsSystems.size ()) {
1586  for (const auto& gs: fAvailableGraphicsSystems) {
1587  const G4String& name = gs->GetName();
1588  const std::vector<G4String>& nicknames = gs->GetNicknames();
1589  if (verbosity <= warnings) {
1590  // Brief output
1591  G4cout << name << " (";
1592  for (size_t i = 0; i < nicknames.size(); ++i) {
1593  if (i != 0) {
1594  G4cout << ", ";
1595  }
1596  G4cout << nicknames[i];
1597  }
1598  G4cout << ')';
1599  } else {
1600  // Full output
1601  G4cout << *gs;
1602  }
1603  G4cout << G4endl;
1604  }
1605  } else {
1606  G4cout << "\n NONE!!! None registered - yet! Mmmmm!" << G4endl;
1607  }
1608 }
1609 
1611 {
1612  {
1613  //fpTrajDrawModelMgr->Print(G4cout);
1614  G4cout << "Registered model factories:" << G4endl;
1615  const std::vector<G4VModelFactory<G4VTrajectoryModel>*>& factoryList =
1617  if (factoryList.empty()) G4cout << " None" << G4endl;
1618  else {
1619  std::vector<G4VModelFactory<G4VTrajectoryModel>*>::const_iterator i;
1620  for (i = factoryList.begin(); i != factoryList.end(); ++i)
1621  (*i)->Print(G4cout);
1622  }
1623  const G4VisListManager<G4VTrajectoryModel>* listManager =
1625  const std::map<G4String, G4VTrajectoryModel*>& modelMap =
1626  listManager->Map();
1627  if (!modelMap.empty()) {
1628  G4cout << "\nRegistered models:" << G4endl;
1629  std::map<G4String, G4VTrajectoryModel*>::const_iterator i;
1630  for (i = modelMap.begin(); i != modelMap.end(); ++i) {
1631  G4cout << " " << i->second->Name();
1632  if (i->second == listManager->Current()) G4cout << " (Current)";
1633  G4cout << G4endl;
1634  if (verbosity >= parameters) i->second->Print(G4cout);
1635  }
1636  }
1637  }
1638 
1639  G4cout << G4endl;
1640 
1641  {
1642  //fpTrajFilterMgr->Print(G4cout);
1643  G4cout << "Registered filter factories:" << G4endl;
1644  const std::vector<G4VModelFactory<G4VFilter<G4VTrajectory> >*>&
1645  factoryList = fpTrajFilterMgr->FactoryList();
1646  if (factoryList.empty()) G4cout << " None" << G4endl;
1647  else {
1648  std::vector<G4VModelFactory<G4VFilter<G4VTrajectory> >*>::const_iterator i;
1649  for (i = factoryList.begin(); i != factoryList.end(); ++i)
1650  (*i)->Print(G4cout);
1651  }
1652  const std::vector<G4VFilter<G4VTrajectory>*>&
1653  filterList = fpTrajFilterMgr->FilterList();
1654  if (!filterList.empty()) {
1655  G4cout << "\nRegistered filters:" << G4endl;
1656  std::vector<G4VFilter<G4VTrajectory>*>::const_iterator i;
1657  for (i = filterList.begin(); i != filterList.end(); ++i) {
1658  G4cout << " " << (*i)->GetName() << G4endl;
1659  if (verbosity >= parameters) (*i)->PrintAll(G4cout);
1660  }
1661  }
1662  }
1663 }
1664 
1666 {
1667  G4cout <<
1668  "You have successfully registered the following user vis actions."
1669  << G4endl;
1670  G4cout << "Run Duration User Vis Actions:";
1671  if (fRunDurationUserVisActions.empty()) G4cout << " none" << G4endl;
1672  else {
1673  G4cout << G4endl;
1674  for (size_t i = 0; i < fRunDurationUserVisActions.size(); i++) {
1675  const G4String& name = fRunDurationUserVisActions[i].fName;
1676  G4cout << " " << name << G4endl;
1677  }
1678  }
1679 
1680  G4cout << "End of Event User Vis Actions:";
1681  if (fEndOfEventUserVisActions.empty()) G4cout << " none" << G4endl;
1682  else {
1683  G4cout << G4endl;
1684  for (size_t i = 0; i < fEndOfEventUserVisActions.size(); i++) {
1685  const G4String& name = fEndOfEventUserVisActions[i].fName;
1686  G4cout << " " << name << G4endl;
1687  }
1688  }
1689 
1690  G4cout << "End of Run User Vis Actions:";
1691  if (fEndOfRunUserVisActions.empty()) G4cout << " none" << G4endl;
1692  else {
1693  G4cout << G4endl;
1694  for (size_t i = 0; i < fEndOfRunUserVisActions.size(); i++) {
1695  const G4String& name = fEndOfRunUserVisActions[i].fName;
1696  G4cout << " " << name << G4endl;
1697  }
1698  }
1699 }
1700 
1702  G4cout <<
1703  "Some /vis commands (optionally) take a string to specify colour."
1704  "\nAvailable colours:\n ";
1705  const std::map<G4String, G4Colour>& map = G4Colour::GetMap();
1706  for (std::map<G4String, G4Colour>::const_iterator i = map.begin();
1707  i != map.end();) {
1708  G4cout << i->first;
1709  if (++i != map.end()) G4cout << ", ";
1710  }
1711  G4cout << G4endl;
1712 }
1713 
1715  if (fVerbosity >= errors) {
1716  G4cerr << "ERROR: G4VisManager::PrintInvalidPointers:";
1717  if (!fpGraphicsSystem) {
1718  G4cerr << "\n null graphics system pointer.";
1719  }
1720  else {
1721  G4cerr << "\n Graphics system is " << fpGraphicsSystem -> GetName ()
1722  << " but:";
1723  if (!fpScene)
1724  G4cerr <<
1725  "\n Null scene pointer. Use \"/vis/drawVolume\" or"
1726  " \"/vis/scene/create\".";
1727  if (!fpSceneHandler)
1728  G4cerr <<
1729  "\n Null scene handler pointer. Use \"/vis/open\" or"
1730  " \"/vis/sceneHandler/create\".";
1731  if (!fpViewer )
1732  G4cerr <<
1733  "\n Null viewer pointer. Use \"/vis/viewer/create\".";
1734  }
1735  G4cerr << G4endl;
1736  }
1737 }
1738 
1739 #ifdef G4MULTITHREADED
1740 
1741 namespace {
1742  G4bool mtRunInProgress = false;
1743  std::deque<const G4Event*> mtVisEventQueue;
1744  G4Thread* mtVisSubThread = 0;
1745  G4Mutex mtVisSubThreadMutex = G4MUTEX_INITIALIZER;
1746 }
1747 
1748 G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
1749 {
1750  G4VisManager* pVisManager = (G4VisManager*)p;
1751  G4VSceneHandler* pSceneHandler = pVisManager->GetCurrentSceneHandler();
1752  if (!pSceneHandler) return 0;
1753  G4Scene* pScene = pSceneHandler->GetScene();
1754  if (!pScene) return 0;
1755  G4VViewer* pViewer = pVisManager->GetCurrentViewer();
1756  if (!pViewer) return 0;
1757 
1759 
1760 // G4cout << "G4VisManager::G4VisSubThread: thread: "
1761 // << G4Threading::G4GetThreadId() << std::endl;
1762 
1763  // Set up geometry and navigation for a thread
1766  G4Navigator* navigator =
1768  navigator->SetWorldVolume
1769  (G4MTRunManager::GetMasterRunManagerKernel()->GetCurrentWorld());
1770 
1771  pViewer->SwitchToVisSubThread();
1772 
1773  while (true) {
1774 
1775  G4MUTEXLOCK(&mtVisSubThreadMutex);
1776  G4int eventQueueSize = mtVisEventQueue.size();
1777  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1778 // G4cout << "Event queue size (A): " << eventQueueSize << G4endl;
1779 
1780  while (eventQueueSize) {
1781 
1782  G4MUTEXLOCK(&mtVisSubThreadMutex);
1783  const G4Event* event = mtVisEventQueue.front();
1784  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1785 // G4int eventID = event->GetEventID();
1786 // G4cout <<
1787 // "G4VisManager::G4VisSubThread: Vis sub-thread: Dealing with event: "
1788 // << eventID << G4endl;
1789 
1790  // Here comes the event drawing
1791  pVisManager->SetTransientsDrawnThisEvent(false);
1792  pSceneHandler->SetTransientsDrawnThisEvent(false);
1793 
1794  // We are about to draw the event (trajectories, etc.), but first we
1795  // have to clear the previous event(s) if necessary. If this event
1796  // needs to be drawn afresh, e.g., the first event or any event when
1797  // "accumulate" is not requested, the old event has to be cleared.
1798  // We have postponed this so that, for normal viewers like OGL, the
1799  // previous event(s) stay on screen until this new event comes
1800  // along. For a file-writing viewer the geometry has to be drawn.
1801  // See, for example, G4HepRepFileSceneHandler::ClearTransientStore.
1802  pVisManager->ClearTransientStoreIfMarked();
1803 
1804  // Now draw the event...
1805  pSceneHandler->DrawEvent(event);
1806  ++pVisManager->fNoOfEventsDrawnThisRun;
1807 
1808  if (pScene->GetRefreshAtEndOfEvent()) {
1809 
1810  // ShowView guarantees the view is flushed to the screen. It also
1811  // triggers other features such picking (if enabled) and allows
1812  // file-writing viewers to close the file.
1813  pViewer->ShowView();
1814  pSceneHandler->SetMarkForClearingTransientStore(true);
1815 
1816  }
1817 
1818  // Testing.
1819 // std::this_thread::sleep_for(std::chrono::seconds(5));
1820 
1821  // Then pop and release event
1822  G4MUTEXLOCK(&mtVisSubThreadMutex);
1823  mtVisEventQueue.pop_front();
1824  event->PostProcessingFinished();
1825  eventQueueSize = mtVisEventQueue.size();
1826  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1827 // G4cout << "Event queue size (B): " << eventQueueSize << G4endl;
1828  }
1829 
1830  G4MUTEXLOCK(&mtVisSubThreadMutex);
1831  G4int runInProgress = mtRunInProgress;
1832  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1833  if (!runInProgress) {
1834  // EndOfRun on master thread has signalled end of run. There is
1835  // nothing to draw so...
1836  break;
1837  }
1838 
1839  // Run still in progress but nothing to draw, so wait a while.
1840 #ifdef G4VIS_USE_STD11
1841  std::this_thread::sleep_for(std::chrono::milliseconds(100));
1842 #else
1843  G4THREADSLEEP(1);
1844 #endif
1845  }
1846 
1847  // Inform viewer that we have finished all sub-thread drawing
1848  pViewer->DoneWithVisSubThread();
1849  pViewer->MovingToMasterThread();
1850 // G4cout << "G4VisManager::G4VisSubThread: Vis sub-thread: ending" << G4endl;
1851  return /*(G4ThreadFunReturnType)*/0;
1852 }
1853 
1854 namespace {
1855  // G4Mutex visBeginOfRunMutex = G4MUTEX_INITIALIZER;
1856  // G4Mutex visBeginOfEventMutex = G4MUTEX_INITIALIZER;
1857  G4Mutex visEndOfEventMutex = G4MUTEX_INITIALIZER;
1858  // G4Mutex visEndOfRunMutex = G4MUTEX_INITIALIZER;
1859 }
1860 
1861 #endif
1862 
1864 {
1865  if (fIgnoreStateChanges) return;
1866 
1867 #ifdef G4MULTITHREADED
1868  if (G4Threading::IsWorkerThread()) return;
1869 #endif
1870 // G4cout << "G4VisManager::BeginOfRun: thread: "
1871 // << G4Threading::G4GetThreadId() << G4endl;
1872 
1873  G4RunManager* runManager = G4RunManager::GetRunManager();
1874 #ifdef G4MULTITHREADED
1876  runManager = G4MTRunManager::GetMasterRunManager();
1877  }
1878 #endif
1879 
1880  // For a fake run...
1881  G4int nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
1882  if (nEventsToBeProcessed == 0) return;
1883 
1884  fNKeepRequests = 0;
1885  fKeptLastEvent = false;
1886  fEventKeepingSuspended = false;
1887  fTransientsDrawnThisRun = false;
1890 
1891 #ifdef G4MULTITHREADED
1892 // There is a static method G4Threading::IsMultithreadedApplication()
1893 // that returns true only if G4MTRunManager is instantiated with MT
1894 // installation. Thus method returns false if G4RunManager base class is
1895 // instantiated even with the MT installation, or of course with sequential
1896 // installation.
1898 
1899  // Inform viewer that we have finished all master thread drawing for now...
1900  if (fpViewer) fpViewer->DoneWithMasterThread();
1901 
1902  // Start vis sub-thread
1903 // G4cout << "G4VisManager::BeginOfRun: Starting vis sub-thread" << G4endl;
1904  G4MUTEXLOCK(&mtVisSubThreadMutex);
1905  mtRunInProgress = true;
1906  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1907  mtVisSubThread = new G4Thread;
1908  // Launch vis thread
1909  G4THREADCREATE(mtVisSubThread,G4VisSubThread,this);
1910 
1911  // Tricky things for some viewers (e.g., Qt):
1912  // - Launch the vis thread
1913  // - Wait for the vis thread to set its QThread
1914  // - Then move current QOpenGL context (if Qt) to this Qthread
1915  // - Go ahead
1916  if (fpViewer) fpViewer->MovingToVisSubThread();
1917  }
1918 #endif
1919 }
1920 
1922 {
1923  if (fIgnoreStateChanges) return;
1924 
1925  if (!GetConcreteInstance()) return;
1926 
1927 // G4cout << "G4VisManager::BeginOfEvent: thread: "
1928 // << G4Threading::G4GetThreadId() << G4endl;
1929 
1930  // Some instructions that should NOT be in multithreaded version.
1931 #ifndef G4MULTITHREADED
1932  // These instructions are in G4VisSubThread for multithreading.
1933  fTransientsDrawnThisEvent = false;
1935 #endif
1936 }
1937 
1939 {
1940  if (fIgnoreStateChanges) return;
1941 
1942  if (!GetConcreteInstance()) return;
1943 
1944  // Don't call IsValidView unless there is a scene handler. This
1945  // avoids WARNING message at end of event and run when the user has
1946  // not instantiated a scene handler, e.g., in batch mode.
1947  G4bool valid = fpSceneHandler && IsValidView();
1948  if (!valid) return;
1949 
1950 // G4cout << "G4VisManager::EndOfEvent: thread: "
1951 // << G4Threading::G4GetThreadId() << G4endl;
1952 
1953 #ifdef G4MULTITHREADED
1954  G4AutoLock al(&visEndOfEventMutex);
1955  // Testing.
1956 // std::this_thread::sleep_for(std::chrono::seconds(5));
1957 #endif
1958 
1959  G4RunManager* runManager = G4RunManager::GetRunManager();
1960 #ifdef G4MULTITHREADED
1962  runManager = G4MTRunManager::GetMasterRunManager();
1963  }
1964 #endif
1965 
1966  const G4Run* currentRun = runManager->GetCurrentRun();
1967  if (!currentRun) return;
1968 
1969  // This gets the thread-local event manager
1971  const G4Event* currentEvent = eventManager->GetConstCurrentEvent();
1972  if (!currentEvent) return;
1973 
1974  // Discard event if fDrawEventOnlyIfToBeKept flag is set unless the
1975  // user has requested the event to be kept.
1977  if (!currentEvent->ToBeKept()) return;
1978  }
1979 
1981 
1982 #ifdef G4MULTITHREADED
1983 
1984  // Wait if too many events in the queue.
1985  G4MUTEXLOCK(&mtVisSubThreadMutex);
1986  G4int eventQueueSize = mtVisEventQueue.size();
1987  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1988 // G4cout << "Event queue size (1): " << eventQueueSize << G4endl;
1989 
1990  G4bool eventQueueFull = false;
1991  while (fMaxEventQueueSize > 0 && eventQueueSize >= fMaxEventQueueSize) {
1992 
1993 // G4cout << "Event queue size (2): " << eventQueueSize << G4endl;
1994  if (fWaitOnEventQueueFull) {
1995  static G4bool warned = false;
1996  if (!warned) {
1997  G4cout <<
1998  "WARNING: The number of events in the visualisation queue has exceeded"
1999  "\n the maximum, "
2000  << fMaxEventQueueSize <<
2001  ".\n If, during a multithreaded run, the simulation gets ahead of the"
2002  "\n visualisation by more than this maximum, the simulation is delayed"
2003  "\n until the vis sub-thread has drawn a few more events and removed them"
2004  "\n from the queue. You may change this maximum number of events with"
2005  "\n \"/vis/multithreading/maxEventQueueSize <N>\", where N is the maximum"
2006  "\n number you wish to allow. N <= 0 means \"unlimited\"."
2007  "\n Alternatively you may choose to discard events for drawing by setting"
2008  "\n \"/vis/multithreading/actionOnEventQueueFull discard\"."
2009  "\n To avoid visualisation altogether: \"/vis/disable\"."
2010  "\n And maybe \"/tracking/storeTrajectories 0\"."
2011  << G4endl;
2012  warned = true;
2013  }
2014  // G4cout << "Event queue size (3): " << eventQueueSize << G4endl;
2015  // Wait a while to give event drawing time to reduce the queue...
2016 #ifdef G4VIS_USE_STD11
2017  std::this_thread::sleep_for(std::chrono::milliseconds(100));
2018 #else
2019  G4THREADSLEEP(1);
2020 #endif
2021  // G4cout << "Event queue size (4): " << eventQueueSize << G4endl;
2022  } else {
2023  static G4bool warned = false;
2024  if (!warned) {
2025  G4cout <<
2026  "WARNING: The number of events in the visualisation queue has exceeded"
2027  "\n the maximum, "
2028  << fMaxEventQueueSize <<
2029  ".\n Some events have been discarded for drawing. You may change this"
2030  "\n behaviour with \"/vis/multithreading/actionOnEventQueueFull wait\"."
2031  "\n To avoid visualisation altogether: \"/vis/disable\"."
2032  "\n And maybe \"/tracking/storeTrajectories 0\"."
2033  << G4endl;
2034  warned = true;
2035  }
2036  eventQueueFull = true; // Causes event to be discarded for drawing.
2037  break;
2038  }
2039 
2040  G4MUTEXLOCK(&mtVisSubThreadMutex);
2041  eventQueueSize = mtVisEventQueue.size();
2042  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2043  }
2044 
2045  if (!eventQueueFull) {
2046  G4MUTEXLOCK(&mtVisSubThreadMutex);
2047  // Keep event for processing and put event on vis event queue
2048  currentEvent->KeepForPostProcessing();
2049  mtVisEventQueue.push_back(currentEvent);
2050  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2051  }
2052 
2053 // G4MUTEXLOCK(&mtVisSubThreadMutex);
2054 // G4int eQS = mtVisEventQueue.size();
2055 // G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2056 // G4cout << "Event queue size (5): " << eQS << G4endl;
2057 
2058 #endif
2059 
2060  } else {
2061 
2062  // Sequential mode
2063 
2064  G4int nEventsToBeProcessed = 0;
2065  G4int nKeptEvents = 0;
2066  G4int eventID = -2; // (If no run manager, triggers ShowView as normal.)
2067  if (currentRun) {
2068  nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
2069  eventID = currentEvent->GetEventID();
2070  const std::vector<const G4Event*>* events = currentRun->GetEventVector();
2071  if (events) nKeptEvents = events->size();
2072  }
2073 
2074  // We are about to draw the event (trajectories, etc.), but first we
2075  // have to clear the previous event(s) if necessary. If this event
2076  // needs to be drawn afresh, e.g., the first event or any event when
2077  // "accumulate" is not requested, the old event has to be cleared.
2078  // We have postponed this so that, for normal viewers like OGL, the
2079  // previous event(s) stay on screen until this new event comes
2080  // along. For a file-writing viewer the geometry has to be drawn.
2081  // See, for example, G4HepRepFileSceneHandler::ClearTransientStore.
2083 
2084  // Now draw the event...
2085  fpSceneHandler->DrawEvent(currentEvent);
2087 
2089 
2090  // Unless last event (in which case wait end of run)...
2091  if (eventID < nEventsToBeProcessed - 1) {
2092  // ShowView guarantees the view is flushed to the screen. It also
2093  // triggers other features such picking (if enabled) and allows
2094  // file-writing viewers to close the file.
2095  fpViewer->ShowView();
2096  } else { // Last event...
2097  // Keep, but only if user has not kept any...
2098  if (nKeptEvents == 0) {
2099  eventManager->KeepTheCurrentEvent();
2100  fNKeepRequests++;
2101  fKeptLastEvent = true;
2102  }
2103  }
2105 
2106  }
2107  }
2108 
2109  // Both modes - sequential and MT
2110 
2111  if (!(fpScene->GetRefreshAtEndOfEvent())) {
2112 
2113  // Accumulating events...
2114 
2115  G4int maxNumberOfKeptEvents = fpScene->GetMaxNumberOfKeptEvents();
2116 
2117  if (maxNumberOfKeptEvents > 0 &&
2118  fNKeepRequests >= maxNumberOfKeptEvents) {
2119 
2120  fEventKeepingSuspended = true;
2121  static G4bool warned = false;
2122  if (!warned) {
2123  if (fVerbosity >= warnings) {
2124  G4cout <<
2125  "WARNING: G4VisManager::EndOfEvent: Automatic event keeping suspended."
2126  "\n The number of events exceeds the maximum, "
2127  << maxNumberOfKeptEvents <<
2128  ", that may be kept by\n the vis manager."
2129  << G4endl;
2130  }
2131  warned = true;
2132  }
2133 
2134  } else if (maxNumberOfKeptEvents != 0) {
2135 
2136  // If not disabled nor suspended.
2138 // G4cout <<
2139 // "Requesting keeping event " << currentEvent->GetEventID()
2140 // << G4endl;
2141  eventManager->KeepTheCurrentEvent();
2142  fNKeepRequests++;
2143  }
2144 
2145  }
2146  }
2147 }
2148 
2150 {
2151  if (fIgnoreStateChanges) return;
2152 
2153 #ifdef G4MULTITHREADED
2154  if (G4Threading::IsWorkerThread()) return;
2155 #endif
2156 
2157 // G4cout << "G4VisManager::EndOfRun: thread: "
2158 // << G4Threading::G4GetThreadId() << G4endl;
2159 
2160  G4RunManager* runManager = G4RunManager::GetRunManager();
2161 #ifdef G4MULTITHREADED
2163  runManager = G4MTRunManager::GetMasterRunManager();
2164  }
2165 #endif
2166 
2167  // For a fake run...
2168  G4int nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
2169  if (nEventsToBeProcessed == 0) return;
2170 
2171  const G4Run* currentRun = runManager->GetCurrentRun();
2172  if (!currentRun) return;
2173 
2174 #ifdef G4MULTITHREADED
2175  // G4AutoLock al(&visEndOfRunMutex); ???
2177  // Reset flag so that sub-thread exits when it has finished processing.
2178  G4MUTEXLOCK(&mtVisSubThreadMutex);
2179  mtRunInProgress = false;
2180  G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2181  // Wait for sub-thread to finish.
2182  G4THREADJOIN(*mtVisSubThread);
2183  delete mtVisSubThread;
2184  if (fpViewer) fpViewer->SwitchToMasterThread();
2185  }
2186 #endif
2187 
2188 #ifdef G4MULTITHREADED
2189  // Print warning about discarded events, if any.
2190  // Don't call IsValidView unless there is a scene handler. This
2191  // avoids WARNING message from IsValidView() when the user has
2192  // not instantiated a scene handler, e.g., in batch mode.
2193  if (fpSceneHandler && IsValidView()) { // Events should have been drawn
2194  G4int noOfEventsRequested = runManager->GetNumberOfEventsToBeProcessed();
2195  if (fNoOfEventsDrawnThisRun != noOfEventsRequested) {
2196  if (!fWaitOnEventQueueFull && fVerbosity >= warnings) {
2197  G4cout
2198  << "WARNING: Number of events drawn this run, "
2199  << fNoOfEventsDrawnThisRun << ", is different to number requested, "
2200  << noOfEventsRequested <<
2201  ".\n (This is because you requested \"/vis/multithreading/actionOnEventQueueFull discard\".)"
2202  << G4endl;
2203  }
2204  }
2205  }
2206 #endif
2207 
2208  G4int nKeptEvents = 0;
2209  const std::vector<const G4Event*>* events = currentRun->GetEventVector();
2210  if (events) nKeptEvents = events->size();
2211  if (nKeptEvents && !fKeptLastEvent) {
2212  if (fVerbosity >= warnings) {
2213  G4cout << "WARNING: " << nKeptEvents;
2214  if (nKeptEvents == 1) G4cout << " event has";
2215  else G4cout << " events have";
2216  G4cout << " been kept for refreshing and/or reviewing." << G4endl;
2217  if (nKeptEvents != fNKeepRequests) {
2218  G4cout << " (Note: ";
2219  if (fNKeepRequests == 0) {
2220  G4cout << "No keep requests were";
2221  } else if (fNKeepRequests == 1) {
2222  G4cout << "Only 1 keep request was";
2223  } else {
2224  G4cout << "Only " << fNKeepRequests << " keep requests were";
2225  }
2226  G4cout << " made by the vis manager.)" << G4endl;
2227  }
2228  G4cout <<
2229  "\n \"/vis/reviewKeptEvents\" to review them one by one."
2230  "\n \"/vis/enable\", then \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
2231  << G4endl;
2232  }
2233  // static G4bool warned = false;
2234  // if (!valid && fVerbosity >= warnings && !warned) {
2235  // G4cout <<
2236  // " Only useful if before starting the run:"
2237  // "\n a) trajectories are stored (\"/vis/scene/add/trajectories [smooth|rich]\"), or"
2238  // "\n b) the Draw method of any hits or digis is implemented."
2239  // "\n To view trajectories, hits or digis:"
2240  // "\n open a viewer, draw a volume, \"/vis/scene/add/trajectories\""
2241  // "\n \"/vis/scene/add/hits\" or \"/vis/scene/add/digitisations\""
2242  // "\n and, possibly, \"/vis/viewer/flush\"."
2243  // "\n To see all events: \"/vis/scene/endOfEventAction accumulate\"."
2244  // "\n (You may need \"/vis/viewer/flush\" or even \"/vis/viewer/rebuild\".)"
2245  // "\n To see events individually: \"/vis/reviewKeptEvents\"."
2246  // << G4endl;
2247  // warned = true;
2248  // }
2249  }
2250 
2252  G4cout <<
2253  "WARNING: G4VisManager::EndOfRun: Automatic event keeping was suspended."
2254  "\n The number of events in the run exceeded the maximum, "
2256  ", that may be\n kept by the vis manager." <<
2257  "\n The number of events kept by the vis manager can be changed with"
2258  "\n \"/vis/scene/endOfEventAction accumulate <N>\", where N is the"
2259  "\n maximum number you wish to allow. N < 0 means \"unlimited\"."
2260  << G4endl;
2261  }
2262 
2263  // Don't call IsValidView unless there is a scene handler. This
2264  // avoids WARNING message at end of event and run when the user has
2265  // not instantiated a scene handler, e.g., in batch mode.
2266  G4bool valid = fpSceneHandler && IsValidView();
2267  if (GetConcreteInstance() && valid) {
2268 // // ???? I can't remember why
2269 // // if (!fpSceneHandler->GetMarkForClearingTransientStore()) {
2270 // // is here. It prevents ShowView at end of run, which seems to be OK
2271 // // for sequential mode, but MT mode seems to need it (I have not
2272 // // figured out why). ???? JA ????
2273 // if (!fpSceneHandler->GetMarkForClearingTransientStore()) {
2274  if (fpScene->GetRefreshAtEndOfRun()) {
2276  // An extra refresh for auto-refresh viewers.
2277  // ???? I DON'T WHY THIS IS NECESSARY ???? JA ????
2279  fpViewer->RefreshView();
2280  }
2281  // ShowView guarantees the view is flushed to the screen. It also
2282  // triggers other features such picking (if enabled) and allows
2283  // file-writing viewers to close the file.
2284  fpViewer->ShowView();
2286  } else {
2289  if (fVerbosity >= warnings) {
2290  G4cout << "\"/vis/viewer/update\" to close file." << G4endl;
2291  }
2292  }
2293  }
2294 // }
2295  }
2296  fEventRefreshing = false;
2297 }
2298 
2300  // Assumes valid view.
2304  }
2305  // Record if transients drawn. These local flags are only set
2306  // *after* ClearTransientStore. In the code in G4VSceneHandler
2307  // triggered by ClearTransientStore, use these flags so that
2308  // event refreshing is not done too early.
2311 }
2312 
2314 {
2315  fTransientsDrawnThisRun = false;
2316  fTransientsDrawnThisEvent = false;
2318  for (i = fAvailableSceneHandlers.begin();
2319  i != fAvailableSceneHandlers.end(); ++i) {
2320  (*i)->SetTransientsDrawnThisEvent(false);
2321  (*i)->SetTransientsDrawnThisRun(false);
2322  }
2323 }
2324 
2326  G4String viewerShortName (viewerName);
2327  viewerShortName = viewerShortName (0, viewerShortName.find (' '));
2328  return viewerShortName.strip ();
2329 }
2330 
2331 G4VViewer* G4VisManager::GetViewer (const G4String& viewerName) const {
2332  G4String viewerShortName = ViewerShortName (viewerName);
2333  size_t nHandlers = fAvailableSceneHandlers.size ();
2334  size_t iHandler, iViewer;
2335  G4VViewer* viewer = 0;
2336  G4bool found = false;
2337  for (iHandler = 0; iHandler < nHandlers; iHandler++) {
2338  G4VSceneHandler* sceneHandler = fAvailableSceneHandlers [iHandler];
2339  const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
2340  for (iViewer = 0; iViewer < viewerList.size (); iViewer++) {
2341  viewer = viewerList [iViewer];
2342  if (viewerShortName == viewer -> GetShortName ()) {
2343  found = true;
2344  break;
2345  }
2346  }
2347  if (found) break;
2348  }
2349  if (found) return viewer;
2350  else return 0;
2351 }
2352 
2353 std::vector<G4String> G4VisManager::VerbosityGuidanceStrings;
2354 
2356  G4String rs;
2357  switch (verbosity) {
2358  case quiet: rs = "quiet (0)"; break;
2359  case startup: rs = "startup (1)"; break;
2360  case errors: rs = "errors (2)"; break;
2361  case warnings: rs = "warnings (3)"; break;
2362  case confirmations: rs = "confirmations (4)"; break;
2363  case parameters: rs = "parameters (5)"; break;
2364  case all: rs = "all (6)"; break;
2365  }
2366  return rs;
2367 }
2368 
2371  G4String ss(verbosityString); ss.toLower();
2372  Verbosity verbosity;
2373  if (ss(0) == 'q') verbosity = quiet;
2374  else if (ss(0) == 's') verbosity = startup;
2375  else if (ss(0) == 'e') verbosity = errors;
2376  else if (ss(0) == 'w') verbosity = warnings;
2377  else if (ss(0) == 'c') verbosity = confirmations;
2378  else if (ss(0) == 'p') verbosity = parameters;
2379  else if (ss(0) == 'a') verbosity = all;
2380  else {
2381  G4int intVerbosity;
2382  std::istringstream is(ss);
2383  is >> intVerbosity;
2384  if (!is) {
2385  G4cerr << "ERROR: G4VisManager::GetVerbosityValue: invalid verbosity \""
2386  << verbosityString << "\"";
2387  for (size_t i = 0; i < VerbosityGuidanceStrings.size(); ++i) {
2388  G4cerr << '\n' << VerbosityGuidanceStrings[i];
2389  }
2390  verbosity = warnings;
2391  G4cerr << "\n Returning " << VerbosityString(verbosity)
2392  << G4endl;
2393  }
2394  else {
2395  verbosity = GetVerbosityValue(intVerbosity);
2396  }
2397  }
2398  return verbosity;
2399 }
2400 
2402  Verbosity verbosity;
2403  if (intVerbosity < quiet) verbosity = quiet;
2404  else if (intVerbosity > all) verbosity = all;
2405  else verbosity = Verbosity(intVerbosity);
2406  return verbosity;
2407 }
2408 
2410  return fVerbosity;
2411 }
2412 
2414  fVerbosity = GetVerbosityValue(intVerbosity);
2415 }
2416 
2417 void G4VisManager::SetVerboseLevel (const G4String& verbosityString) {
2418  fVerbosity = GetVerbosityValue(verbosityString);
2419 }
2420 
2422 
2423  if (!fInitialised) Initialise ();
2424 
2425  static G4bool noGSPrinting = true;
2426  if (!fpGraphicsSystem) {
2427  // Limit printing - we do not want printing if the user simply does
2428  // not want to use graphics, e.g., in batch mode.
2429  if (noGSPrinting) {
2430  noGSPrinting = false;
2431  if (fVerbosity >= warnings) {
2432  G4cout <<
2433  "WARNING: G4VisManager::IsValidView(): Attempt to draw when no graphics system"
2434  "\n has been instantiated. Use \"/vis/open\" or \"/vis/sceneHandler/create\"."
2435  "\n Alternatively, to avoid this message, suppress instantiation of vis"
2436  "\n manager (G4VisExecutive) and ensure drawing code is executed only if"
2437  "\n G4VVisManager::GetConcreteInstance() is non-zero."
2438  << G4endl;
2439  }
2440  }
2441  return false;
2442  }
2443 
2444  if ((!fpScene) || (!fpSceneHandler) || (!fpViewer)) {
2445  if (fVerbosity >= errors) {
2446  G4cerr <<
2447  "ERROR: G4VisManager::IsValidView(): Current view is not valid."
2448  << G4endl;
2450  }
2451  return false;
2452  }
2453 
2454  if (fpScene != fpSceneHandler -> GetScene ()) {
2455  if (fVerbosity >= errors) {
2456  G4cerr << "ERROR: G4VisManager::IsValidView ():";
2457  if (fpSceneHandler -> GetScene ()) {
2458  G4cout <<
2459  "\n The current scene \""
2460  << fpScene -> GetName ()
2461  << "\" is not handled by"
2462  "\n the current scene handler \""
2463  << fpSceneHandler -> GetName ()
2464  << "\""
2465  "\n (it currently handles scene \""
2466  << fpSceneHandler -> GetScene () -> GetName ()
2467  << "\")."
2468  "\n Either:"
2469  "\n (a) attach it to the scene handler with"
2470  "\n /vis/sceneHandler/attach "
2471  << fpScene -> GetName ()
2472  << ", or"
2473  "\n (b) create a new scene handler with "
2474  "\n /vis/sceneHandler/create <graphics-system>,"
2475  "\n in which case it should pick up the the new scene."
2476  << G4endl;
2477  }
2478  else {
2479  G4cout << "\n Scene handler \""
2480  << fpSceneHandler -> GetName ()
2481  << "\" has null scene pointer."
2482  "\n Attach a scene with /vis/sceneHandler/attach [<scene-name>]"
2483  << G4endl;
2484  }
2485  }
2486  return false;
2487  }
2488 
2489  const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList ();
2490  if (viewerList.size () == 0) {
2491  if (fVerbosity >= errors) {
2492  G4cerr <<
2493  "ERROR: G4VisManager::IsValidView (): the current scene handler\n \""
2494  << fpSceneHandler -> GetName ()
2495  << "\" has no viewers. Do /vis/viewer/create."
2496  << G4endl;
2497  }
2498  return false;
2499  }
2500 
2501  G4bool isValid = true;
2502  if (fpScene -> IsEmpty ()) { // Add world by default if possible...
2503  G4bool warn(fVerbosity >= warnings);
2504  G4bool successful = fpScene -> AddWorldIfEmpty (warn);
2505  if (!successful || fpScene -> IsEmpty ()) { // If still empty...
2506  if (fVerbosity >= errors) {
2507  G4cerr << "ERROR: G4VisManager::IsValidView ():";
2508  G4cerr <<
2509  "\n Attempt at some drawing operation when scene is empty."
2510  "\n Maybe the geometry has not yet been defined."
2511  " Try /run/initialize."
2512  "\n Or use \"/vis/scene/add/extent\"."
2513  << G4endl;
2514  }
2515  isValid = false;
2516  }
2517  else {
2518  G4UImanager::GetUIpointer()->ApplyCommand ("/vis/scene/notifyHandlers");
2519  if (fVerbosity >= warnings) {
2520  G4cout <<
2521  "WARNING: G4VisManager: the scene was empty, \"world\" has been"
2522  "\n added and the scene handlers notified.";
2523  G4cout << G4endl;
2524  }
2525  }
2526  }
2527  return isValid;
2528 }
2529 
2530 void
2532 {
2533  if (fVerbosity >= warnings) {
2534  G4cout<<"G4VisManager: No model factories registered with G4VisManager."<<G4endl;
2535  G4cout<<"G4VisManager::RegisterModelFactories() should be overridden in derived"<<G4endl;
2536  G4cout<<"class. See G4VisExecutive for an example."<<G4endl;
2537  }
2538 }
2539 
2540 #ifdef G4MULTITHREADED
2541 void G4VisManager::SetUpForAThread()
2542 {
2543  new G4VisStateDependent(this);
2544 }
2545 #endif
2546 
2548 {
2549  fIgnoreStateChanges = val;
2550 }
void RegisterModelFactory(G4TrajDrawModelFactory *factory)
const std::map< G4String, T * > & Map() const
G4bool GetMarkForClearingTransientStore() const
void SetTransientsDrawnThisEvent(G4bool)
static G4MTRunManager * GetMasterRunManager()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
const G4Run * GetCurrentRun() const
G4VViewer * fpViewer
void SetTransientsDrawnThisEvent(G4bool)
std::vector< G4UImessenger * > fMessengerList
const XML_Char * name
Definition: expat.h:151
void Register(Model *)
const G4VTrajectoryModel * CurrentTrajDrawModel() const
G4bool fTransientsDrawnThisEvent
void Draw2D(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
static void SetConcreteInstance(G4VVisManager *)
G4LogicalVolume * GetLogicalVolume() const
G4int GetEventID() const
Definition: G4Event.hh:151
void ResetTransientsDrawnFlags()
friend class G4VisStateDependent
#define TOOLS_COLORS_STAT(name, r, g, b)
const std::vector< Factory * > & FactoryList() const
static Verbosity GetVerbosityValue(const G4String &)
void SetCurrentTrajectory(const G4VTrajectory *pTraj)
G4VSceneHandler * fpSceneHandler
G4int GetStoreTrajectory() const
void EndDraw2D()
const std::vector< Filter * > & FilterList() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
void PrintAvailableColours(Verbosity) const
G4int fDrawGroupNestingDepth
#define G4endl
Definition: G4ios.hh:61
const char * p
Definition: xmltok.h:285
Definition: G4VHit.hh:48
static G4SolidsWorkspacePool * GetInstance()
G4VisModelManager< G4VTrajectoryModel > * fpTrajDrawModelMgr
const List * ListManager() const
const std::vector< Factory * > & FactoryList() const
G4bool fInitialised
void SetRunID(G4int runID)
void BeginOfEvent()
G4bool fTransientsDrawnThisRun
static G4VisManager * GetInstance()
virtual void ClearTransientStore()
void CreateViewer(const G4String &name="", const G4String &XGeometry="")
virtual void DescribeYourselfTo(G4VGraphicsScene &scene) const =0
void RegisterEndOfRunUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
G4Navigator * GetNavigatorForTracking() const
G4Scene * fpScene
const G4ViewParameters & GetViewParameters() const
const Model * Current() const
G4bool fEventKeepingSuspended
void PrintAvailableUserVisActions(Verbosity) const
G4bool fKeptLastEvent
G4bool IsValidView()
static std::vector< G4String > VerbosityGuidanceStrings
G4int GetNumberOfEventsToBeProcessed() const
G4VisFilterManager< G4VDigi > * fpDigiFilterMgr
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
G4GraphicsSystemList fAvailableGraphicsSystems
void SetVerboseLevel(G4int)
void PrintAvailableModels(Verbosity) const
G4bool IsCulling() const
G4TrackingManager * GetTrackingManager() const
static G4VVisManager * GetConcreteInstance()
static Verbosity fVerbosity
std::vector< UserVisAction > fEndOfRunUserVisActions
#define G4THREADSLEEP(tick)
Definition: G4Threading.hh:52
virtual void ShowView()
Definition: G4VViewer.cc:103
void DispatchToModel(const G4VTrajectory &)
void PrintAvailableGraphicsSystems(Verbosity) const
void toLower()
static G4RunManagerKernel * GetRunManagerKernel()
G4bool FilterHit(const G4VHit &)
void Initialise()
bool G4bool
Definition: G4Types.hh:79
Double_t scale
G4DummyThread G4Thread
Definition: G4Threading.hh:229
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:88
G4bool fIgnoreStateChanges
G4VisFilterManager< G4VHit > * fpHitFilterMgr
G4bool GetRefreshAtEndOfEvent() const
virtual void RegisterGraphicsSystems()=0
Definition: G4Text.hh:73
static void InitialiseColourMap()
Definition: G4Colour.cc:143
G4VGraphicsSystem * fpGraphicsSystem
G4bool IsWorkerThread()
Definition: G4Threading.cc:129
const G4String & GetName() const
G4bool RegisterGraphicsSystem(G4VGraphicsSystem *)
void SetCurrentViewer(G4VViewer *)
void InitialiseG4ColourMap() const
G4VisManager(const G4String &verbosityString="warnings")
Definition: G4VisManager.cc:99
G4bool ToBeKept() const
Definition: G4Event.hh:137
G4int GetMaxNumberOfKeptEvents() const
G4VViewer * GetCurrentViewer() const
void KeepForPostProcessing() const
Definition: G4Event.hh:139
G4int fNKeepRequests
G4int GetRunID() const
Definition: G4Run.hh:76
void RegisterModel(G4VTrajectoryModel *model)
void DrawEvent(const G4Event *)
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4VisFilterManager< G4VTrajectory > * fpTrajFilterMgr
static G4EventManager * GetEventManager()
G4String strip(G4int strip_Type=trailing, char c=' ')
void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
void KeepTheCurrentEvent()
G4int fNoOfEventsDrawnThisRun
void SetTransientsDrawnThisRun(G4bool)
static Verbosity GetVerbosity()
static G4VisManager * fpInstance
G4bool IsCullingInvisible() const
G4bool GetTransientsDrawnThisEvent() const
std::vector< G4VSceneHandler * >::const_iterator G4SceneHandlerListConstIterator
void RegisterMessenger(G4UImessenger *messenger)
void SetUpForSpecialThread(G4String aPrefix)
Definition: G4UImanager.cc:770
G4GLOB_DLL std::ostream G4cerr
void RegisterMessengers()
static void SetVisManager(G4VisManager *)
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:234
Definition: G4Run.hh:46
G4bool IsAutoRefresh() const
const G4Event * GetConstCurrentEvent()
G4bool fIsDrawGroup
void SetCurrentGraphicsSystem(G4VGraphicsSystem *)
static G4TransportationManager * GetTransportationManager()
void ClearTransientStoreIfMarked()
void SetCurrentSceneHandler(G4VSceneHandler *)
static G4GeometryWorkspacePool * GetInstance()
G4bool GetRefreshAtEndOfRun() const
void RefreshView()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
void * G4ThreadFunReturnType
Definition: G4Threading.hh:102
std::vector< G4UIcommand * > fDirectoryList
void PrintInvalidPointers() const
std::vector< UserVisAction > fEndOfEventUserVisActions
void BeginDraw(const G4Transform3D &objectTransformation=G4Transform3D())
FilterMode::Mode GetMode() const
G4bool IsMultithreadedApplication()
Definition: G4Threading.cc:136
int G4int
Definition: G4Types.hh:78
G4bool fDrawEventOnlyIfToBeKept
const T * Current() const
void SetCurrentScene(G4Scene *)
void SelectTrajectoryModel(const G4String &model)
const G4GraphicsSystemList & GetAvailableGraphicsSystems()
Functionality GetFunctionality() const
void * G4ThreadFunArgType
Definition: G4Threading.hh:103
#define G4THREADJOIN(worker)
Definition: G4Threading.hh:237
G4bool FilterDigi(const G4VDigi &)
G4String Placement() const
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:71
static const std::map< G4String, G4Colour > & GetMap()
Definition: G4Colour.cc:181
virtual ~G4VisManager()
void SetUserAction(G4VUserVisAction *pVisAction, const G4VisExtent &=G4VisExtent())
G4String Placement() const
const std::vector< const G4Event * > * GetEventVector() const
Definition: G4Run.hh:115
void GeometryHasChanged()
bool Accept(const T &)
G4bool fEventRefreshing
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:233
static G4RunManagerKernel * GetMasterRunManagerKernel()
G4bool FilterTrajectory(const G4VTrajectory &)
G4GLOB_DLL std::ostream G4cout
void SetXGeometryString(const G4String &)
void RegisterRunDurationUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
void G4THREADCREATE(_Worker *&worker, _Func func, _Args...args)
Definition: G4Threading.hh:244
void DrawT2D(const T &graphics_primitive, const G4Transform3D &objectTransform)
virtual void Draw(const G4VTrajectory &trajectory, const G4bool &visible=true) const =0
G4VSolid * GetSolid() const
G4VisStateDependent * fpStateDependent
virtual void SetView()=0
G4bool IsCullingCovered() const
void SetEventID(G4int eventID)
void SetCurrent(const G4String &)
void BeginDraw2D(const G4Transform3D &objectTransformation=G4Transform3D())
void NotifyHandlers()
G4SceneList fSceneList
void CalculateExtent()
Definition: G4Scene.cc:98
G4VSceneHandler * GetCurrentSceneHandler() const
std::vector< UserVisAction > fRunDurationUserVisActions
G4VViewer * GetViewer(const G4String &viewerName) const
const XML_Char XML_Content * model
Definition: expat.h:151
static G4String VerbosityString(Verbosity)
virtual void RegisterModelFactories()
G4String ViewerShortName(const G4String &viewerName) const
G4SceneHandlerList fAvailableSceneHandlers
void CreateSceneHandler(const G4String &name="")
G4bool GetTransientsDrawnThisRun() const
G4Scene * GetScene() const
void RegisterEndOfEventUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
void IgnoreStateChanges(G4bool)
std::mutex G4Mutex
Definition: G4Threading.hh:84
void SetMarkForClearingTransientStore(G4bool)
void DrawT(const T &graphics_primitive, const G4Transform3D &objectTransform)