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