Geant4-11
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4VisManager.cc
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//
28// GEANT4 Visualization Manager - John Allison 02/Jan/1996.
29// Michael Kelsey 31 Jan 2019 -- Add new command for electric field
30
31#include "G4VisManager.hh"
32
33#include "G4VisCommands.hh"
38#include "G4VisCommandsSet.hh"
39#include "G4VisCommandsScene.hh"
48#include "G4UImanager.hh"
50#include "G4UIdirectory.hh"
51#include "G4VGraphicsSystem.hh"
52#include "G4VSceneHandler.hh"
53#include "G4VViewer.hh"
54#include "G4VPhysicalVolume.hh"
55#include "G4LogicalVolume.hh"
56#include "G4VSolid.hh"
57#include "G4Vector3D.hh"
58#include "G4Point3D.hh"
59#include "G4RotationMatrix.hh"
60#include "G4Polyline.hh"
61#include "G4Polyhedron.hh"
62#include "G4NullModel.hh"
67#include "G4VisModelManager.hh"
68#include "G4VModelFactory.hh"
69#include "G4VisFilterManager.hh"
70#include "G4VTrajectoryModel.hh"
72#include "Randomize.hh"
73#include "G4RunManager.hh"
75#include "G4EventManager.hh"
76#include "G4Run.hh"
77#include "G4Event.hh"
78#include <map>
79#include <set>
80#include <vector>
81#include <sstream>
82
83#ifdef G4MULTITHREADED
84# include "G4Threading.hh"
85# include "G4AutoLock.hh"
86# include "G4GeometryWorkspace.hh"
87# include "G4SolidsWorkspace.hh"
88# include <deque>
89# include <typeinfo>
90# include <chrono>
91# include <thread>
92#endif
93
95
97
98G4VisManager::G4VisManager (const G4String& verbosityString):
99 fVerbose (1),
100 fInitialised (false),
101 fpGraphicsSystem (0),
102 fpScene (0),
103 fpSceneHandler (0),
104 fpViewer (0),
105 fpStateDependent (0),
106 fEventRefreshing (false),
107 fTransientsDrawnThisRun (false),
108 fTransientsDrawnThisEvent (false),
109 fNoOfEventsDrawnThisRun (0),
110 fNKeepRequests (0),
111 fEventKeepingSuspended (false),
112 fDrawEventOnlyIfToBeKept (false),
113 fpRequestedEvent (0),
114 fReviewingKeptEvents (false),
115 fAbortReviewKeptEvents (false),
116 fIsDrawGroup (false),
117 fDrawGroupNestingDepth (0),
118 fIgnoreStateChanges (false)
119#ifdef G4MULTITHREADED
120, fMaxEventQueueSize (100)
121, fWaitOnEventQueueFull (true)
122#endif
123 // All other objects use default constructors.
124{
125 fpTrajDrawModelMgr = new G4VisModelManager<G4VTrajectoryModel>("/vis/modeling/trajectories");
126 fpTrajFilterMgr = new G4VisFilterManager<G4VTrajectory>("/vis/filtering/trajectories");
127 fpHitFilterMgr = new G4VisFilterManager<G4VHit>("/vis/filtering/hits");
128 fpDigiFilterMgr = new G4VisFilterManager<G4VDigi>("/vis/filtering/digi");
129
131 ("Simple graded message scheme - digit or string (1st character defines):");
133 (" 0) quiet, // Nothing is printed.");
135 (" 1) startup, // Startup and endup messages are printed...");
137 (" 2) errors, // ...and errors...");
139 (" 3) warnings, // ...and warnings...");
141 (" 4) confirmations, // ...and confirming messages...");
143 (" 5) parameters, // ...and parameters of scenes and views...");
145 (" 6) all // ...and everything available.");
146
147 if (fpInstance) {
149 ("G4VisManager::G4VisManager",
150 "visman0001", FatalException,
151 "Attempt to Construct more than one VisManager");
152 }
153
154 fpInstance = this;
156
158 // No need to delete this; G4StateManager does this.
159
160 fVerbosity = GetVerbosityValue(verbosityString);
161 if (fVerbosity >= startup) {
162 G4cout
163 << "Visualization Manager instantiating with verbosity \""
165 << "\"..." << G4endl;
166 }
167
168 // Note: The specific graphics systems must be instantiated in a
169 // higher level library to avoid circular dependencies. Also,
170 // some specifically need additional external libararies that the
171 // user must supply. Therefore we ask the user to implement
172 // RegisterGraphicsSystems() and RegisterModelFactories()
173 // in a subclass. We have to wait for the subclass to instantiate
174 // so RegisterGraphicsSystems() cannot be called from this
175 // constructor; it is called from Initialise(). So we ask the
176 // user:
177 // (a) to write a subclass and implement RegisterGraphicsSystems()
178 // and RegisterModelFactories(). See
179 // visualization/include/G4VisExecutive.hh/icc as an example.
180 // (b) instantiate the subclass.
181 // (c) invoke the Initialise() method of the subclass.
182 // For example:
183 // ...
184 // // Instantiate and initialise Visualization Manager.
185 // G4VisManager* visManager = new G4VisExecutive;
186 // visManager -> SetVerboseLevel (Verbose);
187 // visManager -> Initialise ();
188 // // (Don't forget to delete visManager;)
189 // ...
190
191 // Make top level command directory...
192 // Vis commands should *not* be broadcast to threads (2nd argument).
193 auto directory = new G4UIdirectory ("/vis/",false);
194 directory -> SetGuidance ("Visualization commands.");
195 // Request commands in name order
196 directory -> Sort(); // Ordering propagates to sub-directories
197 fDirectoryList.push_back (directory);
198
199 // Instantiate *basic* top level commands so that they can be used
200 // immediately after instantiation of the vis manager. Other top
201 // level and lower level commands are instantiated later in
202 // RegisterMessengers.
203 G4VVisCommand::SetVisManager (this); // Sets shared pointer
206}
207
209{
211 UImanager->SetCoutDestination(nullptr);
212 size_t i;
213 for (i = 0; i < fSceneList.size (); ++i) {
214 delete fSceneList[i];
215 }
216 for (i = 0; i < fAvailableSceneHandlers.size (); ++i) {
217 if (fAvailableSceneHandlers[i] != NULL) {
218 delete fAvailableSceneHandlers[i];
219 }
220 }
221 for (i = 0; i < fAvailableGraphicsSystems.size (); ++i) {
224 }
225 }
226 if (fVerbosity >= startup) {
227 G4cout << "Graphics systems deleted." << G4endl;
228 G4cout << "Visualization Manager deleting..." << G4endl;
229 }
230 for (i = 0; i < fMessengerList.size (); ++i) {
231 delete fMessengerList[i];
232 }
233 for (i = 0; i < fDirectoryList.size (); ++i) {
234 delete fDirectoryList[i];
235 }
236
237 delete fpDigiFilterMgr;
238 delete fpHitFilterMgr;
239 delete fpTrajFilterMgr;
240 delete fpTrajDrawModelMgr;
241 fpInstance = 0;
242}
243
245 if (!fpInstance) {
247 ("G4VisManager::GetInstance",
248 "visman0002", FatalException, "VisManager not yet instantiated");
249 }
250 return fpInstance;
251}
252
254
255 if (fInitialised && fVerbosity >= warnings) {
256 G4cout << "WARNING: G4VisManager::Initialise: already initialised."
257 << G4endl;
258 return;
259 }
260
261 if (fVerbosity >= startup) {
262 G4cout << "Visualization Manager initialising..." << G4endl;
263 }
264
265 if (fVerbosity >= parameters) {
266 G4cout <<
267 "\nYou have instantiated your own Visualization Manager, inheriting"
268 "\n G4VisManager and implementing RegisterGraphicsSystems(), in which"
269 "\n you should, normally, instantiate drivers which do not need"
270 "\n external packages or libraries, and, optionally, drivers under"
271 "\n control of environment variables."
272 "\n Also you should implement RegisterModelFactories()."
273 "\n See visualization/management/include/G4VisExecutive.hh/icc, for example."
274 "\n In your main() you will have something like:"
275 "\n G4VisManager* visManager = new G4VisExecutive;"
276 "\n visManager -> SetVerboseLevel (Verbose);"
277 "\n visManager -> Initialize ();"
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) \
376G4Colour::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 directory = new G4UIdirectory ("/vis/geometry/");
468 directory -> SetGuidance("Operations on vis attributes of Geant4 geometry.");
469 fDirectoryList.push_back (directory);
472
473 directory = new G4UIdirectory ("/vis/geometry/set/");
474 directory -> SetGuidance("Set vis attributes of Geant4 geometry.");
475 fDirectoryList.push_back (directory);
486
487#ifdef G4MULTITHREADED
488 directory = new G4UIdirectory ("/vis/multithreading/");
489 directory -> SetGuidance("Commands unique to multithreading mode.");
490 fDirectoryList.push_back (directory);
491 RegisterMessenger(new G4VisCommandMultithreadingActionOnEventQueueFull);
492 RegisterMessenger(new G4VisCommandMultithreadingMaxEventQueueSize);
493#endif
494
495 directory = new G4UIdirectory ("/vis/set/");
496 directory -> SetGuidance
497 ("Set quantities for use in future commands where appropriate.");
498 fDirectoryList.push_back (directory);
508
509 directory = new G4UIdirectory ("/vis/scene/");
510 directory -> SetGuidance ("Operations on Geant4 scenes.");
511 fDirectoryList.push_back (directory);
521
522 directory = new G4UIdirectory ("/vis/scene/add/");
523 directory -> SetGuidance ("Add model to current scene.");
524 fDirectoryList.push_back (directory);
551
552 RegisterMessenger(new G4VisCommandPlotterCreate);
553 RegisterMessenger(new G4VisCommandPlotterSetLayout);
554 RegisterMessenger(new G4VisCommandPlotterAddStyle);
555 RegisterMessenger(new G4VisCommandPlotterAddRegionStyle);
556 RegisterMessenger(new G4VisCommandPlotterAddRegionParameter);
557 RegisterMessenger(new G4VisCommandPlotterClear);
558 RegisterMessenger(new G4VisCommandPlotterClearRegion);
559 RegisterMessenger(new G4VisCommandPlotterList);
560 RegisterMessenger(new G4VisCommandPlotterAddRegionH1);
561 RegisterMessenger(new G4VisCommandPlotterAddRegionH2);
562
563 directory = new G4UIdirectory ("/vis/sceneHandler/");
564 directory -> SetGuidance ("Operations on Geant4 scene handlers.");
565 fDirectoryList.push_back (directory);
570
571 directory = new G4UIdirectory ("/vis/touchable/");
572 directory -> SetGuidance ("Operations on touchables.");
573 fDirectoryList.push_back (directory);
575
576 directory = new G4UIdirectory ("/vis/touchable/set/");
577 directory -> SetGuidance ("Set vis attributes of current touchable.");
578 fDirectoryList.push_back (directory);
580
581 directory = new G4UIdirectory ("/vis/viewer/");
582 directory -> SetGuidance ("Operations on Geant4 viewers.");
583 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 // *Basic* top level commands were instantiated in the constructor
621 // so that they can be used immediately after instantiation of the
622 // vis manager. Other top level commands, including "compound commands"
623 // (i.e., commands that invoke other commands) are instantiated here.
624
636
637 // List manager commands
642
643 // Trajectory filter manager commands
648
649 // Hit filter manager commands
654
655 // Digi filter manager commands
660}
661
663 if (IsValidView ()) {
665 if (fVerbosity >= confirmations) {
666 G4cout << "G4VisManager::Enable: visualization enabled." << G4endl;
667 }
668 if (fVerbosity >= warnings) {
669 G4int nKeptEvents = 0;
671 if (run) nKeptEvents = run->GetEventVector()->size();
672 G4cout <<
673 "There are " << nKeptEvents << " kept events."
674 "\n \"/vis/reviewKeptEvents\" to review them one by one."
675 "\n \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
676 << G4endl;
677 }
678 }
679 else {
680 if (fVerbosity >= warnings) {
681 G4cout <<
682 "G4VisManager::Enable: WARNING: visualization remains disabled for"
683 "\n above reasons. Rectifying with valid vis commands will"
684 "\n automatically enable."
685 << G4endl;
686 }
687 }
688}
689
692 if (fVerbosity >= confirmations) {
693 G4cout <<
694 "G4VisManager::Disable: visualization disabled."
695 "\n The pointer returned by GetConcreteInstance will be zero."
696 "\n Note that it will become enabled after some valid vis commands."
697 << G4endl;
698 }
699 if (fVerbosity >= warnings) {
700 G4int currentTrajectoryType =
702 if (currentTrajectoryType > 0) {
703 G4cout <<
704 "You may wish to disable trajectory production too:"
705 "\n \"/tracking/storeTrajectory 0\""
706 "\nbut don't forget to re-enable with"
707 "\n \"/vis/enable\""
708 "\n \"/tracking/storeTrajectory " << currentTrajectoryType
709 << "\"\n and maybe \"/vis/viewer/rebuild\""
710 << G4endl;
711 }
712 }
713}
714
716 G4int nSystems = fAvailableGraphicsSystems.size ();
717 if (nSystems == 0) {
718 if (fVerbosity >= warnings) {
719 G4cout << "G4VisManager::GetAvailableGraphicsSystems: WARNING: no"
720 "\n graphics system available!"
721 "\n 1) Did you have environment variables G4VIS_BUILD_xxxx_DRIVER set"
722 "\n when you compiled/built the visualization code?"
723 "\n 2) Did you instantiate your own Visualization Manager and forget"
724 "\n to implement RegisterGraphicsSystems correctly?"
725 "\n 3) You can register your own graphics system, e.g.,"
726 "\n visManager->RegisterGraphicsSystem(new MyGraphicsSystem);)"
727 "\n after instantiating your vis manager and before"
728 "\n visManager->Initialize()."
729 << G4endl;
730 }
731 }
733}
734
736 G4bool happy = true;
737 if (pSystem) {
738 fAvailableGraphicsSystems.push_back (pSystem);
739 if (fVerbosity >= confirmations) {
740 G4cout << "G4VisManager::RegisterGraphicsSystem: "
741 << pSystem -> GetName ();
742 if (pSystem -> GetNickname () != "") {
743 G4cout << " (" << pSystem -> GetNickname () << ")";
744 }
745 G4cout << " registered." << G4endl;
746 }
747 }
748 else {
749 if (fVerbosity >= errors) {
750 G4cout << "G4VisManager::RegisterGraphicsSystem: null pointer!"
751 << G4endl;
752 }
753 happy=false;
754 }
755 return happy;
756}
757
760{
761 assert (0 != fpTrajDrawModelMgr);
762
764
765 if (0 == model) {
766 // No model was registered with the trajectory model manager.
767 // Use G4TrajectoryDrawByCharge as a fallback.
769 if (fVerbosity >= warnings) {
770 G4cout<<"G4VisManager: Using G4TrajectoryDrawByCharge as fallback trajectory model."<<G4endl;
771 G4cout<<"See commands in /vis/modeling/trajectories/ for other options."<<G4endl;
772 }
773 }
774
775 model = fpTrajDrawModelMgr->Current();
776 assert (0 != model); // Should definitely exist now
777
778 return model;
779}
780
782{
784}
785
786void
788{
790}
791
793{
795}
796
797void
799{
801}
802
804{
805 fpHitFilterMgr->Register(model);
806}
807
808void
810{
812}
813
815{
817}
818
819void
821{
823}
824
826{
828}
829
830void G4VisManager::BeginDraw (const G4Transform3D& objectTransform)
831{
832#ifdef G4MULTITHREADED
833 if (G4Threading::IsWorkerThread()) return;
834#endif
836 if (fDrawGroupNestingDepth > 1) {
838 ("G4VisManager::BeginDraw",
839 "visman0008", JustWarning,
840 "Nesting detected. It is illegal to nest Begin/EndDraw."
841 "\n Ignored");
842 return;
843 }
844 if (IsValidView ()) {
846 fpSceneHandler -> BeginPrimitives (objectTransform);
847 fIsDrawGroup = true;
848 }
849}
850
852{
853#ifdef G4MULTITHREADED
854 if (G4Threading::IsWorkerThread()) return;
855#endif
857 if (fDrawGroupNestingDepth != 0) {
859 return;
860 }
861 if (IsValidView ()) {
862 fpSceneHandler -> EndPrimitives ();
863 }
864 fIsDrawGroup = false;
865}
866
867void G4VisManager::BeginDraw2D (const G4Transform3D& objectTransform)
868{
869#ifdef G4MULTITHREADED
870 if (G4Threading::IsWorkerThread()) return;
871#endif
873 if (fDrawGroupNestingDepth > 1) {
875 ("G4VisManager::BeginDraw2D",
876 "visman0009", JustWarning,
877 "Nesting detected. It is illegal to nest Begin/EndDraw2D."
878 "\n Ignored");
879 return;
880 }
881 if (IsValidView ()) {
883 fpSceneHandler -> BeginPrimitives2D (objectTransform);
884 fIsDrawGroup = true;
885 }
886}
887
889{
890#ifdef G4MULTITHREADED
891 if (G4Threading::IsWorkerThread()) return;
892#endif
894 if (fDrawGroupNestingDepth != 0) {
896 return;
897 }
898 if (IsValidView ()) {
899 fpSceneHandler -> EndPrimitives2D ();
900 }
901 fIsDrawGroup = false;
902}
903
904template <class T> void G4VisManager::DrawT
905(const T& graphics_primitive, const G4Transform3D& objectTransform) {
906#ifdef G4MULTITHREADED
907 if (G4Threading::IsWorkerThread()) return;
908#endif
909 if (fIsDrawGroup) {
910 if (objectTransform != fpSceneHandler->GetObjectTransformation()) {
912 ("G4VSceneHandler::DrawT",
913 "visman0010", FatalException,
914 "Different transform detected in Begin/EndDraw group.");
915 }
916 fpSceneHandler -> AddPrimitive (graphics_primitive);
917 } else {
918 if (IsValidView ()) {
920 fpSceneHandler -> BeginPrimitives (objectTransform);
921 fpSceneHandler -> AddPrimitive (graphics_primitive);
922 fpSceneHandler -> EndPrimitives ();
923 }
924 }
925}
926
927template <class T> void G4VisManager::DrawT2D
928(const T& graphics_primitive, const G4Transform3D& objectTransform) {
929#ifdef G4MULTITHREADED
930 if (G4Threading::IsWorkerThread()) return;
931#endif
932 if (fIsDrawGroup) {
933 if (objectTransform != fpSceneHandler->GetObjectTransformation()) {
935 ("G4VSceneHandler::DrawT",
936 "visman0011", FatalException,
937 "Different transform detected in Begin/EndDraw2D group.");
938 }
939 fpSceneHandler -> AddPrimitive (graphics_primitive);
940 } else {
941 if (IsValidView ()) {
943 fpSceneHandler -> BeginPrimitives2D (objectTransform);
944 fpSceneHandler -> AddPrimitive (graphics_primitive);
945 fpSceneHandler -> EndPrimitives2D ();
946 }
947 }
948}
949
950void G4VisManager::Draw (const G4Circle& circle,
951 const G4Transform3D& objectTransform)
952{
953 DrawT (circle, objectTransform);
954}
955
956void G4VisManager::Draw (const G4Polyhedron& polyhedron,
957 const G4Transform3D& objectTransform)
958{
959 DrawT (polyhedron, objectTransform);
960}
961
963 const G4Transform3D& objectTransform)
964{
965 DrawT (line, objectTransform);
966}
967
968void G4VisManager::Draw (const G4Polymarker& polymarker,
969 const G4Transform3D& objectTransform)
970{
971 DrawT (polymarker, objectTransform);
972}
973
974void G4VisManager::Draw (const G4Square& square,
975 const G4Transform3D& objectTransform)
976{
977 DrawT (square, objectTransform);
978}
979
980void G4VisManager::Draw (const G4Text& text,
981 const G4Transform3D& objectTransform)
982{
983 DrawT (text, objectTransform);
984}
985
986void G4VisManager::Draw2D (const G4Circle& circle,
987 const G4Transform3D& objectTransform)
988{
989 DrawT2D (circle, objectTransform);
990}
991
992void G4VisManager::Draw2D (const G4Polyhedron& polyhedron,
993 const G4Transform3D& objectTransform)
994{
995 DrawT2D (polyhedron, objectTransform);
996}
997
999 const G4Transform3D& objectTransform)
1000{
1001 DrawT2D (line, objectTransform);
1002}
1003
1004void G4VisManager::Draw2D (const G4Polymarker& polymarker,
1005 const G4Transform3D& objectTransform)
1006{
1007 DrawT2D (polymarker, objectTransform);
1008}
1009
1010void G4VisManager::Draw2D (const G4Square& square,
1011 const G4Transform3D& objectTransform)
1012{
1013 DrawT2D (square, objectTransform);
1014}
1015
1017 const G4Transform3D& objectTransform)
1018{
1019 DrawT2D (text, objectTransform);
1020}
1021
1022void G4VisManager::Draw (const G4VHit& hit) {
1023#ifdef G4MULTITHREADED
1024 if (G4Threading::IsWorkerThread()) return;
1025#endif
1026 if (fIsDrawGroup) {
1027 fpSceneHandler -> AddCompound (hit);
1028 } else {
1029 if (IsValidView ()) {
1031 fpSceneHandler -> AddCompound (hit);
1032 }
1033 }
1034}
1035
1036void G4VisManager::Draw (const G4VDigi& digi) {
1037#ifdef G4MULTITHREADED
1038 if (G4Threading::IsWorkerThread()) return;
1039#endif
1040 if (fIsDrawGroup) {
1041 fpSceneHandler -> AddCompound (digi);
1042 } else {
1043 if (IsValidView ()) {
1045 fpSceneHandler -> AddCompound (digi);
1046 }
1047 }
1048}
1049
1051#ifdef G4MULTITHREADED
1052 if (G4Threading::IsWorkerThread()) return;
1053#endif
1054 // A trajectory needs a trajectories model to provide G4Atts, etc.
1055 static G4TrajectoriesModel trajectoriesModel;
1056 trajectoriesModel.SetCurrentTrajectory(&traj);
1058 const G4Run* currentRun = runManager->GetCurrentRun();
1059 if (currentRun) {
1060 trajectoriesModel.SetRunID(currentRun->GetRunID());
1061 }
1062 const G4Event* currentEvent =
1064 if (currentEvent) {
1065 trajectoriesModel.SetEventID(currentEvent->GetEventID());
1066 }
1067 if (fIsDrawGroup) {
1068 fpSceneHandler -> SetModel (&trajectoriesModel);
1069 fpSceneHandler -> AddCompound (traj);
1070 fpSceneHandler -> SetModel (0);
1071 } else {
1072 if (IsValidView ()) {
1074 fpSceneHandler -> SetModel (&trajectoriesModel);
1075 fpSceneHandler -> AddCompound (traj);
1076 fpSceneHandler -> SetModel (0);
1077 }
1078 }
1079}
1080
1081void G4VisManager::Draw (const G4LogicalVolume& logicalVol,
1082 const G4VisAttributes& attribs,
1083 const G4Transform3D& objectTransform) {
1084#ifdef G4MULTITHREADED
1085 if (G4Threading::IsWorkerThread()) return;
1086#endif
1087 // Find corresponding solid.
1088 G4VSolid* pSol = logicalVol.GetSolid ();
1089 Draw (*pSol, attribs, objectTransform);
1090}
1091
1092void G4VisManager::Draw (const G4VSolid& solid,
1093 const G4VisAttributes& attribs,
1094 const G4Transform3D& objectTransform) {
1095#ifdef G4MULTITHREADED
1096 if (G4Threading::IsWorkerThread()) return;
1097#endif
1098 if (fIsDrawGroup) {
1099 fpSceneHandler -> PreAddSolid (objectTransform, attribs);
1101 fpSceneHandler -> PostAddSolid ();
1102 } else {
1103 if (IsValidView ()) {
1105 fpSceneHandler -> PreAddSolid (objectTransform, attribs);
1107 fpSceneHandler -> PostAddSolid ();
1108 }
1109 }
1110}
1111
1112void G4VisManager::Draw (const G4VPhysicalVolume& physicalVol,
1113 const G4VisAttributes& attribs,
1114 const G4Transform3D& objectTransform) {
1115#ifdef G4MULTITHREADED
1116 if (G4Threading::IsWorkerThread()) return;
1117#endif
1118 // Note: It is tempting to use a temporary model here, as for
1119 // trajectories, in order to get at the G4Atts of the physical
1120 // volume. I tried it (JA). But it's not easy to pass the
1121 // vis attributes. Also other aspects of the model seem not to
1122 // be properly set up. So, the idea has been abandoned for the time
1123 // being. The model pointer will be null. So when picking there
1124 // will be no G4Atts from this physical volume.
1125 //
1126 // If this is called from DrawHit, for example, the user may G4Atts to the
1127 // hit and these will be available with "/vis/scene/add/hits".
1128 //
1129 // Find corresponding logical volume and solid.
1130 G4LogicalVolume* pLV = physicalVol.GetLogicalVolume ();
1131 G4VSolid* pSol = pLV -> GetSolid ();
1132 Draw (*pSol, attribs, objectTransform);
1133}
1134
1136 if (!fInitialised) Initialise ();
1137 if (fpGraphicsSystem) {
1138 G4VSceneHandler* pSceneHandler =
1140 if (pSceneHandler) {
1141 fAvailableSceneHandlers.push_back (pSceneHandler);
1142 fpSceneHandler = pSceneHandler; // Make current.
1143 }
1144 else {
1145 if (fVerbosity >= errors) {
1146 G4cout << "ERROR in G4VisManager::CreateSceneHandler during "
1147 << fpGraphicsSystem -> GetName ()
1148 << " scene handler creation.\n No action taken."
1149 << G4endl;
1150 }
1151 }
1152 }
1153 else PrintInvalidPointers ();
1154}
1155
1157(const G4String& name, const G4String& XGeometry)
1158{
1159
1160 if (!fInitialised) Initialise ();
1161
1162 if (!fpSceneHandler) {
1164 return;
1165 }
1166
1168
1169 if (!p) {
1170 if (fVerbosity >= errors) {
1171 G4cerr << "ERROR in G4VisManager::CreateViewer: null pointer during "
1172 << fpGraphicsSystem -> GetName ()
1173 << " viewer creation.\n No action taken."
1174 << G4endl;
1175 }
1176 return;
1177 }
1178
1179 if (p -> GetViewId() < 0) {
1180 if (fVerbosity >= errors) {
1181 G4cerr << "ERROR in G4VisManager::CreateViewer during "
1182 << fpGraphicsSystem -> GetName ()
1183 << " viewer instantiation.\n No action taken."
1184 << G4endl;
1185 }
1186 return;
1187 }
1188
1189 // Viewer is created, now we can set geometry parameters
1190 // Before 12/2008, it was done in G4VViewer.cc but it did not have to be there!
1191
1192 G4ViewParameters initialvp = p -> GetViewParameters();
1193 initialvp.SetXGeometryString(XGeometry); //parse string and store parameters
1194 p -> SetViewParameters(initialvp);
1195 p -> Initialise (); // (Viewer itself may change view parameters further.)
1196 if (p -> GetViewId() < 0) {
1197 if (fVerbosity >= errors) {
1198 G4cerr << "ERROR in G4VisManager::CreateViewer during "
1199 << fpGraphicsSystem -> GetName ()
1200 << " viewer initialisation.\n No action taken."
1201 << G4endl;
1202 }
1203 return;
1204 }
1205
1206 fpViewer = p; // Make current.
1207 fpSceneHandler -> AddViewerToList (fpViewer);
1209 if (fVerbosity >= confirmations) {
1210 G4cout << "G4VisManager::CreateViewer: new viewer created."
1211 << G4endl;
1212 }
1213
1215 if (fVerbosity >= parameters) {
1216 G4cout << " view parameters are:\n " << vp << G4endl;
1217 }
1218
1219 if (vp.IsCulling () && vp.IsCullingInvisible ()) {
1220 static G4bool warned = false;
1221 if (fVerbosity >= confirmations) {
1222 if (!warned) {
1223 G4cout <<
1224 "NOTE: objects with visibility flag set to \"false\""
1225 " will not be drawn!"
1226 "\n \"/vis/viewer/set/culling global false\" to Draw such objects."
1227 "\n Also see other \"/vis/viewer/set\" commands."
1228 << G4endl;
1229 warned = true;
1230 }
1231 }
1232 }
1233 if (vp.IsCullingCovered ()) {
1234 static G4bool warned = false;
1235 if (fVerbosity >= warnings) {
1236 if (!warned) {
1237 G4cout <<
1238 "WARNING: covered objects in solid mode will not be rendered!"
1239 "\n \"/vis/viewer/set/culling coveredDaughters false\" to reverse this."
1240 "\n Also see other \"/vis/viewer/set\" commands."
1241 << G4endl;
1242 warned = true;
1243 }
1244 }
1245 }
1246}
1247
1249 if (fVerbosity >= confirmations) {
1250 G4cout << "G4VisManager::GeometryHasChanged() called." << G4endl;
1251 }
1252
1253 // Change the world...
1254 G4VPhysicalVolume* pWorld =
1256 -> GetNavigatorForTracking () -> GetWorldVolume ();
1257 if (!pWorld) {
1258 if (fVerbosity >= warnings) {
1259 G4cout << "WARNING: There is no world volume!" << G4endl;
1260 }
1261 }
1262
1263 // Check scenes.
1264 G4SceneList& sceneList = fSceneList;
1265 G4int iScene, nScenes = sceneList.size ();
1266 for (iScene = 0; iScene < nScenes; iScene++) {
1267 G4Scene* pScene = sceneList [iScene];
1268 std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
1269 if (modelList.size ()) {
1270 G4bool modelInvalid;
1271 do { // Remove, if required, one at a time.
1272 modelInvalid = false;
1273 std::vector<G4Scene::Model>::iterator iterModel;
1274 for (iterModel = modelList.begin();
1275 iterModel != modelList.end();
1276 ++iterModel) {
1277 modelInvalid = !(iterModel->fpModel->Validate(fVerbosity>=warnings));
1278 if (modelInvalid) {
1279 // Model invalid - remove and break.
1280 if (fVerbosity >= warnings) {
1281 G4cout << "WARNING: Model \""
1282 << iterModel->fpModel->GetGlobalDescription ()
1283 <<
1284 "\" is no longer valid - being removed\n from scene \""
1285 << pScene -> GetName () << "\""
1286 << G4endl;
1287 }
1288 modelList.erase (iterModel);
1289 break;
1290 }
1291 }
1292 } while (modelInvalid);
1293
1294 if (modelList.size () == 0) {
1295 if (fVerbosity >= warnings) {
1296 G4cout << "WARNING: No models left in this scene \""
1297 << pScene -> GetName ()
1298 << "\"."
1299 << G4endl;
1300 }
1301 }
1302 else {
1303 pScene->CalculateExtent();
1305 ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName()));
1306 }
1307 }
1308 }
1309
1310 // Check the manager's current scene...
1311 if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) {
1312 if (fVerbosity >= warnings) {
1313 G4cout << "WARNING: The current scene \""
1314 << fpScene -> GetName ()
1315 << "\" has no run duration models."
1316 << "\n Use \"/vis/scene/add/volume\" or create a new scene."
1317 << G4endl;
1318 }
1319 // Clean up
1320 if (fpSceneHandler) {
1323 if (fpViewer) {
1325 fpViewer->SetView();
1328 }
1329 }
1330 }
1331}
1332
1334
1335 if (fVerbosity >= confirmations) {
1336 G4cout << "G4VisManager::NotifyHandler() called." << G4endl;
1337 }
1338
1339 if (IsValidView()) {
1340
1341 // Check scenes.
1342 G4SceneList& sceneList = fSceneList;
1343 G4int iScene, nScenes = sceneList.size ();
1344 for (iScene = 0; iScene < nScenes; iScene++) {
1345 G4Scene* pScene = sceneList [iScene];
1346 std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
1347
1348 if (modelList.size ()) {
1349 pScene->CalculateExtent();
1351 ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName()));
1352 }
1353 }
1354
1355 // Check the manager's current scene...
1356 if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) {
1357 if (fVerbosity >= warnings) {
1358 G4cout << "WARNING: The current scene \""
1359 << fpScene -> GetName ()
1360 << "\" has no run duration models."
1361 << "\n Use \"/vis/scene/add/volume\" or create a new scene."
1362 << G4endl;
1363 }
1367 fpViewer->SetView();
1370 }
1371 }
1372}
1373
1375{
1376 return fpTrajFilterMgr->Accept(trajectory);
1377}
1378
1380{
1381 return fpHitFilterMgr->Accept(hit);
1382}
1383
1385{
1386 return fpDigiFilterMgr->Accept(digi);
1387}
1388
1390{
1391 G4bool visible(true);
1392
1393 // See if trajectory passes filter
1394 G4bool passed = FilterTrajectory(trajectory);
1395
1396 if (!passed) {
1397 // Draw invisible trajectory if trajectory failed filter and
1398 // are filtering in soft mode
1399 if (fpTrajFilterMgr->GetMode() == FilterMode::Soft) visible = false;
1400 else {return;}
1401 }
1402
1403 // Go on to draw trajectory
1404 assert (0 != fpTrajDrawModelMgr);
1405
1406 const G4VTrajectoryModel* trajectoryModel = CurrentTrajDrawModel();
1407
1408 assert (0 != trajectoryModel); // Should exist
1409
1410 if (IsValidView()) {
1411 trajectoryModel->Draw(trajectory, visible);
1412 }
1413}
1414
1416(const G4String& name,
1417 G4VUserVisAction* pVisAction,
1418 const G4VisExtent& extent) {
1419 fRunDurationUserVisActions.push_back(UserVisAction(name,pVisAction));
1420 if (extent.GetExtentRadius() > 0.) {
1421 fUserVisActionExtents[pVisAction] = extent;
1422 } else {
1423 if (fVerbosity >= warnings) {
1424 G4cout <<
1425 "WARNING: No extent set for user vis action \"" << name << "\"."
1426 << G4endl;
1427 }
1428 }
1429 if (fVerbosity >= confirmations) {
1430 G4cout
1431 << "Run duration user vis action \"" << name << "\" registered"
1432 << G4endl;
1433 }
1434}
1435
1437(const G4String& name,
1438 G4VUserVisAction* pVisAction,
1439 const G4VisExtent& extent) {
1440 fEndOfEventUserVisActions.push_back(UserVisAction(name,pVisAction));
1441 if (extent.GetExtentRadius() > 0.) {
1442 fUserVisActionExtents[pVisAction] = extent;
1443 } else {
1444 if (fVerbosity >= warnings) {
1445 G4cout <<
1446 "WARNING: No extent set for user vis action \"" << name << "\"."
1447 << G4endl;
1448 }
1449 }
1450 if (fVerbosity >= confirmations) {
1451 G4cout
1452 << "End of event user vis action \"" << name << "\" registered"
1453 << G4endl;
1454 }
1455}
1456
1458(const G4String& name,
1459 G4VUserVisAction* pVisAction,
1460 const G4VisExtent& extent) {
1461 fEndOfRunUserVisActions.push_back(UserVisAction(name,pVisAction));
1462 if (extent.GetExtentRadius() > 0.) {
1463 fUserVisActionExtents[pVisAction] = extent;
1464 } else {
1465 if (fVerbosity >= warnings) {
1466 G4cout <<
1467 "WARNING: No extent set for user vis action \"" << name << "\"."
1468 << G4endl;
1469 }
1470 }
1471 if (fVerbosity >= confirmations) {
1472 G4cout
1473 << "End of run user vis action \"" << name << "\" registered"
1474 << G4endl;
1475 }
1476}
1477
1479 if (pScene != fpScene) {
1480 // A change of scene. Therefore reset transients drawn flags. All
1481 // memory of previous transient proceessing thereby erased...
1483 }
1484 fpScene = pScene;
1485}
1486
1488 fpGraphicsSystem = pSystem;
1489 if (fVerbosity >= confirmations) {
1490 G4cout << "G4VisManager::SetCurrentGraphicsSystem: system now "
1491 << pSystem -> GetName () << G4endl;
1492 }
1493 // If current scene handler is of same graphics system, leave unchanged.
1494 // Else find the most recent scene handler of same graphics system.
1495 // Or clear pointers.
1496 if (!(fpSceneHandler && fpSceneHandler -> GetGraphicsSystem () == pSystem)) {
1497 const G4SceneHandlerList& sceneHandlerList = fAvailableSceneHandlers;
1498 G4int nSH = sceneHandlerList.size (); // No. of scene handlers.
1499 G4int iSH;
1500 for (iSH = nSH - 1; iSH >= 0; iSH--) {
1501 if (sceneHandlerList [iSH] -> GetGraphicsSystem () == pSystem) break;
1502 }
1503 if (iSH >= 0) {
1504 fpSceneHandler = sceneHandlerList [iSH];
1505 if (fVerbosity >= confirmations) {
1506 G4cout << " Scene Handler now "
1507 << fpSceneHandler -> GetName () << G4endl;
1508 }
1509 if (fpScene != fpSceneHandler -> GetScene ()) {
1510 fpScene = fpSceneHandler -> GetScene ();
1511 if (fVerbosity >= confirmations) {
1512 G4cout << " Scene now \""
1513 << fpScene -> GetName () << "\"" << G4endl;
1514 }
1515 }
1516 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList ();
1517 if (viewerList.size ()) {
1518 fpViewer = viewerList [0];
1519 if (fVerbosity >= confirmations) {
1520 G4cout << " Viewer now " << fpViewer -> GetName () << G4endl;
1521 }
1522 }
1523 else {
1524 fpViewer = 0;
1525 }
1526 }
1527 else {
1528 fpSceneHandler = 0;
1529 fpViewer = 0;
1530 }
1531 }
1532}
1533
1535 fpSceneHandler = pSceneHandler;
1536 if (fVerbosity >= confirmations) {
1537 G4cout << "G4VisManager::SetCurrentSceneHandler: scene handler now \""
1538 << pSceneHandler -> GetName () << "\"" << G4endl;
1539 }
1540 if (fpScene != fpSceneHandler -> GetScene ()) {
1541 fpScene = fpSceneHandler -> GetScene ();
1542 if (fVerbosity >= confirmations) {
1543 G4cout << " Scene now \""
1544 << fpScene -> GetName () << "\"" << G4endl;
1545 }
1546 }
1547 if (fpGraphicsSystem != pSceneHandler -> GetGraphicsSystem ()) {
1548 fpGraphicsSystem = pSceneHandler -> GetGraphicsSystem ();
1549 if (fVerbosity >= confirmations) {
1550 G4cout << " Graphics system now \""
1551 << fpGraphicsSystem -> GetName () << "\"" << G4endl;
1552 }
1553 }
1554 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList ();
1555 G4int nViewers = viewerList.size ();
1556 if (nViewers) {
1557 G4int iViewer;
1558 for (iViewer = 0; iViewer < nViewers; iViewer++) {
1559 if (fpViewer == viewerList [iViewer]) break;
1560 }
1561 if (iViewer >= nViewers) {
1562 fpViewer = viewerList [0];
1563 if (fVerbosity >= confirmations) {
1564 G4cout << " Viewer now \"" << fpViewer -> GetName () << "\""
1565 << G4endl;
1566 }
1567 }
1568 if (!IsValidView ()) {
1569 if (fVerbosity >= warnings) {
1570 G4cout <<
1571 "WARNING: Problem setting scene handler - please report circumstances."
1572 << G4endl;
1573 }
1574 }
1575 }
1576 else {
1577 fpViewer = 0;
1578 if (fVerbosity >= warnings) {
1579 G4cout <<
1580 "WARNING: No viewers for this scene handler - please create one."
1581 << G4endl;
1582 }
1583 }
1584}
1585
1587 fpViewer = pViewer;
1588 if (fpViewer == nullptr) {
1589 if (fVerbosity >= confirmations) {
1590 G4cout << "G4VisManager::SetCurrentViewer: current viewer pointer zeroed "
1591 << G4endl;
1592 }
1593 return;
1594 }
1595 if (fVerbosity >= confirmations) {
1596 G4cout << "G4VisManager::SetCurrentViewer: viewer now "
1597 << pViewer -> GetName ()
1598 << G4endl;
1599 }
1600 fpSceneHandler = fpViewer -> GetSceneHandler ();
1601 if (!fpSceneHandler) {
1602 if (fVerbosity >= warnings) {
1603 G4cout <<
1604 "WARNING: No scene handler for this viewer - please create one."
1605 << G4endl;
1606 }
1607 return;
1608 }
1609 // JA: I don't think we need this. Setview will be called when needed.
1610 // fpViewer->SetView();
1611 fpSceneHandler -> SetCurrentViewer (pViewer);
1612 fpScene = fpSceneHandler -> GetScene ();
1613 fpGraphicsSystem = fpSceneHandler -> GetGraphicsSystem ();
1614 if (!IsValidView ()) {
1615 if (fVerbosity >= warnings) {
1616 G4cout <<
1617 "WARNING: Problem setting viewer - please report circumstances."
1618 << G4endl;
1619 }
1620 }
1621}
1622
1624{
1625 G4cout << "Registered graphics systems are:\n";
1626 if (fAvailableGraphicsSystems.size ()) {
1627 for (const auto& gs: fAvailableGraphicsSystems) {
1628 const G4String& name = gs->GetName();
1629 const std::vector<G4String>& nicknames = gs->GetNicknames();
1630 if (verbosity <= warnings) {
1631 // Brief output
1632 G4cout << " " << name << " (";
1633 for (size_t i = 0; i < nicknames.size(); ++i) {
1634 if (i != 0) {
1635 G4cout << ", ";
1636 }
1637 G4cout << nicknames[i];
1638 }
1639 G4cout << ')';
1640 } else {
1641 // Full output
1642 G4cout << *gs;
1643 }
1644 G4cout << G4endl;
1645 }
1646 } else {
1647 G4cout << " NONE!!! None registered - yet! Mmmmm!" << G4endl;
1648 }
1649}
1650
1652{
1653 {
1654 //fpTrajDrawModelMgr->Print(G4cout);
1655 G4cout << "Registered model factories:" << G4endl;
1656 const std::vector<G4VModelFactory<G4VTrajectoryModel>*>& factoryList =
1658 if (factoryList.empty()) G4cout << " None" << G4endl;
1659 else {
1660 std::vector<G4VModelFactory<G4VTrajectoryModel>*>::const_iterator i;
1661 for (i = factoryList.begin(); i != factoryList.end(); ++i) {
1662 (*i)->Print(G4cout);
1663 }
1664 }
1665 G4cout << "\nRegistered models:" << G4endl;
1666 const G4VisListManager<G4VTrajectoryModel>* listManager =
1668 const std::map<G4String, G4VTrajectoryModel*>& modelMap =
1669 listManager->Map();
1670 if (modelMap.empty()) G4cout << " None" << G4endl;
1671 else {
1672 std::map<G4String, G4VTrajectoryModel*>::const_iterator i;
1673 for (i = modelMap.begin(); i != modelMap.end(); ++i) {
1674 G4cout << " " << i->second->Name();
1675 if (i->second == listManager->Current()) G4cout << " (Current)";
1676 G4cout << G4endl;
1677 if (verbosity >= parameters) i->second->Print(G4cout);
1678 }
1679 }
1680 }
1681
1682 G4cout << G4endl;
1683
1684 {
1685 //fpTrajFilterMgr->Print(G4cout);
1686 G4cout << "Registered filter factories:" << G4endl;
1687 const std::vector<G4VModelFactory<G4VFilter<G4VTrajectory> >*>&
1688 factoryList = fpTrajFilterMgr->FactoryList();
1689 if (factoryList.empty()) G4cout << " None" << G4endl;
1690 else {
1691 std::vector<G4VModelFactory<G4VFilter<G4VTrajectory> >*>::const_iterator i;
1692 for (i = factoryList.begin(); i != factoryList.end(); ++i) {
1693 (*i)->Print(G4cout);
1694 }
1695 }
1696
1697 G4cout << "\nRegistered filters:" << G4endl;
1698 const std::vector<G4VFilter<G4VTrajectory>*>&
1699 filterList = fpTrajFilterMgr->FilterList();
1700 if (filterList.empty()) G4cout << " None" << G4endl;
1701 else {
1702 std::vector<G4VFilter<G4VTrajectory>*>::const_iterator i;
1703 for (i = filterList.begin(); i != filterList.end(); ++i) {
1704 G4cout << " " << (*i)->GetName() << G4endl;
1705 if (verbosity >= parameters) (*i)->PrintAll(G4cout);
1706 }
1707 }
1708 }
1709}
1710
1712{
1713 G4cout <<
1714 "You have successfully registered the following user vis actions."
1715 << G4endl;
1716 G4cout << "Run Duration User Vis Actions:";
1717 if (fRunDurationUserVisActions.empty()) G4cout << " none" << G4endl;
1718 else {
1719 G4cout << G4endl;
1720 for (size_t i = 0; i < fRunDurationUserVisActions.size(); i++) {
1721 const G4String& name = fRunDurationUserVisActions[i].fName;
1722 G4cout << " " << name << G4endl;
1723 }
1724 }
1725
1726 G4cout << "End of Event User Vis Actions:";
1727 if (fEndOfEventUserVisActions.empty()) G4cout << " none" << G4endl;
1728 else {
1729 G4cout << G4endl;
1730 for (size_t i = 0; i < fEndOfEventUserVisActions.size(); i++) {
1731 const G4String& name = fEndOfEventUserVisActions[i].fName;
1732 G4cout << " " << name << G4endl;
1733 }
1734 }
1735
1736 G4cout << "End of Run User Vis Actions:";
1737 if (fEndOfRunUserVisActions.empty()) G4cout << " none" << G4endl;
1738 else {
1739 G4cout << G4endl;
1740 for (size_t i = 0; i < fEndOfRunUserVisActions.size(); i++) {
1741 const G4String& name = fEndOfRunUserVisActions[i].fName;
1742 G4cout << " " << name << G4endl;
1743 }
1744 }
1745}
1746
1748 G4cout <<
1749 "Some /vis commands (optionally) take a string to specify colour."
1750 "\nAvailable colours:\n ";
1751 const std::map<G4String, G4Colour>& map = G4Colour::GetMap();
1752 for (std::map<G4String, G4Colour>::const_iterator i = map.begin();
1753 i != map.end();) {
1754 G4cout << i->first;
1755 if (++i != map.end()) G4cout << ", ";
1756 }
1757 G4cout << G4endl;
1758}
1759
1761 if (fVerbosity >= errors) {
1762 G4cerr << "ERROR: G4VisManager::PrintInvalidPointers:";
1763 if (!fpGraphicsSystem) {
1764 G4cerr << "\n null graphics system pointer.";
1765 }
1766 else {
1767 G4cerr << "\n Graphics system is " << fpGraphicsSystem -> GetName ()
1768 << " but:";
1769 if (!fpScene)
1770 G4cerr <<
1771 "\n Null scene pointer. Use \"/vis/drawVolume\" or"
1772 " \"/vis/scene/create\".";
1773 if (!fpSceneHandler)
1774 G4cerr <<
1775 "\n Null scene handler pointer. Use \"/vis/open\" or"
1776 " \"/vis/sceneHandler/create\".";
1777 if (!fpViewer )
1778 G4cerr <<
1779 "\n Null viewer pointer. Use \"/vis/viewer/create\".";
1780 }
1781 G4cerr << G4endl;
1782 }
1783}
1784
1785#ifdef G4MULTITHREADED
1786
1787namespace {
1788 G4bool mtRunInProgress = false;
1789 std::deque<const G4Event*> mtVisEventQueue;
1790 G4Thread* mtVisSubThread = 0;
1791 G4Mutex mtVisSubThreadMutex = G4MUTEX_INITIALIZER;
1792}
1793
1794G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
1795{
1796 G4VisManager* pVisManager = (G4VisManager*)p;
1797 G4VSceneHandler* pSceneHandler = pVisManager->GetCurrentSceneHandler();
1798 if (!pSceneHandler) return 0;
1799 G4Scene* pScene = pSceneHandler->GetScene();
1800 if (!pScene) return 0;
1801 G4VViewer* pViewer = pVisManager->GetCurrentViewer();
1802 if (!pViewer) return 0;
1803
1805
1806 // G4cout << "G4VisManager::G4VisSubThread: thread: "
1807 // << G4Threading::G4GetThreadId() << std::endl;
1808
1809 // Set up geometry and navigation for a thread
1814 navigator->SetWorldVolume(
1816
1817 pViewer->SwitchToVisSubThread();
1818
1819 while (true) {
1820
1821 G4MUTEXLOCK(&mtVisSubThreadMutex);
1822 G4int eventQueueSize = mtVisEventQueue.size();
1823 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1824 // G4cout << "Event queue size (A): " << eventQueueSize << G4endl;
1825
1826 while (eventQueueSize) {
1827
1828 G4MUTEXLOCK(&mtVisSubThreadMutex);
1829 const G4Event* event = mtVisEventQueue.front();
1830 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1831 // G4int eventID = event->GetEventID();
1832 // G4cout
1833 // << "G4VisManager::G4VisSubThread: Vis sub-thread: Dealing with event:
1834 // "
1835 // << eventID << G4endl;
1836
1837 // Here comes the event drawing
1838 pVisManager->SetTransientsDrawnThisEvent(false);
1839 pSceneHandler->SetTransientsDrawnThisEvent(false);
1840
1841 // We are about to draw the event (trajectories, etc.), but first we
1842 // have to clear the previous event(s) if necessary. If this event
1843 // needs to be drawn afresh, e.g., the first event or any event when
1844 // "accumulate" is not requested, the old event has to be cleared.
1845 // We have postponed this so that, for normal viewers like OGL, the
1846 // previous event(s) stay on screen until this new event comes
1847 // along. For a file-writing viewer the geometry has to be drawn.
1848 // See, for example, G4HepRepFileSceneHandler::ClearTransientStore.
1849 pVisManager->ClearTransientStoreIfMarked();
1850
1851 // Now draw the event...
1852 pSceneHandler->DrawEvent(event);
1853 ++pVisManager->fNoOfEventsDrawnThisRun;
1854
1855 if (pScene->GetRefreshAtEndOfEvent()) {
1856
1857 // ShowView guarantees the view is flushed to the screen. It also
1858 // triggers other features such picking (if enabled) and allows
1859 // file-writing viewers to close the file.
1860 pViewer->ShowView();
1861 pSceneHandler->SetMarkForClearingTransientStore(true);
1862
1863 }
1864
1865 // Testing.
1866 // std::this_thread::sleep_for(std::chrono::seconds(5));
1867
1868 // Then pop and release event
1869 G4MUTEXLOCK(&mtVisSubThreadMutex);
1870 mtVisEventQueue.pop_front();
1871 event->PostProcessingFinished();
1872 eventQueueSize = mtVisEventQueue.size();
1873 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1874 // G4cout << "Event queue size (B): " << eventQueueSize << G4endl;
1875 }
1876
1877 G4MUTEXLOCK(&mtVisSubThreadMutex);
1878 G4int runInProgress = mtRunInProgress;
1879 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1880 if (!runInProgress) {
1881 // EndOfRun on master thread has signalled end of run. There is
1882 // nothing to draw so...
1883 break;
1884 }
1885
1886 // Run still in progress but nothing to draw, so wait a while.
1887 std::this_thread::sleep_for(std::chrono::milliseconds(100));
1888 }
1889
1890 // Inform viewer that we have finished all sub-thread drawing
1891 pViewer->DoneWithVisSubThread();
1892 pViewer->MovingToMasterThread();
1893 // G4cout << "G4VisManager::G4VisSubThread: Vis sub-thread: ending" << G4endl;
1894 return nullptr;
1895}
1896
1897namespace {
1898 // G4Mutex visBeginOfRunMutex = G4MUTEX_INITIALIZER;
1899 // G4Mutex visBeginOfEventMutex = G4MUTEX_INITIALIZER;
1900 G4Mutex visEndOfEventMutex = G4MUTEX_INITIALIZER;
1901 // G4Mutex visEndOfRunMutex = G4MUTEX_INITIALIZER;
1902}
1903
1904#endif
1905
1907{
1908 if (fIgnoreStateChanges) return;
1909
1910#ifdef G4MULTITHREADED
1911 if (G4Threading::IsWorkerThread()) return;
1912#endif
1913 // G4cout << "G4VisManager::BeginOfRun: thread: "
1914 // << G4Threading::G4GetThreadId() << G4endl;
1915
1917
1918 // For a fake run...
1919 G4int nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
1920 if (nEventsToBeProcessed == 0) return;
1921
1922 fNKeepRequests = 0;
1923 fEventKeepingSuspended = false;
1927
1928 // Check to see if the user has created a trajectory model. If not, create
1929 // a default one. To avoid code duplication the following function is used
1930 // and its result (a const G4VTrajectoryModel*) is thrown away at this point.
1931 // The function is called again later when needed.
1933
1934#ifdef G4MULTITHREADED
1935// There is a static method G4Threading::IsMultithreadedApplication()
1936// that returns true only if G4MTRunManager is instantiated with MT
1937// installation. Thus method returns false if G4RunManager base class is
1938// instantiated even with the MT installation, or of course with sequential
1939// installation.
1941
1942 // Inform viewer that we have finished all master thread drawing for now...
1943 if (fpViewer) fpViewer->DoneWithMasterThread();
1944
1945 // Start vis sub-thread
1946// G4cout << "G4VisManager::BeginOfRun: Starting vis sub-thread" << G4endl;
1947 G4MUTEXLOCK(&mtVisSubThreadMutex);
1948 mtRunInProgress = true;
1949 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
1950 mtVisSubThread = new G4Thread;
1951 // Launch vis thread
1952 G4THREADCREATE(mtVisSubThread,G4VisSubThread,this);
1953
1954 // Tricky things for some viewers (e.g., Qt):
1955 // - Launch the vis thread
1956 // - Wait for the vis thread to set its QThread
1957 // - Then move current QOpenGL context (if Qt) to this Qthread
1958 // - Go ahead
1959 if (fpViewer) fpViewer->MovingToVisSubThread();
1960 }
1961#endif
1962}
1963
1965{
1966 if (fIgnoreStateChanges) return;
1967
1968 if (!GetConcreteInstance()) return;
1969
1970// G4cout << "G4VisManager::BeginOfEvent: thread: "
1971// << G4Threading::G4GetThreadId() << G4endl;
1972
1973 // Some instructions that should NOT be in multithreaded version.
1974#ifndef G4MULTITHREADED
1975 // These instructions are in G4VisSubThread for multithreading.
1978#endif
1979}
1980
1982{
1983 if (fIgnoreStateChanges) return;
1984
1985 if (!GetConcreteInstance()) return;
1986
1987 // Don't call IsValidView unless there is a scene handler. This
1988 // avoids WARNING message at end of event and run when the user has
1989 // not instantiated a scene handler, e.g., in batch mode.
1990 G4bool valid = fpSceneHandler && IsValidView();
1991 if (!valid) return;
1992
1993// G4cout << "G4VisManager::EndOfEvent: thread: "
1994// << G4Threading::G4GetThreadId() << G4endl;
1995
1996#ifdef G4MULTITHREADED
1997 G4AutoLock al(&visEndOfEventMutex);
1998 // Testing.
1999// std::this_thread::sleep_for(std::chrono::seconds(5));
2000#endif
2001
2003
2004 const G4Run* currentRun = runManager->GetCurrentRun();
2005 if (!currentRun) return;
2006
2007 // This gets the thread-local event manager
2009 const G4Event* currentEvent = eventManager->GetConstCurrentEvent();
2010 if (!currentEvent) return;
2011
2012 // Discard event if fDrawEventOnlyIfToBeKept flag is set unless the
2013 // user has requested the event to be kept.
2015 if (!currentEvent->ToBeKept()) return;
2016 }
2017
2019
2020#ifdef G4MULTITHREADED
2021
2022 // Wait if too many events in the queue.
2023 G4MUTEXLOCK(&mtVisSubThreadMutex);
2024 G4int eventQueueSize = mtVisEventQueue.size();
2025 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2026// G4cout << "Event queue size (1): " << eventQueueSize << G4endl;
2027
2028 G4bool eventQueueFull = false;
2029 while (fMaxEventQueueSize > 0 && eventQueueSize >= fMaxEventQueueSize) {
2030
2031// G4cout << "Event queue size (2): " << eventQueueSize << G4endl;
2032 if (fWaitOnEventQueueFull) {
2033 static G4bool warned = false;
2034 if (!warned) {
2035 G4cout <<
2036 "WARNING: The number of events in the visualisation queue has exceeded"
2037 "\n the maximum, "
2038 << fMaxEventQueueSize <<
2039 ".\n If, during a multithreaded run, the simulation gets ahead of the"
2040 "\n visualisation by more than this maximum, the simulation is delayed"
2041 "\n until the vis sub-thread has drawn a few more events and removed them"
2042 "\n from the queue. You may change this maximum number of events with"
2043 "\n \"/vis/multithreading/maxEventQueueSize <N>\", where N is the maximum"
2044 "\n number you wish to allow. N <= 0 means \"unlimited\"."
2045 "\n Alternatively you may choose to discard events for drawing by setting"
2046 "\n \"/vis/multithreading/actionOnEventQueueFull discard\"."
2047 "\n To avoid visualisation altogether: \"/vis/disable\"."
2048 "\n And maybe \"/tracking/storeTrajectories 0\"."
2049 << G4endl;
2050 warned = true;
2051 }
2052 // G4cout << "Event queue size (3): " << eventQueueSize << G4endl;
2053 // Wait a while to give event drawing time to reduce the queue...
2054 std::this_thread::sleep_for(std::chrono::milliseconds(100));
2055 // G4cout << "Event queue size (4): " << eventQueueSize << G4endl;
2056 } else {
2057 static G4bool warned = false;
2058 if (!warned) {
2059 G4cout <<
2060 "WARNING: The number of events in the visualisation queue has exceeded"
2061 "\n the maximum, "
2062 << fMaxEventQueueSize <<
2063 ".\n Some events have been discarded for drawing. You may change this"
2064 "\n behaviour with \"/vis/multithreading/actionOnEventQueueFull wait\"."
2065 "\n To avoid visualisation altogether: \"/vis/disable\"."
2066 "\n And maybe \"/tracking/storeTrajectories 0\"."
2067 << G4endl;
2068 warned = true;
2069 }
2070 eventQueueFull = true; // Causes event to be discarded for drawing.
2071 break;
2072 }
2073
2074 G4MUTEXLOCK(&mtVisSubThreadMutex);
2075 eventQueueSize = mtVisEventQueue.size();
2076 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2077 }
2078
2079 if (!eventQueueFull) {
2080 G4MUTEXLOCK(&mtVisSubThreadMutex);
2081 // Keep event for processing and put event on vis event queue
2082 currentEvent->KeepForPostProcessing();
2084 // Keep one event (cannot know which is last so any will do)
2085 if (fNKeepRequests == 0) {
2086 eventManager->KeepTheCurrentEvent();
2088 }
2089 }
2090 mtVisEventQueue.push_back(currentEvent);
2091 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2092 }
2093
2094// G4MUTEXLOCK(&mtVisSubThreadMutex);
2095// G4int eQS = mtVisEventQueue.size();
2096// G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2097// G4cout << "Event queue size (5): " << eQS << G4endl;
2098
2099#endif
2100
2101 } else {
2102
2103 // Sequential mode
2104
2105 G4int nEventsToBeProcessed = 0;
2106 G4int nKeptEvents = 0;
2107 G4int eventID = -2; // (If no run manager, triggers ShowView as normal.)
2108 if (currentRun) {
2109 nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
2110 eventID = currentEvent->GetEventID();
2111 const std::vector<const G4Event*>* events = currentRun->GetEventVector();
2112 if (events) nKeptEvents = events->size();
2113 }
2114
2115 // We are about to draw the event (trajectories, etc.), but first we
2116 // have to clear the previous event(s) if necessary. If this event
2117 // needs to be drawn afresh, e.g., the first event or any event when
2118 // "accumulate" is not requested, the old event has to be cleared.
2119 // We have postponed this so that, for normal viewers like OGL, the
2120 // previous event(s) stay on screen until this new event comes
2121 // along. For a file-writing viewer the geometry has to be drawn.
2122 // See, for example, G4HepRepFileSceneHandler::ClearTransientStore.
2124
2125 // Now draw the event...
2126 fpSceneHandler->DrawEvent(currentEvent);
2128
2130
2131 // Unless last event (in which case wait end of run)...
2132 if (eventID < nEventsToBeProcessed - 1) {
2133 // ShowView guarantees the view is flushed to the screen. It also
2134 // triggers other features such picking (if enabled) and allows
2135 // file-writing viewers to close the file.
2136 fpViewer->ShowView();
2137 } else { // Last event...
2138 // Keep, but only if user has not kept any...
2139 if (nKeptEvents == 0) {
2140 eventManager->KeepTheCurrentEvent();
2142 }
2143 }
2145
2146 }
2147 }
2148
2149 // Both modes - sequential and MT
2150
2151 if (!(fpScene->GetRefreshAtEndOfEvent())) {
2152
2153 // Accumulating events...
2154
2155 G4int maxNumberOfKeptEvents = fpScene->GetMaxNumberOfKeptEvents();
2156
2157 if (maxNumberOfKeptEvents >= 0 &&
2158 fNKeepRequests >= maxNumberOfKeptEvents) {
2159
2161 static G4bool warned = false;
2162 if (!warned) {
2163 if (fVerbosity >= warnings) {
2164 G4cout <<
2165 "WARNING: G4VisManager::EndOfEvent: Automatic event keeping suspended."
2166 "\n The number of events exceeds the maximum, "
2167 << maxNumberOfKeptEvents <<
2168 ", that may be kept by\n the vis manager."
2169 << G4endl;
2170 }
2171 warned = true;
2172 }
2173
2174 } else if (maxNumberOfKeptEvents != 0) {
2175
2176 // If not disabled nor suspended.
2178// G4cout <<
2179// "Requesting keeping event " << currentEvent->GetEventID()
2180// << G4endl;
2181 eventManager->KeepTheCurrentEvent();
2183 }
2184
2185 }
2186 }
2187}
2188
2190{
2191 if (fIgnoreStateChanges) return;
2192
2193#ifdef G4MULTITHREADED
2194 if (G4Threading::IsWorkerThread()) return;
2195#endif
2196
2197 // G4cout << "G4VisManager::EndOfRun: thread: "
2198 // << G4Threading::G4GetThreadId() << G4endl;
2199
2201
2202 // For a fake run...
2203 G4int nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
2204 if (nEventsToBeProcessed == 0) return;
2205
2206 const G4Run* currentRun = runManager->GetCurrentRun();
2207 if (!currentRun) return;
2208
2209#ifdef G4MULTITHREADED
2210 // G4AutoLock al(&visEndOfRunMutex); ???
2212 // Reset flag so that sub-thread exits when it has finished processing.
2213 G4MUTEXLOCK(&mtVisSubThreadMutex);
2214 mtRunInProgress = false;
2215 G4MUTEXUNLOCK(&mtVisSubThreadMutex);
2216 // Wait for sub-thread to finish.
2217 G4THREADJOIN(*mtVisSubThread);
2218 delete mtVisSubThread;
2219 if (fpViewer) fpViewer->SwitchToMasterThread();
2220 }
2221#endif
2222
2223#ifdef G4MULTITHREADED
2224 // Print warning about discarded events, if any.
2225 // Don't call IsValidView unless there is a scene handler. This
2226 // avoids WARNING message from IsValidView() when the user has
2227 // not instantiated a scene handler, e.g., in batch mode.
2228 if (fpSceneHandler && IsValidView()) { // Events should have been drawn
2229 G4int noOfEventsRequested = runManager->GetNumberOfEventsToBeProcessed();
2230 if (fNoOfEventsDrawnThisRun != noOfEventsRequested) {
2231 if (!fWaitOnEventQueueFull && fVerbosity >= warnings) {
2232 G4cout
2233 << "WARNING: Number of events drawn this run, "
2234 << fNoOfEventsDrawnThisRun << ", is different to number requested, "
2235 << noOfEventsRequested <<
2236 ".\n (This is because you requested \"/vis/multithreading/actionOnEventQueueFull discard\".)"
2237 << G4endl;
2238 }
2239 }
2240 }
2241#endif
2242
2243 G4int nKeptEvents = 0;
2244 const std::vector<const G4Event*>* events = currentRun->GetEventVector();
2245 if (events) nKeptEvents = events->size();
2246 if (fVerbosity >= warnings) {
2247 G4cout << nKeptEvents;
2248 if (nKeptEvents == 1) G4cout << " event has";
2249 else G4cout << " events have";
2250 G4cout << " been kept for refreshing and/or reviewing." << G4endl;
2251 if (nKeptEvents != fNKeepRequests) {
2252 G4cout << " (Note: ";
2253 if (fNKeepRequests == 0) {
2254 G4cout << "No keep requests were";
2255 } else if (fNKeepRequests == 1) {
2256 G4cout << "1 keep request was";
2257 } else {
2258 G4cout << fNKeepRequests << " keep requests were";
2259 }
2260 G4cout << " made by the vis manager.";
2261 if (fNKeepRequests == 0) {
2262 G4cout <<
2263 "\n The kept events are those you have asked to be kept in your user action(s).)";
2264 } else {
2265 G4cout <<
2266 "\n The same or further events may have been kept by you in your user action(s).)";
2267 }
2268 G4cout << G4endl;
2269 }
2270 G4cout <<
2271 " \"/vis/reviewKeptEvents\" to review them one by one."
2272 "\n \"/vis/enable\", then \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
2273 << G4endl;
2274 }
2275
2276 // static G4bool warned = false;
2277 // if (!valid && fVerbosity >= warnings && !warned) {
2278 // G4cout <<
2279 // " Only useful if before starting the run:"
2280 // "\n a) trajectories are stored (\"/vis/scene/add/trajectories [smooth|rich]\"), or"
2281 // "\n b) the Draw method of any hits or digis is implemented."
2282 // "\n To view trajectories, hits or digis:"
2283 // "\n open a viewer, draw a volume, \"/vis/scene/add/trajectories\""
2284 // "\n \"/vis/scene/add/hits\" or \"/vis/scene/add/digitisations\""
2285 // "\n and, possibly, \"/vis/viewer/flush\"."
2286 // "\n To see all events: \"/vis/scene/endOfEventAction accumulate\"."
2287 // "\n (You may need \"/vis/viewer/flush\" or even \"/vis/viewer/rebuild\".)"
2288 // "\n To see events individually: \"/vis/reviewKeptEvents\"."
2289 // << G4endl;
2290 // warned = true;
2291 // }
2292
2294 G4cout <<
2295 "WARNING: G4VisManager::EndOfRun: Automatic event keeping was suspended."
2296 "\n The number of events in the run exceeded the maximum, "
2298 ", that may be\n kept by the vis manager." <<
2299 "\n The number of events kept by the vis manager can be changed with"
2300 "\n \"/vis/scene/endOfEventAction accumulate <N>\", where N is the"
2301 "\n maximum number you wish to allow. N < 0 means \"unlimited\"."
2302 << G4endl;
2303 }
2304
2305 // Don't call IsValidView unless there is a scene handler. This
2306 // avoids WARNING message at end of event and run when the user has
2307 // not instantiated a scene handler, e.g., in batch mode.
2308 G4bool valid = fpSceneHandler && IsValidView();
2309 if (GetConcreteInstance() && valid) {
2310// // ???? I can't remember why
2311// // if (!fpSceneHandler->GetMarkForClearingTransientStore()) {
2312// // is here. It prevents ShowView at end of run, which seems to be OK
2313// // for sequential mode, but MT mode seems to need it (I have not
2314// // figured out why). ???? JA ????
2315// if (!fpSceneHandler->GetMarkForClearingTransientStore()) {
2318 // An extra refresh for auto-refresh viewers.
2319 // ???? I DON'T WHY THIS IS NECESSARY ???? JA ????
2322 }
2323 // ShowView guarantees the view is flushed to the screen. It also
2324 // triggers other features such picking (if enabled) and allows
2325 // file-writing viewers to close the file.
2326 fpViewer->ShowView();
2328 } else {
2331 if (fVerbosity >= warnings) {
2332 G4cout << "\"/vis/viewer/update\" to close file." << G4endl;
2333 }
2334 }
2335 }
2336// }
2337 }
2338 fEventRefreshing = false;
2339}
2340
2342 // Assumes valid view.
2346 }
2347 // Record if transients drawn. These local flags are only set
2348 // *after* ClearTransientStore. In the code in G4VSceneHandler
2349 // triggered by ClearTransientStore, use these flags so that
2350 // event refreshing is not done too early.
2353}
2354
2356{
2360 for (i = fAvailableSceneHandlers.begin();
2361 i != fAvailableSceneHandlers.end(); ++i) {
2362 (*i)->SetTransientsDrawnThisEvent(false);
2363 (*i)->SetTransientsDrawnThisRun(false);
2364 }
2365}
2366
2368 G4String viewerShortName = viewerName.substr(0, viewerName.find (' '));
2369 return G4StrUtil::strip_copy(viewerShortName);
2370}
2371
2372G4VViewer* G4VisManager::GetViewer (const G4String& viewerName) const {
2373 G4String viewerShortName = ViewerShortName (viewerName);
2374 size_t nHandlers = fAvailableSceneHandlers.size ();
2375 size_t iHandler, iViewer;
2376 G4VViewer* viewer = 0;
2377 G4bool found = false;
2378 for (iHandler = 0; iHandler < nHandlers; iHandler++) {
2379 G4VSceneHandler* sceneHandler = fAvailableSceneHandlers [iHandler];
2380 const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
2381 for (iViewer = 0; iViewer < viewerList.size (); iViewer++) {
2382 viewer = viewerList [iViewer];
2383 if (viewerShortName == viewer -> GetShortName ()) {
2384 found = true;
2385 break;
2386 }
2387 }
2388 if (found) break;
2389 }
2390 if (found) return viewer;
2391 else return 0;
2392}
2393
2394std::vector<G4String> G4VisManager::VerbosityGuidanceStrings;
2395
2397 G4String rs;
2398 switch (verbosity) {
2399 case quiet: rs = "quiet (0)"; break;
2400 case startup: rs = "startup (1)"; break;
2401 case errors: rs = "errors (2)"; break;
2402 case warnings: rs = "warnings (3)"; break;
2403 case confirmations: rs = "confirmations (4)"; break;
2404 case parameters: rs = "parameters (5)"; break;
2405 case all: rs = "all (6)"; break;
2406 }
2407 return rs;
2408}
2409
2412 G4String ss = G4StrUtil::to_lower_copy(verbosityString);
2413 Verbosity verbosity;
2414 if (ss[0] == 'q') verbosity = quiet;
2415 else if (ss[0] == 's') verbosity = startup;
2416 else if (ss[0] == 'e') verbosity = errors;
2417 else if (ss[0] == 'w') verbosity = warnings;
2418 else if (ss[0] == 'c') verbosity = confirmations;
2419 else if (ss[0] == 'p') verbosity = parameters;
2420 else if (ss[0] == 'a') verbosity = all;
2421 else {
2422 G4int intVerbosity;
2423 std::istringstream is(ss);
2424 is >> intVerbosity;
2425 if (!is) {
2426 G4cerr << "ERROR: G4VisManager::GetVerbosityValue: invalid verbosity \""
2427 << verbosityString << "\"";
2428 for (size_t i = 0; i < VerbosityGuidanceStrings.size(); ++i) {
2429 G4cerr << '\n' << VerbosityGuidanceStrings[i];
2430 }
2431 verbosity = warnings;
2432 G4cerr << "\n Returning " << VerbosityString(verbosity)
2433 << G4endl;
2434 }
2435 else {
2436 verbosity = GetVerbosityValue(intVerbosity);
2437 }
2438 }
2439 return verbosity;
2440}
2441
2443 Verbosity verbosity;
2444 if (intVerbosity < quiet) verbosity = quiet;
2445 else if (intVerbosity > all) verbosity = all;
2446 else verbosity = Verbosity(intVerbosity);
2447 return verbosity;
2448}
2449
2451 return fVerbosity;
2452}
2453
2455 fVerbosity = GetVerbosityValue(intVerbosity);
2456}
2457
2458void G4VisManager::SetVerboseLevel (const G4String& verbosityString) {
2459 fVerbosity = GetVerbosityValue(verbosityString);
2460}
2461
2463
2464 if (!fInitialised) Initialise ();
2465
2466 static G4bool noGSPrinting = true;
2467 if (!fpGraphicsSystem) {
2468 // Limit printing - we do not want printing if the user simply does
2469 // not want to use graphics, e.g., in batch mode.
2470 if (noGSPrinting) {
2471 noGSPrinting = false;
2472 if (fVerbosity >= warnings) {
2473 G4cout <<
2474 "WARNING: G4VisManager::IsValidView(): Attempt to draw when no graphics system"
2475 "\n has been instantiated. Use \"/vis/open\" or \"/vis/sceneHandler/create\"."
2476 "\n Alternatively, to avoid this message, suppress instantiation of vis"
2477 "\n manager (G4VisExecutive) and ensure drawing code is executed only if"
2478 "\n G4VVisManager::GetConcreteInstance() is non-zero."
2479 << G4endl;
2480 }
2481 }
2482 return false;
2483 }
2484
2485 if ((!fpScene) || (!fpSceneHandler) || (!fpViewer)) {
2486 if (fVerbosity >= errors) {
2487 G4cerr <<
2488 "ERROR: G4VisManager::IsValidView(): Current view is not valid."
2489 << G4endl;
2491 }
2492 return false;
2493 }
2494
2495 if (fpScene != fpSceneHandler -> GetScene ()) {
2496 if (fVerbosity >= errors) {
2497 G4cerr << "ERROR: G4VisManager::IsValidView ():";
2498 if (fpSceneHandler -> GetScene ()) {
2499 G4cout <<
2500 "\n The current scene \""
2501 << fpScene -> GetName ()
2502 << "\" is not handled by"
2503 "\n the current scene handler \""
2504 << fpSceneHandler -> GetName ()
2505 << "\""
2506 "\n (it currently handles scene \""
2507 << fpSceneHandler -> GetScene () -> GetName ()
2508 << "\")."
2509 "\n Either:"
2510 "\n (a) attach it to the scene handler with"
2511 "\n /vis/sceneHandler/attach "
2512 << fpScene -> GetName ()
2513 << ", or"
2514 "\n (b) create a new scene handler with "
2515 "\n /vis/sceneHandler/create <graphics-system>,"
2516 "\n in which case it should pick up the the new scene."
2517 << G4endl;
2518 }
2519 else {
2520 G4cout << "\n Scene handler \""
2521 << fpSceneHandler -> GetName ()
2522 << "\" has null scene pointer."
2523 "\n Attach a scene with /vis/sceneHandler/attach [<scene-name>]"
2524 << G4endl;
2525 }
2526 }
2527 return false;
2528 }
2529
2530 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList ();
2531 if (viewerList.size () == 0) {
2532 if (fVerbosity >= errors) {
2533 G4cerr <<
2534 "ERROR: G4VisManager::IsValidView (): the current scene handler\n \""
2535 << fpSceneHandler -> GetName ()
2536 << "\" has no viewers. Do /vis/viewer/create."
2537 << G4endl;
2538 }
2539 return false;
2540 }
2541
2542 G4bool isValid = true;
2543 if (fpScene -> IsEmpty ()) { // Add world by default if possible...
2544 G4bool warn(fVerbosity >= warnings);
2545 G4bool successful = fpScene -> AddWorldIfEmpty (warn);
2546 if (!successful || fpScene -> IsEmpty ()) { // If still empty...
2547 if (fVerbosity >= errors) {
2548 G4cerr << "ERROR: G4VisManager::IsValidView ():";
2549 G4cerr <<
2550 "\n Attempt at some drawing operation when scene is empty."
2551 "\n Maybe the geometry has not yet been defined."
2552 " Try /run/initialize."
2553 "\n Or use \"/vis/scene/add/extent\"."
2554 << G4endl;
2555 }
2556 isValid = false;
2557 }
2558 else {
2559 G4UImanager::GetUIpointer()->ApplyCommand ("/vis/scene/notifyHandlers");
2560 if (fVerbosity >= warnings) {
2561 G4cout <<
2562 "WARNING: G4VisManager: the scene was empty, \"world\" has been"
2563 "\n added and the scene handlers notified.";
2564 G4cout << G4endl;
2565 }
2566 }
2567 }
2568 return isValid;
2569}
2570
2571void
2573{
2574 if (fVerbosity >= warnings) {
2575 G4cout<<"G4VisManager: No model factories registered with G4VisManager."<<G4endl;
2576 G4cout<<"G4VisManager::RegisterModelFactories() should be overridden in derived"<<G4endl;
2577 G4cout<<"class. See G4VisExecutive for an example."<<G4endl;
2578 }
2579}
2580
2581#ifdef G4MULTITHREADED
2582void G4VisManager::SetUpForAThread()
2583{
2584 new G4VisStateDependent(this);
2585}
2586#endif
2587
2589{
2590 fIgnoreStateChanges = val;
2591}
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::vector< G4VSceneHandler * >::const_iterator G4SceneHandlerListConstIterator
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:251
#define G4THREADJOIN(worker)
Definition: G4Threading.hh:259
void G4THREADCREATE(_Worker *&worker, _Func func, _Args... args)
Definition: G4Threading.hh:268
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:254
G4DummyThread G4Thread
Definition: G4Threading.hh:247
void * G4ThreadFunReturnType
Definition: G4Threading.hh:110
void * G4ThreadFunArgType
Definition: G4Threading.hh:111
std::mutex G4Mutex
Definition: G4Threading.hh:81
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define TOOLS_COLORS_STAT(name, r, g, b)
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static void InitialiseColourMap()
Definition: G4Colour.cc:141
static const std::map< G4String, G4Colour > & GetMap()
Definition: G4Colour.cc:178
void KeepTheCurrentEvent()
const G4Event * GetConstCurrentEvent()
static G4EventManager * GetEventManager()
G4bool ToBeKept() const
Definition: G4Event.hh:102
G4int GetEventID() const
Definition: G4Event.hh:118
void KeepForPostProcessing() const
Definition: G4Event.hh:104
static pool_type * GetPool()
G4VSolid * GetSolid() const
static G4RunManager * GetMasterRunManager()
static G4RunManagerKernel * GetMasterRunManagerKernel()
static G4RunManagerKernel * GetRunManagerKernel()
G4TrackingManager * GetTrackingManager() const
G4int GetNumberOfEventsToBeProcessed() const
static G4RunManager * GetRunManager()
const G4Run * GetCurrentRun() const
Definition: G4Run.hh:49
G4int GetRunID() const
Definition: G4Run.hh:78
const std::vector< const G4Event * > * GetEventVector() const
Definition: G4Run.hh:96
void CalculateExtent()
Definition: G4Scene.cc:62
G4bool GetRefreshAtEndOfEvent() const
const G4String & GetName() const
G4bool GetRefreshAtEndOfRun() const
G4int GetMaxNumberOfKeptEvents() const
static pool_type * GetPool()
Definition: G4Text.hh:72
G4int GetStoreTrajectory() const
void SetCurrentTrajectory(const G4VTrajectory *pTraj)
void SetEventID(G4int eventID)
void SetRunID(G4int runID)
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:727
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
void SetUpForSpecialThread(G4String aPrefix)
Definition: G4UImanager.cc:869
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
Functionality GetFunctionality() const
Definition: G4VHit.hh:48
G4LogicalVolume * GetLogicalVolume() const
virtual void ClearTransientStore()
G4bool GetTransientsDrawnThisEvent() const
void SetTransientsDrawnThisRun(G4bool)
void DrawEvent(const G4Event *)
void SetMarkForClearingTransientStore(G4bool)
G4Scene * GetScene() const
void SetTransientsDrawnThisEvent(G4bool)
const G4Transform3D & GetObjectTransformation() const
G4bool GetTransientsDrawnThisRun() const
virtual void ClearStore()
G4bool GetMarkForClearingTransientStore() const
virtual void DescribeYourselfTo(G4VGraphicsScene &scene) const =0
virtual void Draw(const G4VTrajectory &trajectory, const G4bool &visible=true) const =0
const G4ViewParameters & GetViewParameters() const
void NeedKernelVisit()
Definition: G4VViewer.cc:78
virtual void FinishView()
Definition: G4VViewer.cc:101
void RefreshView()
virtual void ClearView()=0
virtual void ShowView()
Definition: G4VViewer.cc:103
virtual void SetView()=0
static void SetVisManager(G4VisManager *pVisManager)
static G4VVisManager * GetConcreteInstance()
static void SetConcreteInstance(G4VVisManager *)
void SetXGeometryString(const G4String &)
G4bool IsCulling() const
G4bool IsCullingInvisible() const
G4bool IsAutoRefresh() const
G4bool IsCullingCovered() const
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
bool Accept(const T &)
FilterMode::Mode GetMode() const
G4String Placement() const
const std::vector< Filter * > & FilterList() const
const std::vector< Factory * > & FactoryList() const
const std::map< G4String, T * > & Map() const
const T * Current() const
std::vector< G4UImessenger * > fMessengerList
void SelectTrajectoryModel(const G4String &model)
void RegisterRunDurationUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
void SetCurrentGraphicsSystem(G4VGraphicsSystem *)
G4bool fEventRefreshing
void Draw2D(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
static G4VisManager * fpInstance
G4bool fEventKeepingSuspended
std::vector< G4UIcommand * > fDirectoryList
virtual void RegisterGraphicsSystems()=0
G4GraphicsSystemList fAvailableGraphicsSystems
G4bool IsValidView()
void InitialiseG4ColourMap() const
void BeginDraw2D(const G4Transform3D &objectTransformation=G4Transform3D())
void CreateSceneHandler(const G4String &name="")
void DrawT2D(const T &graphics_primitive, const G4Transform3D &objectTransform)
G4VSceneHandler * fpSceneHandler
void SetCurrentSceneHandler(G4VSceneHandler *)
void ClearTransientStoreIfMarked()
void PrintAvailableModels(Verbosity) const
const G4VTrajectoryModel * CurrentTrajDrawModel() const
G4int fNoOfEventsDrawnThisRun
void BeginOfEvent()
static Verbosity fVerbosity
G4bool FilterDigi(const G4VDigi &)
void SetTransientsDrawnThisEvent(G4bool)
void SetCurrentScene(G4Scene *)
static std::vector< G4String > VerbosityGuidanceStrings
static G4String VerbosityString(Verbosity)
void RegisterEndOfEventUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
G4VisFilterManager< G4VHit > * fpHitFilterMgr
G4String ViewerShortName(const G4String &viewerName) const
G4VisModelManager< G4VTrajectoryModel > * fpTrajDrawModelMgr
void RegisterModel(G4VTrajectoryModel *model)
void RegisterMessenger(G4UImessenger *messenger)
void SetCurrentViewer(G4VViewer *)
void DrawT(const T &graphics_primitive, const G4Transform3D &objectTransform)
G4VViewer * fpViewer
std::vector< UserVisAction > fRunDurationUserVisActions
G4VisFilterManager< G4VTrajectory > * fpTrajFilterMgr
void RegisterModelFactory(G4TrajDrawModelFactory *factory)
void EndDraw2D()
G4bool FilterHit(const G4VHit &)
G4int fNKeepRequests
std::map< G4VUserVisAction *, G4VisExtent > fUserVisActionExtents
std::vector< UserVisAction > fEndOfRunUserVisActions
G4bool fIgnoreStateChanges
G4VViewer * GetCurrentViewer() const
G4bool RegisterGraphicsSystem(G4VGraphicsSystem *)
void PrintAvailableGraphicsSystems(Verbosity) const
G4VisFilterManager< G4VDigi > * fpDigiFilterMgr
virtual void RegisterModelFactories()
virtual ~G4VisManager()
G4int fDrawGroupNestingDepth
G4VSceneHandler * GetCurrentSceneHandler() const
static Verbosity GetVerbosity()
void Initialise()
void RegisterMessengers()
G4VisStateDependent * fpStateDependent
void ResetTransientsDrawnFlags()
std::vector< UserVisAction > fEndOfEventUserVisActions
G4bool FilterTrajectory(const G4VTrajectory &)
void PrintAvailableColours(Verbosity) const
void SetVerboseLevel(G4int)
void PrintAvailableUserVisActions(Verbosity) const
void IgnoreStateChanges(G4bool)
friend class G4VisStateDependent
void NotifyHandlers()
G4bool fDrawEventOnlyIfToBeKept
G4bool fIsDrawGroup
void PrintInvalidPointers() const
G4VisManager(const G4String &verbosityString="warnings")
Definition: G4VisManager.cc:98
G4SceneHandlerList fAvailableSceneHandlers
static Verbosity GetVerbosityValue(const G4String &)
static G4VisManager * GetInstance()
void GeometryHasChanged()
const G4GraphicsSystemList & GetAvailableGraphicsSystems()
G4VGraphicsSystem * fpGraphicsSystem
G4bool fTransientsDrawnThisEvent
void RegisterEndOfRunUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
G4SceneList fSceneList
void BeginDraw(const G4Transform3D &objectTransformation=G4Transform3D())
void CreateViewer(const G4String &name="", const G4String &XGeometry="")
void DispatchToModel(const G4VTrajectory &)
G4bool fInitialised
G4bool fTransientsDrawnThisRun
G4Scene * fpScene
G4VViewer * GetViewer(const G4String &viewerName) const
const List * ListManager() const
const Model * Current() const
void SetCurrent(const G4String &)
void Register(Model *)
const std::vector< Factory * > & FactoryList() const
G4String Placement() const
const G4double al
Mysterious coefficient that appears in the wavefunctions.
const char * name(G4int ptype)
G4String to_lower_copy(G4String str)
Return lowercased copy of string.
G4String strip_copy(G4String str, char c=' ')
Return copy of string with leading and trailing characters removed.
G4bool IsWorkerThread()
Definition: G4Threading.cc:123
G4bool IsMultithreadedApplication()
Definition: G4Threading.cc:130
Definition: run.py:1
factory
Definition: test.py:55