Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: G4VisManager.cc,v 1.131 2010-12-14 15:53:28 gcosmo Exp $ >> 27 // GEANT4 tag $Name: not supported by cvs2svn $ 26 // 28 // 27 // 29 // 28 // GEANT4 Visualization Manager - John Allison 30 // GEANT4 Visualization Manager - John Allison 02/Jan/1996. 29 // Michael Kelsey 31 Jan 2019 -- Add new comm << 30 31 31 #include "G4VisManager.hh" 32 #include "G4VisManager.hh" 32 33 33 #include "G4VisCommands.hh" 34 #include "G4VisCommands.hh" 34 #include "G4VisCommandsCompound.hh" 35 #include "G4VisCommandsCompound.hh" 35 #include "G4VisCommandsGeometry.hh" 36 #include "G4VisCommandsGeometry.hh" 36 #include "G4VisCommandsGeometrySet.hh" 37 #include "G4VisCommandsGeometrySet.hh" 37 #include "G4VisCommandsMultithreading.hh" << 38 #include "G4VisCommandsSet.hh" << 39 #include "G4VisCommandsScene.hh" 38 #include "G4VisCommandsScene.hh" 40 #include "G4VisCommandsSceneAdd.hh" 39 #include "G4VisCommandsSceneAdd.hh" 41 #include "G4VisCommandsPlotter.hh" << 42 #include "G4VisCommandsSceneHandler.hh" 40 #include "G4VisCommandsSceneHandler.hh" 43 #include "G4VisCommandsTouchable.hh" << 44 #include "G4VisCommandsTouchableSet.hh" << 45 #include "G4VisCommandsViewer.hh" 41 #include "G4VisCommandsViewer.hh" 46 #include "G4VisCommandsViewerDefault.hh" << 47 #include "G4VisCommandsViewerSet.hh" 42 #include "G4VisCommandsViewerSet.hh" 48 #include "G4UImanager.hh" 43 #include "G4UImanager.hh" 49 #include "G4VisStateDependent.hh" 44 #include "G4VisStateDependent.hh" 50 #include "G4UIdirectory.hh" 45 #include "G4UIdirectory.hh" >> 46 #include "G4VisFeaturesOfFukuiRenderer.hh" >> 47 #include "G4VisFeaturesOfDAWNFILE.hh" >> 48 #include "G4VisFeaturesOfOpenGL.hh" >> 49 #include "G4VisFeaturesOfOpenInventor.hh" 51 #include "G4VGraphicsSystem.hh" 50 #include "G4VGraphicsSystem.hh" 52 #include "G4VSceneHandler.hh" 51 #include "G4VSceneHandler.hh" 53 #include "G4VViewer.hh" 52 #include "G4VViewer.hh" 54 #include "G4VPhysicalVolume.hh" 53 #include "G4VPhysicalVolume.hh" 55 #include "G4LogicalVolume.hh" 54 #include "G4LogicalVolume.hh" 56 #include "G4VSolid.hh" 55 #include "G4VSolid.hh" 57 #include "G4Vector3D.hh" 56 #include "G4Vector3D.hh" 58 #include "G4Point3D.hh" 57 #include "G4Point3D.hh" 59 #include "G4RotationMatrix.hh" 58 #include "G4RotationMatrix.hh" 60 #include "G4Polyline.hh" 59 #include "G4Polyline.hh" 61 #include "G4Polyhedron.hh" 60 #include "G4Polyhedron.hh" >> 61 #include "G4NURBS.hh" 62 #include "G4NullModel.hh" 62 #include "G4NullModel.hh" 63 #include "G4ModelingParameters.hh" 63 #include "G4ModelingParameters.hh" 64 #include "G4TransportationManager.hh" 64 #include "G4TransportationManager.hh" 65 #include "G4VisCommandModelCreate.hh" 65 #include "G4VisCommandModelCreate.hh" 66 #include "G4VisCommandsListManager.hh" 66 #include "G4VisCommandsListManager.hh" 67 #include "G4VisModelManager.hh" 67 #include "G4VisModelManager.hh" 68 #include "G4VModelFactory.hh" 68 #include "G4VModelFactory.hh" 69 #include "G4VisFilterManager.hh" 69 #include "G4VisFilterManager.hh" 70 #include "G4VTrajectoryModel.hh" 70 #include "G4VTrajectoryModel.hh" 71 #include "G4TrajectoryDrawByCharge.hh" 71 #include "G4TrajectoryDrawByCharge.hh" 72 #include "Randomize.hh" 72 #include "Randomize.hh" 73 #include "G4RunManager.hh" 73 #include "G4RunManager.hh" 74 #include "G4RunManagerFactory.hh" << 75 #include "G4EventManager.hh" 74 #include "G4EventManager.hh" 76 #include "G4Run.hh" 75 #include "G4Run.hh" 77 #include "G4Event.hh" 76 #include "G4Event.hh" 78 #include <map> << 79 #include <set> << 80 #include <vector> << 81 #include <sstream> 77 #include <sstream> 82 78 83 #include "G4Threading.hh" << 84 #include "G4AutoLock.hh" << 85 #include "G4GeometryWorkspace.hh" // no_geant4 << 86 #include "G4SolidsWorkspace.hh" << 87 #include <deque> << 88 #include <typeinfo> << 89 #include <chrono> << 90 #include <thread> << 91 #include <utility> << 92 << 93 #define G4warn G4cout << 94 << 95 // Local threading related variables << 96 namespace { << 97 G4bool mtRunInProgress = false; << 98 std::deque<const G4Event*> mtVisEventQueue; << 99 G4Thread* mtVisSubThread = 0; << 100 [[maybe_unused]] G4Mutex mtVisSubThreadMutex << 101 // G4Mutex visBeginOfRunMutex = G4MUTEX_INI << 102 // G4Mutex visBeginOfEventMutex = G4MUTEX_I << 103 G4Mutex visEndOfEventMutex = G4MUTEX_INITIAL << 104 // G4Mutex visEndOfRunMutex = G4MUTEX_INITI << 105 G4bool isSubEventRunManagerType = false; << 106 G4bool isValidViewForRun = false; << 107 G4bool isFakeRun = false; << 108 } << 109 << 110 // Class statics << 111 G4VisManager* G4VisManager::fpInstance = 0; 79 G4VisManager* G4VisManager::fpInstance = 0; 112 80 113 G4VisManager::Verbosity G4VisManager::fVerbosi 81 G4VisManager::Verbosity G4VisManager::fVerbosity = G4VisManager::warnings; 114 82 115 G4VisManager::G4VisManager (const G4String& ve << 83 G4VisManager::G4VisManager (const G4String& verbosityString): 116 : fVerbose (1) << 84 fVerbose (1), 117 , fDefaultGraphicsSystemName("OGL") / << 85 fInitialised (false), 118 , fDefaultXGeometryString ("600x600-0+0") / << 86 fpUserVisAction (0), 119 , fDefaultGraphicsSystemBasis ("G4VisManager i << 87 fpGraphicsSystem (0), 120 , fDefaultXGeometryStringBasis("G4VisManager i << 88 fpScene (0), 121 , fInitialised (false) << 89 fpSceneHandler (0), 122 , fpGraphicsSystem (0) << 90 fpViewer (0), 123 , fpScene (0) << 91 fpStateDependent (0), 124 , fpSceneHandler (0) << 92 fEventRefreshing (false), 125 , fpViewer (0) << 93 fTransientsDrawnThisRun (false), 126 , fpStateDependent (0) << 94 fTransientsDrawnThisEvent (false), 127 , fEventRefreshing (false) << 95 fEventKeepingSuspended (false), 128 , fTransientsDrawnThisRun (false) << 96 fKeptLastEvent (false), 129 , fTransientsDrawnThisEvent (false) << 97 fpRequestedEvent (0), 130 , fNoOfEventsDrawnThisRun (0) << 98 fAbortReviewKeptEvents (false) 131 , fNKeepForPostProcessingRequests (0) << 99 // All other objects use default constructors. 132 , fNKeepTheEventRequests (0) << 133 , fEventKeepingSuspended (false) << 134 , fDrawEventOnlyIfToBeKept (false) << 135 , fpRequestedEvent (0) << 136 , fReviewingKeptEvents (false) << 137 , fAbortReviewKeptEvents (false) << 138 , fReviewingPlots (false) << 139 , fAbortReviewPlots (false) << 140 , fIsDrawGroup (false) << 141 , fDrawGroupNestingDepth (0) << 142 , fIgnoreStateChanges (false) << 143 , fMaxEventQueueSize (100) << 144 , fWaitOnEventQueueFull (true) << 145 // All other objects use default constructors. << 146 { 100 { 147 fpTrajDrawModelMgr = new G4VisModelManager<G 101 fpTrajDrawModelMgr = new G4VisModelManager<G4VTrajectoryModel>("/vis/modeling/trajectories"); 148 fpTrajFilterMgr = new G4VisFilterManager<G4V 102 fpTrajFilterMgr = new G4VisFilterManager<G4VTrajectory>("/vis/filtering/trajectories"); 149 fpHitFilterMgr = new G4VisFilterManager<G4VH 103 fpHitFilterMgr = new G4VisFilterManager<G4VHit>("/vis/filtering/hits"); 150 fpDigiFilterMgr = new G4VisFilterManager<G4V 104 fpDigiFilterMgr = new G4VisFilterManager<G4VDigi>("/vis/filtering/digi"); 151 105 152 VerbosityGuidanceStrings.push_back 106 VerbosityGuidanceStrings.push_back 153 ("Simple graded message scheme - digit or 107 ("Simple graded message scheme - digit or string (1st character defines):"); 154 VerbosityGuidanceStrings.push_back 108 VerbosityGuidanceStrings.push_back 155 (" 0) quiet, // Nothing is printe 109 (" 0) quiet, // Nothing is printed."); 156 VerbosityGuidanceStrings.push_back 110 VerbosityGuidanceStrings.push_back 157 (" 1) startup, // Startup and endup 111 (" 1) startup, // Startup and endup messages are printed..."); 158 VerbosityGuidanceStrings.push_back 112 VerbosityGuidanceStrings.push_back 159 (" 2) errors, // ...and errors..." 113 (" 2) errors, // ...and errors..."); 160 VerbosityGuidanceStrings.push_back 114 VerbosityGuidanceStrings.push_back 161 (" 3) warnings, // ...and warnings.. 115 (" 3) warnings, // ...and warnings..."); 162 VerbosityGuidanceStrings.push_back 116 VerbosityGuidanceStrings.push_back 163 (" 4) confirmations, // ...and confirming 117 (" 4) confirmations, // ...and confirming messages..."); 164 VerbosityGuidanceStrings.push_back 118 VerbosityGuidanceStrings.push_back 165 (" 5) parameters, // ...and parameters 119 (" 5) parameters, // ...and parameters of scenes and views..."); 166 VerbosityGuidanceStrings.push_back 120 VerbosityGuidanceStrings.push_back 167 (" 6) all // ...and everything 121 (" 6) all // ...and everything available."); 168 122 169 if (fpInstance) { 123 if (fpInstance) { 170 G4Exception 124 G4Exception 171 ("G4VisManager::G4VisManager", << 125 ("G4VisManager: attempt to Construct more than one VisManager."); 172 "visman0001", FatalException, << 173 "Attempt to Construct more than one Vis << 174 } 126 } 175 127 176 fpInstance = this; 128 fpInstance = this; 177 SetConcreteInstance(this); 129 SetConcreteInstance(this); 178 130 179 fpStateDependent = new G4VisStateDependent ( 131 fpStateDependent = new G4VisStateDependent (this); 180 // No need to delete this; G4StateManager do 132 // No need to delete this; G4StateManager does this. 181 133 182 fVerbosity = GetVerbosityValue(verbosityStri 134 fVerbosity = GetVerbosityValue(verbosityString); 183 if (fVerbosity >= startup) { 135 if (fVerbosity >= startup) { 184 G4cout 136 G4cout 185 << "Visualization Manager instantiating with 137 << "Visualization Manager instantiating with verbosity \"" 186 << VerbosityString(fVerbosity) 138 << VerbosityString(fVerbosity) 187 << "\"..." << G4endl; 139 << "\"..." << G4endl; 188 } 140 } 189 141 190 // Note: The specific graphics systems must 142 // Note: The specific graphics systems must be instantiated in a 191 // higher level library to avoid circular de 143 // higher level library to avoid circular dependencies. Also, 192 // some specifically need additional externa 144 // some specifically need additional external libararies that the 193 // user must supply. Therefore we ask the u 145 // user must supply. Therefore we ask the user to implement 194 // RegisterGraphicsSystems() and RegisterMod 146 // RegisterGraphicsSystems() and RegisterModelFactories() 195 // in a subclass. We have to wait for the s 147 // in a subclass. We have to wait for the subclass to instantiate 196 // so RegisterGraphicsSystems() cannot be ca 148 // so RegisterGraphicsSystems() cannot be called from this 197 // constructor; it is called from Initialise 149 // constructor; it is called from Initialise(). So we ask the 198 // user: 150 // user: 199 // (a) to write a subclass and implement 151 // (a) to write a subclass and implement RegisterGraphicsSystems() 200 // and RegisterModelFactories(). See 152 // and RegisterModelFactories(). See 201 // visualization/include/G4VisExecutiv 153 // visualization/include/G4VisExecutive.hh/icc as an example. 202 // (b) instantiate the subclass. 154 // (b) instantiate the subclass. 203 // (c) invoke the Initialise() method of t 155 // (c) invoke the Initialise() method of the subclass. 204 // For example: 156 // For example: 205 // ... 157 // ... >> 158 // #ifdef G4VIS_USE 206 // // Instantiate and initialise Visualiza 159 // // Instantiate and initialise Visualization Manager. 207 // G4VisManager* visManager = new G4VisExe 160 // G4VisManager* visManager = new G4VisExecutive; 208 // visManager -> SetVerboseLevel (Verbose) 161 // visManager -> SetVerboseLevel (Verbose); 209 // visManager -> Initialise (); 162 // visManager -> Initialise (); >> 163 // #endif 210 // // (Don't forget to delete visManager;) 164 // // (Don't forget to delete visManager;) 211 // ... 165 // ... 212 166 213 // Make top level command directory... 167 // Make top level command directory... 214 // vis commands should *not* be broadcast to << 168 G4UIcommand* directory; 215 G4bool propagateToWorkers; << 169 directory = new G4UIdirectory ("/vis/"); 216 auto directory = new G4UIdirectory ("/vis/", << 217 directory -> SetGuidance ("Visualization com 170 directory -> SetGuidance ("Visualization commands."); 218 // Request commands in name order << 219 directory -> Sort(); // Ordering propagates << 220 fDirectoryList.push_back (directory); 171 fDirectoryList.push_back (directory); 221 172 222 // Instantiate *basic* top level commands so << 173 // Instantiate top level basic commands 223 // immediately after instantiation of the vi << 224 // level and lower level commands are instan << 225 // RegisterMessengers. << 226 G4VVisCommand::SetVisManager (this); // Set 174 G4VVisCommand::SetVisManager (this); // Sets shared pointer 227 RegisterMessenger(new G4VisCommandVerbose); 175 RegisterMessenger(new G4VisCommandVerbose); 228 RegisterMessenger(new G4VisCommandInitialize 176 RegisterMessenger(new G4VisCommandInitialize); 229 } 177 } 230 178 231 G4VisManager::~G4VisManager() << 179 G4VisManager::~G4VisManager () { 232 { << 180 fpInstance = 0; 233 G4UImanager* UImanager = G4UImanager::GetUIp << 181 size_t i; 234 UImanager->SetCoutDestination(nullptr); << 235 std::size_t i; << 236 for (i = 0; i < fSceneList.size (); ++i) { 182 for (i = 0; i < fSceneList.size (); ++i) { 237 delete fSceneList[i]; 183 delete fSceneList[i]; 238 } 184 } 239 for (i = 0; i < fAvailableSceneHandlers.size 185 for (i = 0; i < fAvailableSceneHandlers.size (); ++i) { 240 if (fAvailableSceneHandlers[i] != NULL) { 186 if (fAvailableSceneHandlers[i] != NULL) { 241 delete fAvailableSceneHandlers[i]; 187 delete fAvailableSceneHandlers[i]; 242 } 188 } 243 } 189 } 244 for (i = 0; i < fAvailableGraphicsSystems.si 190 for (i = 0; i < fAvailableGraphicsSystems.size (); ++i) { 245 if (fAvailableGraphicsSystems[i]) { 191 if (fAvailableGraphicsSystems[i]) { 246 delete fAvailableGraphicsSystems[i]; 192 delete fAvailableGraphicsSystems[i]; 247 } 193 } 248 } 194 } 249 if (fVerbosity >= startup) { 195 if (fVerbosity >= startup) { 250 G4cout << "Graphics systems deleted." << G 196 G4cout << "Graphics systems deleted." << G4endl; 251 G4cout << "Visualization Manager deleting. 197 G4cout << "Visualization Manager deleting..." << G4endl; 252 } 198 } 253 for (i = 0; i < fMessengerList.size (); ++i) 199 for (i = 0; i < fMessengerList.size (); ++i) { 254 delete fMessengerList[i]; 200 delete fMessengerList[i]; 255 } 201 } 256 for (i = 0; i < fDirectoryList.size (); ++i) 202 for (i = 0; i < fDirectoryList.size (); ++i) { 257 delete fDirectoryList[i]; 203 delete fDirectoryList[i]; 258 } 204 } 259 205 260 delete fpDigiFilterMgr; 206 delete fpDigiFilterMgr; 261 delete fpHitFilterMgr; 207 delete fpHitFilterMgr; 262 delete fpTrajFilterMgr; 208 delete fpTrajFilterMgr; 263 delete fpTrajDrawModelMgr; 209 delete fpTrajDrawModelMgr; 264 fpInstance = 0; << 265 } 210 } 266 211 267 G4VisManager* G4VisManager::GetInstance () { 212 G4VisManager* G4VisManager::GetInstance () { 268 if (!fpInstance) { 213 if (!fpInstance) { 269 G4Exception 214 G4Exception 270 ("G4VisManager::GetInstance", << 215 ("G4VisManager::GetInstance: VisManager not yet instantiated!"); 271 "visman0002", FatalException, "VisManag << 272 } 216 } 273 return fpInstance; 217 return fpInstance; 274 } 218 } 275 219 276 void G4VisManager::Initialise () { 220 void G4VisManager::Initialise () { 277 221 278 if (fInitialised && fVerbosity >= warnings) 222 if (fInitialised && fVerbosity >= warnings) { 279 G4warn << "WARNING: G4VisManager::Initiali << 223 G4cout << "WARNING: G4VisManager::Initialise: already initialised." 280 << G4endl; 224 << G4endl; 281 return; 225 return; 282 } 226 } 283 227 284 if (fVerbosity >= startup) { 228 if (fVerbosity >= startup) { 285 G4cout << "Visualization Manager initialis 229 G4cout << "Visualization Manager initialising..." << G4endl; 286 } 230 } 287 231 288 if (fVerbosity >= parameters) { 232 if (fVerbosity >= parameters) { 289 G4cout << 233 G4cout << 290 "\nYou have instantiated your own Visual 234 "\nYou have instantiated your own Visualization Manager, inheriting" 291 "\n G4VisManager and implementing Regis 235 "\n G4VisManager and implementing RegisterGraphicsSystems(), in which" 292 "\n you should, normally, instantiate d 236 "\n you should, normally, instantiate drivers which do not need" 293 "\n external packages or libraries, and 237 "\n external packages or libraries, and, optionally, drivers under" 294 "\n control of environment variables." 238 "\n control of environment variables." 295 "\n Also you should implement RegisterM 239 "\n Also you should implement RegisterModelFactories()." 296 "\n See visualization/management/includ << 240 "\n See visualization/include/G4VisExecutive.hh/icc, for example." 297 "\n In your main() you will have someth 241 "\n In your main() you will have something like:" >> 242 "\n #ifdef G4VIS_USE" 298 "\n G4VisManager* visManager = new G4 243 "\n G4VisManager* visManager = new G4VisExecutive;" 299 "\n visManager -> SetVerboseLevel (Ve 244 "\n visManager -> SetVerboseLevel (Verbose);" 300 "\n visManager -> Initialize ();" 245 "\n visManager -> Initialize ();" >> 246 "\n #endif" 301 "\n (Don't forget to delete visManager; 247 "\n (Don't forget to delete visManager;)" 302 "\n" 248 "\n" 303 << G4endl; 249 << G4endl; 304 } 250 } 305 251 306 if (fVerbosity >= startup) { 252 if (fVerbosity >= startup) { 307 G4cout << "Registering graphics systems... 253 G4cout << "Registering graphics systems..." << G4endl; 308 } 254 } 309 255 310 RegisterGraphicsSystems (); 256 RegisterGraphicsSystems (); 311 257 312 if (fVerbosity >= startup) { 258 if (fVerbosity >= startup) { 313 G4cout << 259 G4cout << 314 "\nYou have successfully registered the 260 "\nYou have successfully registered the following graphics systems." 315 << G4endl; 261 << G4endl; 316 PrintAvailableGraphicsSystems (fVerbosity) << 262 PrintAvailableGraphicsSystems (); 317 G4cout << G4endl; 263 G4cout << G4endl; 318 } 264 } 319 265 320 // Make command directories for commands ins 266 // Make command directories for commands instantiated in the 321 // modeling subcategory... 267 // modeling subcategory... 322 G4UIcommand* directory; 268 G4UIcommand* directory; 323 directory = new G4UIdirectory ("/vis/modelin 269 directory = new G4UIdirectory ("/vis/modeling/"); 324 directory -> SetGuidance ("Modeling commands 270 directory -> SetGuidance ("Modeling commands."); 325 fDirectoryList.push_back (directory); 271 fDirectoryList.push_back (directory); 326 directory = new G4UIdirectory ("/vis/modelin 272 directory = new G4UIdirectory ("/vis/modeling/trajectories/"); 327 directory -> SetGuidance ("Trajectory model 273 directory -> SetGuidance ("Trajectory model commands."); 328 fDirectoryList.push_back (directory); 274 fDirectoryList.push_back (directory); 329 directory = new G4UIdirectory ("/vis/modelin 275 directory = new G4UIdirectory ("/vis/modeling/trajectories/create/"); 330 directory -> SetGuidance ("Create trajectory 276 directory -> SetGuidance ("Create trajectory models and messengers."); 331 fDirectoryList.push_back (directory); 277 fDirectoryList.push_back (directory); 332 278 333 // Filtering command directory 279 // Filtering command directory 334 directory = new G4UIdirectory ("/vis/filteri 280 directory = new G4UIdirectory ("/vis/filtering/"); 335 directory -> SetGuidance ("Filtering command 281 directory -> SetGuidance ("Filtering commands."); 336 fDirectoryList.push_back (directory); 282 fDirectoryList.push_back (directory); 337 directory = new G4UIdirectory ("/vis/filteri 283 directory = new G4UIdirectory ("/vis/filtering/trajectories/"); 338 directory -> SetGuidance ("Trajectory filter 284 directory -> SetGuidance ("Trajectory filtering commands."); 339 fDirectoryList.push_back (directory); 285 fDirectoryList.push_back (directory); 340 directory = new G4UIdirectory ("/vis/filteri 286 directory = new G4UIdirectory ("/vis/filtering/trajectories/create/"); 341 directory -> SetGuidance ("Create trajectory 287 directory -> SetGuidance ("Create trajectory filters and messengers."); 342 fDirectoryList.push_back (directory); 288 fDirectoryList.push_back (directory); 343 directory = new G4UIdirectory ("/vis/filteri 289 directory = new G4UIdirectory ("/vis/filtering/hits/"); 344 directory -> SetGuidance ("Hit filtering com 290 directory -> SetGuidance ("Hit filtering commands."); 345 fDirectoryList.push_back (directory); 291 fDirectoryList.push_back (directory); 346 directory = new G4UIdirectory ("/vis/filteri 292 directory = new G4UIdirectory ("/vis/filtering/hits/create/"); 347 directory -> SetGuidance ("Create hit filter 293 directory -> SetGuidance ("Create hit filters and messengers."); 348 fDirectoryList.push_back (directory); 294 fDirectoryList.push_back (directory); 349 directory = new G4UIdirectory ("/vis/filteri 295 directory = new G4UIdirectory ("/vis/filtering/digi/"); 350 directory -> SetGuidance ("Digi filtering co 296 directory -> SetGuidance ("Digi filtering commands."); 351 fDirectoryList.push_back (directory); 297 fDirectoryList.push_back (directory); 352 directory = new G4UIdirectory ("/vis/filteri 298 directory = new G4UIdirectory ("/vis/filtering/digi/create/"); 353 directory -> SetGuidance ("Create digi filte 299 directory -> SetGuidance ("Create digi filters and messengers."); 354 fDirectoryList.push_back (directory); 300 fDirectoryList.push_back (directory); 355 301 356 RegisterMessengers (); 302 RegisterMessengers (); 357 303 358 if (fVerbosity >= startup) { 304 if (fVerbosity >= startup) { 359 G4cout << "Registering model factories..." 305 G4cout << "Registering model factories..." << G4endl; 360 } 306 } 361 307 362 RegisterModelFactories(); 308 RegisterModelFactories(); 363 309 364 if (fVerbosity >= startup) { 310 if (fVerbosity >= startup) { 365 G4cout << 311 G4cout << 366 "\nYou have successfully registered the 312 "\nYou have successfully registered the following model factories." 367 << G4endl; << 313 << G4endl; 368 PrintAvailableModels (fVerbosity); 314 PrintAvailableModels (fVerbosity); 369 G4cout << G4endl; 315 G4cout << G4endl; 370 } 316 } 371 317 372 if (fVerbosity >= startup) { << 373 PrintAvailableUserVisActions (fVerbosity); << 374 G4cout << G4endl; << 375 } << 376 << 377 InitialiseG4ColourMap(); << 378 << 379 if (fVerbosity >= startup) { << 380 G4cout << << 381 "Some /vis commands (optionally) take a st << 382 "\n\"/vis/list\" to see available colours. << 383 << G4endl; << 384 } << 385 << 386 fInitialised = true; 318 fInitialised = true; 387 } 319 } 388 320 389 void G4VisManager::InitialiseG4ColourMap() con << 390 { << 391 G4Colour::InitialiseColourMap(); // Initial << 392 << 393 // our forever 65 named colors taken long ti << 394 // Extracted from g4tools/include/tools/colo << 395 // Copyright (C) 2010, Guy Barrand. All righ << 396 // See the file tools.license for terms. << 397 << 398 #define TOOLS_COLORS_STAT(name,r,g,b) \ << 399 G4Colour::AddToMap(#name, G4Colour(r,g,b)); << 400 << 401 //0-9 << 402 TOOLS_COLORS_STAT(aquamarine,0.496101F,0.996 << 403 TOOLS_COLORS_STAT(mediumaquamarine,0.398444F << 404 // TOOLS_COLORS_STAT(black,0,0,0) (already << 405 // TOOLS_COLORS_STAT(blue,0,0,1) (already d << 406 TOOLS_COLORS_STAT(cadetblue,0.371099F,0.6171 << 407 TOOLS_COLORS_STAT(cornflowerblue,0.390631F,0 << 408 TOOLS_COLORS_STAT(darkslateblue,0.281254F,0. << 409 TOOLS_COLORS_STAT(lightblue,0.675792F,0.8437 << 410 TOOLS_COLORS_STAT(lightsteelblue,0.68751F,0. << 411 TOOLS_COLORS_STAT(mediumblue,0,0,0.800793F) << 412 << 413 //10-19 << 414 TOOLS_COLORS_STAT(mediumslateblue,0.480476F, << 415 TOOLS_COLORS_STAT(midnightblue,0.0976577F,0. << 416 TOOLS_COLORS_STAT(navyblue,0,0,0.500008F) << 417 TOOLS_COLORS_STAT(navy,0,0,0.500008F) << 418 TOOLS_COLORS_STAT(skyblue,0.527352F,0.8047F, << 419 TOOLS_COLORS_STAT(slateblue,0.414069F,0.3515 << 420 TOOLS_COLORS_STAT(steelblue,0.273442F,0.5078 << 421 TOOLS_COLORS_STAT(coral,0.996109F,0.496101F, << 422 // TOOLS_COLORS_STAT(cyan,0,1,1) (already d << 423 TOOLS_COLORS_STAT(firebrick,0.695323F,0.1328 << 424 << 425 //20-29 << 426 // TOOLS_COLORS_STAT(brown,0.644541F,0.1640 << 427 TOOLS_COLORS_STAT(gold,0.996109F,0.839857F,0 << 428 TOOLS_COLORS_STAT(goldenrod,0.851575F,0.6445 << 429 // TOOLS_COLORS_STAT(green,0,1,0) (already << 430 TOOLS_COLORS_STAT(darkgreen,0,0.390631F,0) << 431 TOOLS_COLORS_STAT(darkolivegreen,0.332036F,0 << 432 TOOLS_COLORS_STAT(forestgreen,0.132815F,0.54 << 433 TOOLS_COLORS_STAT(limegreen,0.195315F,0.8007 << 434 TOOLS_COLORS_STAT(mediumseagreen,0.234379F,0 << 435 TOOLS_COLORS_STAT(mediumspringgreen,0,0.9765 << 436 << 437 //30-39 << 438 TOOLS_COLORS_STAT(palegreen,0.593759F,0.9804 << 439 TOOLS_COLORS_STAT(seagreen,0.17969F,0.542977 << 440 TOOLS_COLORS_STAT(springgreen,0,0.996109F,0. << 441 TOOLS_COLORS_STAT(yellowgreen,0.601572F,0.80 << 442 TOOLS_COLORS_STAT(darkslategrey,0.183597F,0. << 443 TOOLS_COLORS_STAT(dimgrey,0.410163F,0.410163 << 444 TOOLS_COLORS_STAT(lightgrey,0.824231F,0.8242 << 445 // TOOLS_COLORS_STAT(grey,0.750011F,0.75001 << 446 TOOLS_COLORS_STAT(khaki,0.937514F,0.898451F, << 447 // TOOLS_COLORS_STAT(magenta,1,0,1) (alread << 448 << 449 //40-49 << 450 TOOLS_COLORS_STAT(maroon,0.68751F,0.187503F, << 451 TOOLS_COLORS_STAT(orange,0.996109F,0.644541F << 452 TOOLS_COLORS_STAT(orchid,0.851575F,0.437507F << 453 TOOLS_COLORS_STAT(darkorchid,0.597665F,0.195 << 454 TOOLS_COLORS_STAT(mediumorchid,0.726574F,0.3 << 455 TOOLS_COLORS_STAT(pink,0.996109F,0.750011F,0 << 456 TOOLS_COLORS_STAT(plum,0.863294F,0.62501F,0. << 457 // TOOLS_COLORS_STAT(red,1,0,0) (already de << 458 TOOLS_COLORS_STAT(indianred,0.800793F,0.3593 << 459 TOOLS_COLORS_STAT(mediumvioletred,0.777356F, << 460 << 461 //50-59 << 462 TOOLS_COLORS_STAT(orangered,0.996109F,0.2695 << 463 TOOLS_COLORS_STAT(violetred,0.812512F,0.1250 << 464 TOOLS_COLORS_STAT(salmon,0.976577F,0.500008F << 465 TOOLS_COLORS_STAT(sienna,0.62501F,0.320317F, << 466 TOOLS_COLORS_STAT(tan,0.820325F,0.703136F,0. << 467 TOOLS_COLORS_STAT(thistle,0.843763F,0.746105 << 468 TOOLS_COLORS_STAT(turquoise,0.250004F,0.8750 << 469 TOOLS_COLORS_STAT(darkturquoise,0,0.8047F,0. << 470 TOOLS_COLORS_STAT(mediumturquoise,0.281254F, << 471 TOOLS_COLORS_STAT(violet,0.929702F,0.50782F, << 472 << 473 //60-64 << 474 TOOLS_COLORS_STAT(blueviolet,0.539071F,0.167 << 475 TOOLS_COLORS_STAT(wheat,0.957046F,0.867201F, << 476 // TOOLS_COLORS_STAT(white,1,1,1) (already << 477 // TOOLS_COLORS_STAT(yellow,1,1,0) (already << 478 TOOLS_COLORS_STAT(greenyellow,0.675792F,0.99 << 479 << 480 #undef TOOLS_COLORS_STAT << 481 } << 482 << 483 void G4VisManager::RegisterMessengers () { << 484 << 485 // Instantiate individual messengers/command << 486 // always - one command per messenger). << 487 << 488 G4UIcommand* directory; << 489 << 490 directory = new G4UIdirectory ("/vis/geometr << 491 directory -> SetGuidance("Operations on vis << 492 fDirectoryList.push_back (directory); << 493 RegisterMessenger(new G4VisCommandGeometryLi << 494 RegisterMessenger(new G4VisCommandGeometryRe << 495 << 496 directory = new G4UIdirectory ("/vis/geometr << 497 directory -> SetGuidance("Set vis attributes << 498 fDirectoryList.push_back (directory); << 499 RegisterMessenger(new G4VisCommandGeometrySe << 500 RegisterMessenger(new G4VisCommandGeometrySe << 501 RegisterMessenger(new G4VisCommandGeometrySe << 502 RegisterMessenger(new G4VisCommandGeometrySe << 503 RegisterMessenger(new G4VisCommandGeometrySe << 504 RegisterMessenger(new G4VisCommandGeometrySe << 505 RegisterMessenger(new G4VisCommandGeometrySe << 506 RegisterMessenger(new G4VisCommandGeometrySe << 507 RegisterMessenger(new G4VisCommandGeometrySe << 508 RegisterMessenger(new G4VisCommandGeometrySe << 509 << 510 directory = new G4UIdirectory ("/vis/multith << 511 directory -> SetGuidance("Commands unique to << 512 fDirectoryList.push_back (directory); << 513 RegisterMessenger(new G4VisCommandMultithrea << 514 RegisterMessenger(new G4VisCommandMultithrea << 515 << 516 directory = new G4UIdirectory ("/vis/set/"); << 517 directory -> SetGuidance << 518 ("Set quantities for use in future command << 519 fDirectoryList.push_back (directory); << 520 RegisterMessenger(new G4VisCommandSetArrow3D << 521 RegisterMessenger(new G4VisCommandSetColour) << 522 RegisterMessenger(new G4VisCommandSetExtentF << 523 RegisterMessenger(new G4VisCommandSetLineWid << 524 RegisterMessenger(new G4VisCommandSetTextCol << 525 RegisterMessenger(new G4VisCommandSetTextLay << 526 RegisterMessenger(new G4VisCommandSetTextSiz << 527 RegisterMessenger(new G4VisCommandSetTouchab << 528 RegisterMessenger(new G4VisCommandSetVolumeF << 529 << 530 directory = new G4UIdirectory ("/vis/scene/" << 531 directory -> SetGuidance ("Operations on Gea << 532 fDirectoryList.push_back (directory); << 533 RegisterMessenger(new G4VisCommandSceneActiv << 534 RegisterMessenger(new G4VisCommandSceneCreat << 535 RegisterMessenger(new G4VisCommandSceneEndOf << 536 RegisterMessenger(new G4VisCommandSceneEndOf << 537 RegisterMessenger(new G4VisCommandSceneList) << 538 RegisterMessenger(new G4VisCommandSceneNotif << 539 RegisterMessenger(new G4VisCommandSceneRemov << 540 RegisterMessenger(new G4VisCommandSceneSelec << 541 RegisterMessenger(new G4VisCommandSceneShowE << 542 << 543 directory = new G4UIdirectory ("/vis/scene/a << 544 directory -> SetGuidance ("Add model to curr << 545 fDirectoryList.push_back (directory); << 546 RegisterMessenger(new G4VisCommandSceneAddAr << 547 RegisterMessenger(new G4VisCommandSceneAddAr << 548 RegisterMessenger(new G4VisCommandSceneAddAx << 549 RegisterMessenger(new G4VisCommandSceneAddDa << 550 RegisterMessenger(new G4VisCommandSceneAddDi << 551 RegisterMessenger(new G4VisCommandSceneAddEv << 552 RegisterMessenger(new G4VisCommandSceneAddEx << 553 RegisterMessenger(new G4VisCommandSceneAddEl << 554 RegisterMessenger(new G4VisCommandSceneAddFr << 555 RegisterMessenger(new G4VisCommandSceneAddGP << 556 RegisterMessenger(new G4VisCommandSceneAddHi << 557 RegisterMessenger(new G4VisCommandSceneAddLi << 558 RegisterMessenger(new G4VisCommandSceneAddLi << 559 RegisterMessenger(new G4VisCommandSceneAddLo << 560 RegisterMessenger(new G4VisCommandSceneAddLo << 561 RegisterMessenger(new G4VisCommandSceneAddLo << 562 RegisterMessenger(new G4VisCommandSceneAddLo << 563 RegisterMessenger(new G4VisCommandSceneAddMa << 564 RegisterMessenger(new G4VisCommandSceneAddPl << 565 RegisterMessenger(new G4VisCommandSceneAddPS << 566 RegisterMessenger(new G4VisCommandSceneAddSc << 567 RegisterMessenger(new G4VisCommandSceneAddTe << 568 RegisterMessenger(new G4VisCommandSceneAddTe << 569 RegisterMessenger(new G4VisCommandSceneAddTr << 570 RegisterMessenger(new G4VisCommandSceneAddUs << 571 RegisterMessenger(new G4VisCommandSceneAddVo << 572 << 573 RegisterMessenger(new G4VisCommandPlotterCre << 574 RegisterMessenger(new G4VisCommandPlotterSet << 575 RegisterMessenger(new G4VisCommandPlotterAdd << 576 RegisterMessenger(new G4VisCommandPlotterAdd << 577 RegisterMessenger(new G4VisCommandPlotterAdd << 578 RegisterMessenger(new G4VisCommandPlotterCle << 579 RegisterMessenger(new G4VisCommandPlotterCle << 580 RegisterMessenger(new G4VisCommandPlotterLis << 581 RegisterMessenger(new G4VisCommandPlotterAdd << 582 RegisterMessenger(new G4VisCommandPlotterAdd << 583 << 584 directory = new G4UIdirectory ("/vis/sceneHa << 585 directory -> SetGuidance ("Operations on Gea << 586 fDirectoryList.push_back (directory); << 587 RegisterMessenger(new G4VisCommandSceneHandl << 588 RegisterMessenger(new G4VisCommandSceneHandl << 589 RegisterMessenger(new G4VisCommandSceneHandl << 590 RegisterMessenger(new G4VisCommandSceneHandl << 591 << 592 directory = new G4UIdirectory ("/vis/touchab << 593 directory -> SetGuidance ("Operations on tou << 594 fDirectoryList.push_back (directory); << 595 RegisterMessenger(new G4VisCommandsTouchable << 596 << 597 directory = new G4UIdirectory ("/vis/touchab << 598 directory -> SetGuidance ("Set vis attribute << 599 fDirectoryList.push_back (directory); << 600 RegisterMessenger(new G4VisCommandsTouchable << 601 << 602 directory = new G4UIdirectory ("/vis/viewer/ << 603 directory -> SetGuidance ("Operations on Gea << 604 fDirectoryList.push_back (directory); << 605 RegisterMessenger(new G4VisCommandViewerAddC << 606 RegisterMessenger(new G4VisCommandViewerCent << 607 RegisterMessenger(new G4VisCommandViewerChan << 608 RegisterMessenger(new G4VisCommandViewerClea << 609 RegisterMessenger(new G4VisCommandViewerClea << 610 RegisterMessenger(new G4VisCommandViewerClea << 611 RegisterMessenger(new G4VisCommandViewerClea << 612 RegisterMessenger(new G4VisCommandViewerClon << 613 RegisterMessenger(new G4VisCommandViewerColo << 614 RegisterMessenger(new G4VisCommandViewerCopy << 615 RegisterMessenger(new G4VisCommandViewerCrea << 616 RegisterMessenger(new G4VisCommandViewerDoll << 617 RegisterMessenger(new G4VisCommandViewerFlus << 618 RegisterMessenger(new G4VisCommandViewerInte << 619 RegisterMessenger(new G4VisCommandViewerList << 620 RegisterMessenger(new G4VisCommandViewerPan) << 621 RegisterMessenger(new G4VisCommandViewerRebu << 622 RegisterMessenger(new G4VisCommandViewerRefr << 623 RegisterMessenger(new G4VisCommandViewerRese << 624 RegisterMessenger(new G4VisCommandViewerRese << 625 RegisterMessenger(new G4VisCommandViewerSave << 626 RegisterMessenger(new G4VisCommandViewerScal << 627 RegisterMessenger(new G4VisCommandViewerSele << 628 RegisterMessenger(new G4VisCommandViewerUpda << 629 RegisterMessenger(new G4VisCommandViewerZoom << 630 << 631 directory = new G4UIdirectory ("/vis/viewer/ << 632 directory -> SetGuidance("Set default values << 633 fDirectoryList.push_back (directory); << 634 RegisterMessenger(new G4VisCommandViewerDefa << 635 RegisterMessenger(new G4VisCommandViewerDefa << 636 << 637 directory = new G4UIdirectory ("/vis/viewer/ << 638 directory -> SetGuidance ("Set view paramete << 639 fDirectoryList.push_back (directory); << 640 RegisterMessenger(new G4VisCommandsViewerSet << 641 << 642 // *Basic* top level commands were instantia << 643 // so that they can be used immediately afte << 644 // vis manager. Other top level commands, i << 645 // (i.e., commands that invoke other command << 646 << 647 RegisterMessenger(new G4VisCommandAbortRevie << 648 RegisterMessenger(new G4VisCommandAbortRevie << 649 RegisterMessenger(new G4VisCommandDrawOnlyTo << 650 RegisterMessenger(new G4VisCommandDrawTree); << 651 RegisterMessenger(new G4VisCommandDrawView); << 652 RegisterMessenger(new G4VisCommandDrawLogica << 653 RegisterMessenger(new G4VisCommandDrawVolume << 654 RegisterMessenger(new G4VisCommandEnable); << 655 RegisterMessenger(new G4VisCommandList); << 656 RegisterMessenger(new G4VisCommandOpen); << 657 RegisterMessenger(new G4VisCommandPlot); << 658 RegisterMessenger(new G4VisCommandReviewKept << 659 RegisterMessenger(new G4VisCommandReviewPlot << 660 RegisterMessenger(new G4VisCommandSpecify); << 661 << 662 // List manager commands << 663 RegisterMessenger(new G4VisCommandListManage << 664 (fpTrajDrawModelMgr, fpTrajDrawModelMg << 665 RegisterMessenger(new G4VisCommandListManage << 666 (fpTrajDrawModelMgr, fpTrajDrawModelMg << 667 << 668 // Trajectory filter manager commands << 669 RegisterMessenger(new G4VisCommandListManage << 670 (fpTrajFilterMgr, fpTrajFi << 671 RegisterMessenger(new G4VisCommandManagerMod << 672 (fpTrajFilterMgr, fpTrajFi << 673 << 674 // Hit filter manager commands << 675 RegisterMessenger(new G4VisCommandListManage << 676 (fpHitFilterMgr, fpHitFilt << 677 RegisterMessenger(new G4VisCommandManagerMod << 678 (fpHitFilterMgr, fpHitFilt << 679 << 680 // Digi filter manager commands << 681 RegisterMessenger(new G4VisCommandListManage << 682 (fpDigiFilterMgr, fpDigiFi << 683 RegisterMessenger(new G4VisCommandManagerMod << 684 (fpDigiFilterMgr, fpDigiFi << 685 } << 686 << 687 #include <tools/histo/h1d> << 688 #include <tools/histo/h2d> << 689 << 690 namespace { << 691 struct PlotResults { << 692 std::size_t fNumberOfPlots = 0; << 693 std::size_t fTotalEntries = 0; << 694 }; << 695 template <typename HT> // tools::histo::h1d << 696 PlotResults ResultsOfHnPlots(const G4String& << 697 PlotResults plotResults; << 698 auto ui = G4UImanager::GetUIpointer(); << 699 auto keepControlVerbose = ui->GetVerboseLe << 700 ui->SetVerboseLevel(0); << 701 auto status = ui->ApplyCommand("/analysis/ << 702 ui->SetVerboseLevel(keepControlVerbose); << 703 if(status==G4UIcommandStatus::fCommandSucc << 704 G4String hexString = ui->GetCurrentValue << 705 if(hexString.size()) { << 706 void* ptr; std::istringstream is(hexSt << 707 auto vectorOfPlots = (const std::vecto << 708 for (std::size_t i = 0; i < vectorOfPl << 709 auto plot = (*vectorOfPlots)[i]; << 710 if (plot == nullptr) continue; // I << 711 ++plotResults.fNumberOfPlots; << 712 plotResults.fTotalEntries += plot->e << 713 } << 714 } << 715 } << 716 return plotResults; << 717 } << 718 void PrintListOfPlots() { << 719 std::size_t numberOfPlots = 0; << 720 std::size_t numberOfEntries = 0; << 721 PlotResults h1results = ResultsOfHnPlots<t << 722 numberOfPlots += h1results.fNumberOfPlots; << 723 numberOfEntries += h1results.fTotalEntries << 724 PlotResults h2results = ResultsOfHnPlots<t << 725 numberOfPlots += h2results.fNumberOfPlots; << 726 numberOfEntries += h2results.fTotalEntries << 727 if (numberOfPlots > 0) { << 728 G4warn << "There are histograms that can << 729 if (h1results.fNumberOfPlots > 0) { << 730 G4warn << "\n " << h1results.fNumberO << 731 } << 732 if (h2results.fNumberOfPlots > 0) { << 733 G4warn << "\n " << h2results.fNumberO << 734 } << 735 G4warn << 736 << "\n List them with \"/analysis/list\ << 737 << "\n View them immediately with \"/vi << 738 << G4endl; << 739 if (numberOfEntries == 0) { << 740 G4warn << << 741 " But...there are no entries. To make << 742 "\n plotting in this UI session, use << 743 "\n EndOfRunAction and Reset() in you << 744 << G4endl; << 745 } << 746 } << 747 } << 748 } << 749 << 750 void G4VisManager::Enable() { 321 void G4VisManager::Enable() { 751 if (IsValidView ()) { 322 if (IsValidView ()) { 752 SetConcreteInstance(this); << 753 if (fVerbosity >= confirmations) { 323 if (fVerbosity >= confirmations) { 754 G4cout << "G4VisManager::Enable: visuali 324 G4cout << "G4VisManager::Enable: visualization enabled." << G4endl; 755 } 325 } 756 if (fVerbosity >= warnings) { << 757 std::size_t nKeptEvents = 0; << 758 const G4Run* run = G4RunManager::GetRunM << 759 if (run) nKeptEvents = run->GetNumberOfK << 760 G4String isare("are"),plural("s"); << 761 if (nKeptEvents == 1) {isare = "is"; plu << 762 G4cout << << 763 "There " << isare << ' ' << nKeptEvents << 764 << G4endl; << 765 if (nKeptEvents > 0) { << 766 G4cout << << 767 " \"/vis/reviewKeptEvents\" to review one b << 768 "\n To see accumulated, \"/vis/enable\", th << 769 << G4endl; << 770 } << 771 PrintListOfPlots(); << 772 } << 773 } 326 } 774 else { 327 else { 775 if (fVerbosity >= warnings) { 328 if (fVerbosity >= warnings) { 776 G4warn << << 329 G4cout << 777 "G4VisManager::Enable: WARNING: visualizatio 330 "G4VisManager::Enable: WARNING: visualization remains disabled for" 778 "\n above reasons. Rectifying with valid v 331 "\n above reasons. Rectifying with valid vis commands will" 779 "\n automatically enable." 332 "\n automatically enable." 780 << G4endl; 333 << G4endl; 781 } 334 } 782 } 335 } 783 } 336 } 784 337 785 void G4VisManager::Disable() { 338 void G4VisManager::Disable() { 786 SetConcreteInstance(0); 339 SetConcreteInstance(0); 787 if (fVerbosity >= confirmations) { 340 if (fVerbosity >= confirmations) { 788 G4cout << 341 G4cout << 789 "G4VisManager::Disable: visualization disa << 342 "G4VisManager::Disable: visualization disabled." 790 "\n The pointer returned by GetConcreteIn << 343 "\n The pointer returned by GetConcreteInstance will be zero." 791 "\n Note that it will become enabled afte << 344 "\n Note that it will become enabled after some valid vis commands." 792 << G4endl; 345 << G4endl; 793 } 346 } 794 if (fVerbosity >= warnings) { << 795 G4int currentTrajectoryType = << 796 G4RunManagerKernel::GetRunManagerKernel()- << 797 if (currentTrajectoryType > 0) { << 798 G4warn << << 799 "You may wish to disable trajectory prod << 800 "\n \"/tracking/storeTrajectory 0\"" << 801 "\nbut don't forget to re-enable with" << 802 "\n \"/vis/enable\"" << 803 "\n \"/tracking/storeTrajectory " << cu << 804 << "\"\n and maybe \"/vis/viewer/rebuil << 805 << G4endl; << 806 } << 807 } << 808 } 347 } 809 348 810 const G4GraphicsSystemList& G4VisManager::GetA 349 const G4GraphicsSystemList& G4VisManager::GetAvailableGraphicsSystems () { 811 std::size_t nSystems = fAvailableGraphicsSys << 350 G4int nSystems = fAvailableGraphicsSystems.size (); 812 if (nSystems == 0) { 351 if (nSystems == 0) { 813 if (fVerbosity >= warnings) { 352 if (fVerbosity >= warnings) { 814 G4warn << "G4VisManager::GetAvailableGra << 353 G4cout << "G4VisManager::GetAvailableGraphicsSystems: WARNING: no" 815 "\n graphics system available!" 354 "\n graphics system available!" 816 "\n 1) Did you have environment variables G 355 "\n 1) Did you have environment variables G4VIS_BUILD_xxxx_DRIVER set" 817 "\n when you compiled/built the visualiz 356 "\n when you compiled/built the visualization code?" 818 "\n 2) Did you instantiate your own Visuali 357 "\n 2) Did you instantiate your own Visualization Manager and forget" 819 "\n to implement RegisterGraphicsSystems 358 "\n to implement RegisterGraphicsSystems correctly?" 820 "\n 3) You can register your own graphics s 359 "\n 3) You can register your own graphics system, e.g.," 821 "\n visManager->RegisterGraphicsSystem(n 360 "\n visManager->RegisterGraphicsSystem(new MyGraphicsSystem);)" 822 "\n after instantiating your vis manager 361 "\n after instantiating your vis manager and before" 823 "\n visManager->Initialize()." 362 "\n visManager->Initialize()." 824 << G4endl; 363 << G4endl; 825 } 364 } 826 } 365 } 827 return fAvailableGraphicsSystems; 366 return fAvailableGraphicsSystems; 828 } 367 } 829 368 830 G4bool G4VisManager::RegisterGraphicsSystem (G 369 G4bool G4VisManager::RegisterGraphicsSystem (G4VGraphicsSystem* pSystem) { 831 G4bool happy = true; 370 G4bool happy = true; 832 if (pSystem) { 371 if (pSystem) { 833 fAvailableGraphicsSystems.push_back (pSyst 372 fAvailableGraphicsSystems.push_back (pSystem); 834 if (fVerbosity >= confirmations) { 373 if (fVerbosity >= confirmations) { 835 G4cout << "G4VisManager::RegisterGraphic 374 G4cout << "G4VisManager::RegisterGraphicsSystem: " 836 << pSystem -> GetName (); 375 << pSystem -> GetName (); 837 if (pSystem -> GetNickname () != "") { 376 if (pSystem -> GetNickname () != "") { 838 G4cout << " (" << pSystem -> GetNickname () 377 G4cout << " (" << pSystem -> GetNickname () << ")"; 839 } 378 } 840 G4cout << " registered." << G4endl; 379 G4cout << " registered." << G4endl; 841 } 380 } 842 } 381 } 843 else { 382 else { 844 if (fVerbosity >= errors) { 383 if (fVerbosity >= errors) { 845 G4warn << "G4VisManager::RegisterGraphic << 384 G4cout << "G4VisManager::RegisterGraphicsSystem: null pointer!" 846 << G4endl; 385 << G4endl; 847 } 386 } 848 happy=false; 387 happy=false; 849 } 388 } 850 return happy; 389 return happy; 851 } 390 } 852 391 853 const G4VTrajectoryModel* 392 const G4VTrajectoryModel* 854 G4VisManager::CurrentTrajDrawModel() const 393 G4VisManager::CurrentTrajDrawModel() const 855 { 394 { 856 assert (0 != fpTrajDrawModelMgr); 395 assert (0 != fpTrajDrawModelMgr); 857 396 858 const G4VTrajectoryModel* model = fpTrajDraw 397 const G4VTrajectoryModel* model = fpTrajDrawModelMgr->Current(); 859 398 860 if (0 == model) { 399 if (0 == model) { 861 // No model was registered with the trajec 400 // No model was registered with the trajectory model manager. 862 // Use G4TrajectoryDrawByCharge as a fallb << 401 // Use G4TrajectoryDrawByCharge as a default. 863 fpTrajDrawModelMgr->Register(new G4Traject << 402 fpTrajDrawModelMgr->Register(new G4TrajectoryDrawByCharge("AutoGenerated")); >> 403 864 if (fVerbosity >= warnings) { 404 if (fVerbosity >= warnings) { 865 G4warn<<"G4VisManager: Using G4Trajector << 405 G4cout<<"G4VisManager: Using G4TrajectoryDrawByCharge as default trajectory model."<<G4endl; 866 G4warn<<"See commands in /vis/modeling/t << 406 G4cout<<"See commands in /vis/modeling/trajectories/ for other options."<<G4endl; 867 } 407 } 868 } 408 } 869 409 870 model = fpTrajDrawModelMgr->Current(); 410 model = fpTrajDrawModelMgr->Current(); 871 assert (0 != model); // Should definitely ex 411 assert (0 != model); // Should definitely exist now 872 412 873 return model; 413 return model; 874 } 414 } 875 415 876 void G4VisManager::RegisterModel(G4VTrajectory << 416 void G4VisManager::RegisterModel(G4VTrajectoryModel* model) 877 { 417 { 878 fpTrajDrawModelMgr->Register(model); 418 fpTrajDrawModelMgr->Register(model); 879 } 419 } 880 420 881 void 421 void 882 G4VisManager::RegisterModelFactory(G4TrajDrawM 422 G4VisManager::RegisterModelFactory(G4TrajDrawModelFactory* factory) 883 { 423 { 884 fpTrajDrawModelMgr->Register(factory); 424 fpTrajDrawModelMgr->Register(factory); 885 } 425 } 886 426 887 void G4VisManager::RegisterModel(G4VFilter<G4V 427 void G4VisManager::RegisterModel(G4VFilter<G4VTrajectory>* model) 888 { 428 { 889 fpTrajFilterMgr->Register(model); 429 fpTrajFilterMgr->Register(model); 890 } 430 } 891 431 892 void 432 void 893 G4VisManager::RegisterModelFactory(G4TrajFilte 433 G4VisManager::RegisterModelFactory(G4TrajFilterFactory* factory) 894 { 434 { 895 fpTrajFilterMgr->Register(factory); 435 fpTrajFilterMgr->Register(factory); 896 } 436 } 897 437 898 void G4VisManager::RegisterModel(G4VFilter<G4V 438 void G4VisManager::RegisterModel(G4VFilter<G4VHit>* model) 899 { 439 { 900 fpHitFilterMgr->Register(model); 440 fpHitFilterMgr->Register(model); 901 } 441 } 902 442 903 void 443 void 904 G4VisManager::RegisterModelFactory(G4HitFilter 444 G4VisManager::RegisterModelFactory(G4HitFilterFactory* factory) 905 { 445 { 906 fpHitFilterMgr->Register(factory); 446 fpHitFilterMgr->Register(factory); 907 } 447 } 908 448 909 void G4VisManager::RegisterModel(G4VFilter<G4V 449 void G4VisManager::RegisterModel(G4VFilter<G4VDigi>* model) 910 { 450 { 911 fpDigiFilterMgr->Register(model); 451 fpDigiFilterMgr->Register(model); 912 } 452 } 913 453 914 void 454 void 915 G4VisManager::RegisterModelFactory(G4DigiFilte 455 G4VisManager::RegisterModelFactory(G4DigiFilterFactory* factory) 916 { 456 { 917 fpDigiFilterMgr->Register(factory); 457 fpDigiFilterMgr->Register(factory); 918 } 458 } 919 459 920 void G4VisManager::SelectTrajectoryModel(const 460 void G4VisManager::SelectTrajectoryModel(const G4String& model) 921 { 461 { 922 fpTrajDrawModelMgr->SetCurrent(model); 462 fpTrajDrawModelMgr->SetCurrent(model); 923 } 463 } 924 464 925 void G4VisManager::BeginDraw (const G4Transfor << 465 void G4VisManager::Draw (const G4Circle& circle, 926 { << 466 const G4Transform3D& objectTransform) { 927 if (G4Threading::IsWorkerThread()) return; << 928 << 929 fDrawGroupNestingDepth++; << 930 if (fDrawGroupNestingDepth > 1) { << 931 G4Exception << 932 ("G4VisManager::BeginDraw", << 933 "visman0008", JustWarning, << 934 "Nesting detected. It is illegal to nes << 935 "\n Ignored"); << 936 return; << 937 } << 938 if (IsValidView ()) { 467 if (IsValidView ()) { 939 ClearTransientStoreIfMarked(); 468 ClearTransientStoreIfMarked(); 940 fpSceneHandler -> BeginPrimitives (objectT 469 fpSceneHandler -> BeginPrimitives (objectTransform); 941 fIsDrawGroup = true; << 470 fpSceneHandler -> AddPrimitive (circle); >> 471 fpSceneHandler -> EndPrimitives (); 942 } 472 } 943 } 473 } 944 474 945 void G4VisManager::EndDraw () << 475 void G4VisManager::Draw (const G4NURBS& nurbs, 946 { << 476 const G4Transform3D& objectTransform) { 947 if (G4Threading::IsWorkerThread()) return; << 948 << 949 fDrawGroupNestingDepth--; << 950 if (fDrawGroupNestingDepth != 0) { << 951 if (fDrawGroupNestingDepth < 0) fDrawGroup << 952 return; << 953 } << 954 if (IsValidView ()) { 477 if (IsValidView ()) { >> 478 ClearTransientStoreIfMarked(); >> 479 fpSceneHandler -> BeginPrimitives (objectTransform); >> 480 fpSceneHandler -> AddPrimitive (nurbs); 955 fpSceneHandler -> EndPrimitives (); 481 fpSceneHandler -> EndPrimitives (); 956 } 482 } 957 fIsDrawGroup = false; << 958 } 483 } 959 484 960 void G4VisManager::BeginDraw2D (const G4Transf << 485 void G4VisManager::Draw (const G4Polyhedron& polyhedron, 961 { << 486 const G4Transform3D& objectTransform) { 962 if (G4Threading::IsWorkerThread()) return; << 963 << 964 fDrawGroupNestingDepth++; << 965 if (fDrawGroupNestingDepth > 1) { << 966 G4Exception << 967 ("G4VisManager::BeginDraw2D", << 968 "visman0009", JustWarning, << 969 "Nesting detected. It is illegal to nes << 970 "\n Ignored"); << 971 return; << 972 } << 973 if (IsValidView ()) { 487 if (IsValidView ()) { 974 ClearTransientStoreIfMarked(); 488 ClearTransientStoreIfMarked(); 975 fpSceneHandler -> BeginPrimitives2D (objec << 489 fpSceneHandler -> BeginPrimitives (objectTransform); 976 fIsDrawGroup = true; << 490 fpSceneHandler -> AddPrimitive (polyhedron); >> 491 fpSceneHandler -> EndPrimitives (); 977 } 492 } 978 } 493 } 979 494 980 void G4VisManager::EndDraw2D () << 495 void G4VisManager::Draw (const G4Polyline& line, 981 { << 496 const G4Transform3D& objectTransform) { 982 if (G4Threading::IsWorkerThread()) return; << 983 << 984 fDrawGroupNestingDepth--; << 985 if (fDrawGroupNestingDepth != 0) { << 986 if (fDrawGroupNestingDepth < 0) fDrawGroup << 987 return; << 988 } << 989 if (IsValidView ()) { 497 if (IsValidView ()) { 990 fpSceneHandler -> EndPrimitives2D (); << 498 ClearTransientStoreIfMarked(); >> 499 fpSceneHandler -> BeginPrimitives (objectTransform); >> 500 fpSceneHandler -> AddPrimitive (line); >> 501 fpSceneHandler -> EndPrimitives (); 991 } 502 } 992 fIsDrawGroup = false; << 993 } 503 } 994 504 995 template <class T> void G4VisManager::DrawT << 505 void G4VisManager::Draw (const G4Polymarker& polymarker, 996 (const T& graphics_primitive, const G4Transfor << 506 const G4Transform3D& objectTransform) { 997 if (G4Threading::IsWorkerThread()) return; << 507 if (IsValidView ()) { 998 << 508 ClearTransientStoreIfMarked(); 999 if (fIsDrawGroup) { << 509 fpSceneHandler -> BeginPrimitives (objectTransform); 1000 if (objectTransform != fpSceneHandler->Ge << 510 fpSceneHandler -> AddPrimitive (polymarker); 1001 G4Exception << 511 fpSceneHandler -> EndPrimitives (); 1002 ("G4VSceneHandler::DrawT", << 1003 "visman0010", FatalException, << 1004 "Different transform detected in Begin/End << 1005 } << 1006 fpSceneHandler -> AddPrimitive (graphics_ << 1007 } else { << 1008 if (IsValidView ()) { << 1009 ClearTransientStoreIfMarked(); << 1010 fpSceneHandler -> BeginPrimitives (obje << 1011 fpSceneHandler -> AddPrimitive (graphic << 1012 fpSceneHandler -> EndPrimitives (); << 1013 } << 1014 } 512 } 1015 } 513 } 1016 514 1017 template <class T> void G4VisManager::DrawT2D << 515 void G4VisManager::Draw (const G4Scale& scale, 1018 (const T& graphics_primitive, const G4Transfo << 516 const G4Transform3D& objectTransform) { 1019 if (G4Threading::IsWorkerThread()) return; << 517 if (IsValidView ()) { 1020 << 518 ClearTransientStoreIfMarked(); 1021 if (fIsDrawGroup) { << 519 fpSceneHandler -> BeginPrimitives (objectTransform); 1022 if (objectTransform != fpSceneHandler->Ge << 520 fpSceneHandler -> AddPrimitive (scale); 1023 G4Exception << 521 fpSceneHandler -> EndPrimitives (); 1024 ("G4VSceneHandler::DrawT", << 1025 "visman0011", FatalException, << 1026 "Different transform detected in Begin/End << 1027 } << 1028 fpSceneHandler -> AddPrimitive (graphics_ << 1029 } else { << 1030 if (IsValidView ()) { << 1031 ClearTransientStoreIfMarked(); << 1032 fpSceneHandler -> BeginPrimitives2D (ob << 1033 fpSceneHandler -> AddPrimitive (graphic << 1034 fpSceneHandler -> EndPrimitives2D (); << 1035 } << 1036 } 522 } 1037 } 523 } 1038 524 1039 void G4VisManager::Draw (const G4Circle& circ << 1040 const G4Transform3D& objectTransform) << 1041 { << 1042 DrawT (circle, objectTransform); << 1043 } << 1044 << 1045 void G4VisManager::Draw (const G4Polyhedron& << 1046 const G4Transform3D& objectTransform) << 1047 { << 1048 DrawT (polyhedron, objectTransform); << 1049 } << 1050 << 1051 void G4VisManager::Draw (const G4Polyline& li << 1052 const G4Transform3D& objectTransform) << 1053 { << 1054 DrawT (line, objectTransform); << 1055 } << 1056 << 1057 void G4VisManager::Draw (const G4Polymarker& << 1058 const G4Transform3D& objectTransform) << 1059 { << 1060 DrawT (polymarker, objectTransform); << 1061 } << 1062 << 1063 void G4VisManager::Draw (const G4Square& squa 525 void G4VisManager::Draw (const G4Square& square, 1064 const G4Transform3D& objectTransform) << 526 const G4Transform3D& objectTransform) { 1065 { << 527 if (IsValidView ()) { 1066 DrawT (square, objectTransform); << 528 ClearTransientStoreIfMarked(); >> 529 fpSceneHandler -> BeginPrimitives (objectTransform); >> 530 fpSceneHandler -> AddPrimitive (square); >> 531 fpSceneHandler -> EndPrimitives (); >> 532 } 1067 } 533 } 1068 534 1069 void G4VisManager::Draw (const G4Text& text, 535 void G4VisManager::Draw (const G4Text& text, 1070 const G4Transform3D& objectTransform) << 536 const G4Transform3D& objectTransform) { 1071 { << 537 if (IsValidView ()) { 1072 DrawT (text, objectTransform); << 538 ClearTransientStoreIfMarked(); >> 539 fpSceneHandler -> BeginPrimitives (objectTransform); >> 540 fpSceneHandler -> AddPrimitive (text); >> 541 fpSceneHandler -> EndPrimitives (); >> 542 } 1073 } 543 } 1074 544 1075 void G4VisManager::Draw2D (const G4Circle& ci 545 void G4VisManager::Draw2D (const G4Circle& circle, 1076 const G4Transform3D& objectTransform 546 const G4Transform3D& objectTransform) 1077 { 547 { 1078 DrawT2D (circle, objectTransform); << 548 if (IsValidView()) { >> 549 ClearTransientStoreIfMarked(); >> 550 fpSceneHandler -> BeginPrimitives2D(objectTransform); >> 551 fpSceneHandler -> AddPrimitive(circle); >> 552 fpSceneHandler -> EndPrimitives2D(); >> 553 } >> 554 } >> 555 >> 556 void G4VisManager::Draw2D (const G4NURBS& nurbs, >> 557 const G4Transform3D& objectTransform) >> 558 { >> 559 if (IsValidView()) { >> 560 ClearTransientStoreIfMarked(); >> 561 fpSceneHandler -> BeginPrimitives2D(objectTransform); >> 562 fpSceneHandler -> AddPrimitive(nurbs); >> 563 fpSceneHandler -> EndPrimitives2D(); >> 564 } 1079 } 565 } 1080 566 1081 void G4VisManager::Draw2D (const G4Polyhedron 567 void G4VisManager::Draw2D (const G4Polyhedron& polyhedron, 1082 const G4Transform3D& objectTransform 568 const G4Transform3D& objectTransform) 1083 { 569 { 1084 DrawT2D (polyhedron, objectTransform); << 570 if (IsValidView()) { >> 571 ClearTransientStoreIfMarked(); >> 572 fpSceneHandler -> BeginPrimitives2D(objectTransform); >> 573 fpSceneHandler -> AddPrimitive(polyhedron); >> 574 fpSceneHandler -> EndPrimitives2D(); >> 575 } 1085 } 576 } 1086 577 1087 void G4VisManager::Draw2D (const G4Polyline& 578 void G4VisManager::Draw2D (const G4Polyline& line, 1088 const G4Transform3D& objectTransform 579 const G4Transform3D& objectTransform) 1089 { 580 { 1090 DrawT2D (line, objectTransform); << 581 if (IsValidView()) { >> 582 ClearTransientStoreIfMarked(); >> 583 fpSceneHandler -> BeginPrimitives2D(objectTransform); >> 584 fpSceneHandler -> AddPrimitive(line); >> 585 fpSceneHandler -> EndPrimitives2D(); >> 586 } 1091 } 587 } 1092 588 1093 void G4VisManager::Draw2D (const G4Polymarker 589 void G4VisManager::Draw2D (const G4Polymarker& polymarker, 1094 const G4Transform3D& objectTransform 590 const G4Transform3D& objectTransform) 1095 { 591 { 1096 DrawT2D (polymarker, objectTransform); << 592 if (IsValidView()) { >> 593 ClearTransientStoreIfMarked(); >> 594 fpSceneHandler -> BeginPrimitives2D(objectTransform); >> 595 fpSceneHandler -> AddPrimitive(polymarker); >> 596 fpSceneHandler -> EndPrimitives2D(); >> 597 } 1097 } 598 } 1098 599 1099 void G4VisManager::Draw2D (const G4Square& sq 600 void G4VisManager::Draw2D (const G4Square& square, 1100 const G4Transform3D& objectTransform 601 const G4Transform3D& objectTransform) 1101 { 602 { 1102 DrawT2D (square, objectTransform); << 603 if (IsValidView()) { >> 604 ClearTransientStoreIfMarked(); >> 605 fpSceneHandler -> BeginPrimitives2D(objectTransform); >> 606 fpSceneHandler -> AddPrimitive(square); >> 607 fpSceneHandler -> EndPrimitives2D(); >> 608 } 1103 } 609 } 1104 610 1105 void G4VisManager::Draw2D (const G4Text& text 611 void G4VisManager::Draw2D (const G4Text& text, 1106 const G4Transform3D& objectTransform 612 const G4Transform3D& objectTransform) 1107 { 613 { 1108 DrawT2D (text, objectTransform); << 614 if (IsValidView()) { >> 615 ClearTransientStoreIfMarked(); >> 616 fpSceneHandler -> BeginPrimitives2D(objectTransform); >> 617 fpSceneHandler -> AddPrimitive(text); >> 618 fpSceneHandler -> EndPrimitives2D(); >> 619 } 1109 } 620 } 1110 621 1111 void G4VisManager::Draw (const G4VHit& hit) { 622 void G4VisManager::Draw (const G4VHit& hit) { 1112 if (G4Threading::IsWorkerThread()) return; << 623 if (IsValidView ()) { 1113 << 624 ClearTransientStoreIfMarked(); 1114 if (fIsDrawGroup) { << 1115 fpSceneHandler -> AddCompound (hit); 625 fpSceneHandler -> AddCompound (hit); 1116 } else { << 1117 if (IsValidView ()) { << 1118 ClearTransientStoreIfMarked(); << 1119 fpSceneHandler -> AddCompound (hit); << 1120 } << 1121 } 626 } 1122 } 627 } 1123 628 1124 void G4VisManager::Draw (const G4VDigi& digi) 629 void G4VisManager::Draw (const G4VDigi& digi) { 1125 if (G4Threading::IsWorkerThread()) return; << 630 if (IsValidView ()) { 1126 << 631 ClearTransientStoreIfMarked(); 1127 if (fIsDrawGroup) { << 1128 fpSceneHandler -> AddCompound (digi); 632 fpSceneHandler -> AddCompound (digi); 1129 } else { << 1130 if (IsValidView ()) { << 1131 ClearTransientStoreIfMarked(); << 1132 fpSceneHandler -> AddCompound (digi); << 1133 } << 1134 } 633 } 1135 } 634 } 1136 635 1137 void G4VisManager::Draw (const G4VTrajectory& << 636 void G4VisManager::Draw (const G4VTrajectory& traj, 1138 if (G4Threading::IsWorkerThread()) return; << 637 G4int i_mode) { 1139 << 638 if (IsValidView ()) { 1140 // A trajectory needs a trajectories model << 639 ClearTransientStoreIfMarked(); 1141 static G4TrajectoriesModel trajectoriesMode << 640 fpSceneHandler -> SetModel (&dummyTrajectoriesModel); 1142 trajectoriesModel.SetCurrentTrajectory(&tra << 641 dummyTrajectoriesModel.SetDrawingMode(i_mode); 1143 G4RunManager* runManager = G4RunManagerFact << 1144 const G4Run* currentRun = runManager->GetC << 1145 if (currentRun) { << 1146 trajectoriesModel.SetRunID(currentRun->Ge << 1147 } << 1148 const G4Event* currentEvent = << 1149 G4EventManager::GetEventManager()->GetConst << 1150 if (currentEvent) { << 1151 trajectoriesModel.SetEventID(currentEvent << 1152 } << 1153 if (fIsDrawGroup) { << 1154 fpSceneHandler -> SetModel (&trajectories << 1155 fpSceneHandler -> AddCompound (traj); 642 fpSceneHandler -> AddCompound (traj); 1156 fpSceneHandler -> SetModel (0); << 1157 } else { << 1158 if (IsValidView ()) { << 1159 ClearTransientStoreIfMarked(); << 1160 fpSceneHandler -> SetModel (&trajectori << 1161 fpSceneHandler -> AddCompound (traj); << 1162 fpSceneHandler -> SetModel (0); << 1163 } << 1164 } 643 } 1165 } 644 } 1166 645 1167 void G4VisManager::Draw (const G4LogicalVolum 646 void G4VisManager::Draw (const G4LogicalVolume& logicalVol, 1168 const G4VisAttributes& attribs, 647 const G4VisAttributes& attribs, 1169 const G4Transform3D& objectTransform) 648 const G4Transform3D& objectTransform) { 1170 if (G4Threading::IsWorkerThread()) return; << 1171 << 1172 // Find corresponding solid. 649 // Find corresponding solid. 1173 G4VSolid* pSol = logicalVol.GetSolid (); 650 G4VSolid* pSol = logicalVol.GetSolid (); 1174 Draw (*pSol, attribs, objectTransform); 651 Draw (*pSol, attribs, objectTransform); 1175 } 652 } 1176 653 1177 void G4VisManager::Draw (const G4VSolid& soli 654 void G4VisManager::Draw (const G4VSolid& solid, 1178 const G4VisAttributes& attribs, 655 const G4VisAttributes& attribs, 1179 const G4Transform3D& objectTransform) 656 const G4Transform3D& objectTransform) { 1180 if (G4Threading::IsWorkerThread()) return; << 657 if (IsValidView ()) { 1181 << 658 ClearTransientStoreIfMarked(); 1182 if (fIsDrawGroup) { << 1183 fpSceneHandler -> PreAddSolid (objectTran 659 fpSceneHandler -> PreAddSolid (objectTransform, attribs); 1184 solid.DescribeYourselfTo (*fpSceneHandler 660 solid.DescribeYourselfTo (*fpSceneHandler); 1185 fpSceneHandler -> PostAddSolid (); 661 fpSceneHandler -> PostAddSolid (); 1186 } else { << 1187 if (IsValidView ()) { << 1188 ClearTransientStoreIfMarked(); << 1189 fpSceneHandler -> PreAddSolid (objectTr << 1190 solid.DescribeYourselfTo (*fpSceneHandl << 1191 fpSceneHandler -> PostAddSolid (); << 1192 } << 1193 } 662 } 1194 } 663 } 1195 664 1196 void G4VisManager::Draw (const G4VPhysicalVol 665 void G4VisManager::Draw (const G4VPhysicalVolume& physicalVol, 1197 const G4VisAttributes& attribs, 666 const G4VisAttributes& attribs, 1198 const G4Transform3D& objectTransform) 667 const G4Transform3D& objectTransform) { 1199 if (G4Threading::IsWorkerThread()) return; << 1200 << 1201 // Note: It is tempting to use a temporary << 1202 // trajectories, in order to get at the G4A << 1203 // volume. I tried it (JA). But it's not << 1204 // vis attributes. Also other aspects of t << 1205 // be properly set up. So, the idea has be << 1206 // being. The model pointer will be null. << 1207 // will be no G4Atts from this physical vol << 1208 // << 1209 // If this is called from DrawHit, for exam << 1210 // hit and these will be available with "/v << 1211 // << 1212 // Find corresponding logical volume and so 668 // Find corresponding logical volume and solid. 1213 G4LogicalVolume* pLV = physicalVol.GetLogi 669 G4LogicalVolume* pLV = physicalVol.GetLogicalVolume (); 1214 G4VSolid* pSol = pLV -> GetSolid (); 670 G4VSolid* pSol = pLV -> GetSolid (); 1215 Draw (*pSol, attribs, objectTransform); 671 Draw (*pSol, attribs, objectTransform); 1216 } 672 } 1217 673 1218 void G4VisManager::DrawGeometry << 674 void G4VisManager::CreateSceneHandler (G4String name) { 1219 (G4VPhysicalVolume* v, const G4Transform3D& t << 1220 // Draws a geometry tree starting at the spec << 1221 { << 1222 auto modelingParameters = fpSceneHandler->C << 1223 auto depth = G4PhysicalVolumeModel::UNLIMIT << 1224 const G4bool useFullExtent = true; << 1225 G4PhysicalVolumeModel aPVModel(v,depth,t,mo << 1226 aPVModel.DescribeYourselfTo(*fpSceneHandler << 1227 delete modelingParameters; << 1228 } << 1229 << 1230 void G4VisManager::CreateSceneHandler (const << 1231 if (!fInitialised) Initialise (); 675 if (!fInitialised) Initialise (); 1232 if (fpGraphicsSystem) { 676 if (fpGraphicsSystem) { 1233 G4VSceneHandler* pSceneHandler = 677 G4VSceneHandler* pSceneHandler = 1234 fpGraphicsSystem -> CreateSceneHandler 678 fpGraphicsSystem -> CreateSceneHandler (name); 1235 if (pSceneHandler) { 679 if (pSceneHandler) { 1236 fAvailableSceneHandlers.push_back (pSce 680 fAvailableSceneHandlers.push_back (pSceneHandler); 1237 fpSceneHandler = pSceneHandler; 681 fpSceneHandler = pSceneHandler; // Make current. 1238 } 682 } 1239 else { 683 else { 1240 if (fVerbosity >= errors) { << 684 if(fVerbosity >= errors) { 1241 G4warn << "ERROR in G4VisManager::CreateSce << 685 G4cout << "ERROR in G4VisManager::CreateSceneHandler during " 1242 << fpGraphicsSystem -> GetName () 686 << fpGraphicsSystem -> GetName () 1243 << " scene handler creation.\n No a 687 << " scene handler creation.\n No action taken." 1244 << G4endl; 688 << G4endl; 1245 } 689 } 1246 } 690 } 1247 } 691 } 1248 else PrintInvalidPointers (); 692 else PrintInvalidPointers (); 1249 } 693 } 1250 694 1251 void G4VisManager::CreateViewer << 695 void G4VisManager::CreateViewer (G4String name,G4String XGeometry) { 1252 (const G4String& name, const G4String& XGeome << 1253 { << 1254 696 1255 if (!fInitialised) Initialise (); 697 if (!fInitialised) Initialise (); 1256 698 1257 if (!fpSceneHandler) { 699 if (!fpSceneHandler) { 1258 PrintInvalidPointers (); 700 PrintInvalidPointers (); 1259 return; 701 return; 1260 } 702 } 1261 703 1262 G4VViewer* p = fpGraphicsSystem -> CreateVi 704 G4VViewer* p = fpGraphicsSystem -> CreateViewer (*fpSceneHandler, name); 1263 705 1264 if (!p) { 706 if (!p) { 1265 if (fVerbosity >= errors) { 707 if (fVerbosity >= errors) { 1266 G4warn << "ERROR in G4VisManager::Creat << 708 G4cout << "ERROR in G4VisManager::CreateViewer during " 1267 << fpGraphicsSystem -> GetName () 709 << fpGraphicsSystem -> GetName () 1268 << " viewer creation.\n No action tak 710 << " viewer creation.\n No action taken." 1269 << G4endl; 711 << G4endl; 1270 } 712 } 1271 return; 713 return; 1272 } 714 } 1273 715 1274 if (p -> GetViewId() < 0) { 716 if (p -> GetViewId() < 0) { 1275 if (fVerbosity >= errors) { 717 if (fVerbosity >= errors) { 1276 G4warn << "ERROR in G4VisManager::Creat << 718 G4cout << "ERROR in G4VisManager::CreateViewer during " 1277 << fpGraphicsSystem -> GetName () 719 << fpGraphicsSystem -> GetName () 1278 << " viewer instantiation.\n No actio << 720 << " viewer initialisation.\n No action taken." 1279 << G4endl; 721 << G4endl; 1280 } 722 } 1281 return; 723 return; 1282 } 724 } 1283 725 1284 // Viewer is created, now we can set geomet 726 // Viewer is created, now we can set geometry parameters 1285 // Before 12/2008, it was done in G4VViewer 727 // Before 12/2008, it was done in G4VViewer.cc but it did not have to be there! 1286 728 1287 G4ViewParameters initialvp = p -> GetViewPa 729 G4ViewParameters initialvp = p -> GetViewParameters(); 1288 initialvp.SetXGeometryString(XGeometry); // 730 initialvp.SetXGeometryString(XGeometry); //parse string and store parameters 1289 p -> SetViewParameters(initialvp); 731 p -> SetViewParameters(initialvp); 1290 p -> Initialise (); // (Viewer itself may 732 p -> Initialise (); // (Viewer itself may change view parameters further.) 1291 if (p -> GetViewId() < 0) { << 1292 if (fVerbosity >= errors) { << 1293 G4warn << "ERROR in G4VisManager::Creat << 1294 << fpGraphicsSystem -> GetName () << 1295 << " viewer initialisation.\n No acti << 1296 << G4endl; << 1297 } << 1298 return; << 1299 } << 1300 733 1301 fpViewer = p; / 734 fpViewer = p; // Make current. 1302 fpSceneHandler -> AddViewerToList (fpViewer 735 fpSceneHandler -> AddViewerToList (fpViewer); 1303 fpSceneHandler -> SetCurrentViewer (fpViewe 736 fpSceneHandler -> SetCurrentViewer (fpViewer); 1304 if (fVerbosity >= confirmations) { 737 if (fVerbosity >= confirmations) { 1305 G4cout << "G4VisManager::CreateViewer: ne 738 G4cout << "G4VisManager::CreateViewer: new viewer created." 1306 << G4endl; 739 << G4endl; 1307 } 740 } 1308 741 1309 const G4ViewParameters& vp = fpViewer->GetV 742 const G4ViewParameters& vp = fpViewer->GetViewParameters(); 1310 if (fVerbosity >= parameters) { 743 if (fVerbosity >= parameters) { 1311 G4cout << " view parameters are:\n " << 744 G4cout << " view parameters are:\n " << vp << G4endl; 1312 } 745 } 1313 746 1314 if (vp.IsCulling () && vp.IsCullingInvisibl 747 if (vp.IsCulling () && vp.IsCullingInvisible ()) { 1315 static G4bool warned = false; 748 static G4bool warned = false; 1316 if (fVerbosity >= confirmations) { 749 if (fVerbosity >= confirmations) { 1317 if (!warned) { 750 if (!warned) { 1318 G4cout << 751 G4cout << 1319 "NOTE: objects with visibility flag set to 752 "NOTE: objects with visibility flag set to \"false\"" 1320 " will not be drawn!" 753 " will not be drawn!" 1321 "\n \"/vis/viewer/set/culling global false 754 "\n \"/vis/viewer/set/culling global false\" to Draw such objects." 1322 "\n Also see other \"/vis/viewer/set\" com 755 "\n Also see other \"/vis/viewer/set\" commands." 1323 << G4endl; 756 << G4endl; 1324 warned = true; 757 warned = true; 1325 } 758 } 1326 } 759 } 1327 } 760 } 1328 if (vp.IsCullingCovered ()) { 761 if (vp.IsCullingCovered ()) { 1329 static G4bool warned = false; 762 static G4bool warned = false; 1330 if (fVerbosity >= warnings) { 763 if (fVerbosity >= warnings) { 1331 if (!warned) { 764 if (!warned) { 1332 G4warn << << 765 G4cout << 1333 "WARNING: covered objects in solid mode wil 766 "WARNING: covered objects in solid mode will not be rendered!" 1334 "\n \"/vis/viewer/set/culling coveredDaugh 767 "\n \"/vis/viewer/set/culling coveredDaughters false\" to reverse this." 1335 "\n Also see other \"/vis/viewer/set\" com 768 "\n Also see other \"/vis/viewer/set\" commands." 1336 << G4endl; 769 << G4endl; 1337 warned = true; 770 warned = true; 1338 } 771 } 1339 } 772 } 1340 } 773 } 1341 } 774 } 1342 775 1343 void G4VisManager::GeometryHasChanged () { 776 void G4VisManager::GeometryHasChanged () { 1344 if (fVerbosity >= confirmations) { 777 if (fVerbosity >= confirmations) { 1345 G4cout << "G4VisManager::GeometryHasChang 778 G4cout << "G4VisManager::GeometryHasChanged() called." << G4endl; 1346 } 779 } 1347 780 1348 // Change the world... 781 // Change the world... 1349 G4VPhysicalVolume* pWorld = 782 G4VPhysicalVolume* pWorld = 1350 G4TransportationManager::GetTransportatio 783 G4TransportationManager::GetTransportationManager () 1351 -> GetNavigatorForTracking () -> GetWorld 784 -> GetNavigatorForTracking () -> GetWorldVolume (); 1352 if (!pWorld) { 785 if (!pWorld) { 1353 if (fVerbosity >= warnings) { 786 if (fVerbosity >= warnings) { 1354 G4warn << "WARNING: There is no world v << 787 G4cout << "WARNING: There is no world volume!" << G4endl; 1355 } 788 } 1356 } 789 } 1357 790 1358 // Check scenes. 791 // Check scenes. 1359 G4SceneList& sceneList = fSceneList; 792 G4SceneList& sceneList = fSceneList; 1360 std::size_t iScene, nScenes = sceneList.siz << 793 G4int iScene, nScenes = sceneList.size (); 1361 for (iScene = 0; iScene < nScenes; ++iScene << 794 for (iScene = 0; iScene < nScenes; iScene++) { 1362 G4Scene* pScene = sceneList [iScene]; 795 G4Scene* pScene = sceneList [iScene]; 1363 std::vector<G4Scene::Model>& modelList = << 796 std::vector<G4VModel*>& modelList = pScene -> SetRunDurationModelList (); >> 797 1364 if (modelList.size ()) { 798 if (modelList.size ()) { 1365 G4bool modelInvalid; 799 G4bool modelInvalid; 1366 do { // Remove, if required, one at a 800 do { // Remove, if required, one at a time. 1367 modelInvalid = false; 801 modelInvalid = false; 1368 std::vector<G4Scene::Model>::iterator iterM << 802 std::vector<G4VModel*>::iterator iterModel; 1369 for (iterModel = modelList.begin(); 803 for (iterModel = modelList.begin(); 1370 iterModel != modelList.end(); 804 iterModel != modelList.end(); 1371 ++iterModel) { 805 ++iterModel) { 1372 modelInvalid = !(iterModel->fpModel->Vali << 806 modelInvalid = !((*iterModel) -> Validate (fVerbosity >= warnings)); 1373 if (modelInvalid) { 807 if (modelInvalid) { 1374 // Model invalid - remove and break. 808 // Model invalid - remove and break. 1375 if (fVerbosity >= warnings) { 809 if (fVerbosity >= warnings) { 1376 G4warn << "WARNING: Model \"" << 810 G4cout << "WARNING: Model \"" 1377 << iterModel->fpModel->GetGlobalDesc << 811 << (*iterModel) -> GetGlobalDescription () 1378 << 812 << 1379 "\" is no longer valid - being removed\n 813 "\" is no longer valid - being removed\n from scene \"" 1380 << pScene -> GetName () << "\"" 814 << pScene -> GetName () << "\"" 1381 << G4endl; 815 << G4endl; 1382 } 816 } 1383 modelList.erase (iterModel); 817 modelList.erase (iterModel); 1384 break; 818 break; 1385 } 819 } 1386 } 820 } 1387 } while (modelInvalid); 821 } while (modelInvalid); 1388 822 1389 if (modelList.size () == 0) { 823 if (modelList.size () == 0) { 1390 if (fVerbosity >= warnings) { 824 if (fVerbosity >= warnings) { 1391 G4warn << "WARNING: No run-duration model << 825 G4cout << "WARNING: No models left in this scene \"" 1392 << pScene -> GetName () 826 << pScene -> GetName () 1393 << "\"." 827 << "\"." 1394 << G4endl; 828 << G4endl; 1395 } 829 } 1396 if (pWorld) { << 1397 if (fVerbosity >= warnings) { << 1398 G4warn << " Adding current world << 1399 << pScene -> GetName () << 1400 << "\"." << 1401 << G4endl; << 1402 } << 1403 pScene->AddRunDurationModel(new G4P << 1404 // (The above includes a re-calcula << 1405 G4UImanager::GetUIpointer () -> << 1406 ApplyCommand (G4String("/vis/scene/ << 1407 } << 1408 } 830 } 1409 else { 831 else { 1410 pScene->CalculateExtent(); // Recalculate << 832 pScene->CalculateExtent(); 1411 G4UImanager::GetUIpointer () -> 833 G4UImanager::GetUIpointer () -> 1412 ApplyCommand (G4String("/vis/scene/notify 834 ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName())); 1413 } 835 } 1414 } 836 } 1415 } 837 } 1416 838 1417 // Check the manager's current scene... 839 // Check the manager's current scene... 1418 if (fpScene && fpScene -> GetRunDurationMod 840 if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) { 1419 if (fVerbosity >= warnings) { 841 if (fVerbosity >= warnings) { 1420 G4warn << "WARNING: The current scene \ << 842 G4cout << "WARNING: The current scene \"" 1421 << fpScene -> GetName () 843 << fpScene -> GetName () 1422 << "\" has no run duration models." << 844 << "\" has no models." 1423 << "\n Use \"/vis/scene/add/vol << 1424 << G4endl; 845 << G4endl; 1425 } 846 } 1426 // Clean up << 1427 if (fpSceneHandler) { << 1428 fpSceneHandler->ClearTransientStore(); << 1429 fpSceneHandler->ClearStore(); << 1430 if (fpViewer) { << 1431 fpViewer->NeedKernelVisit(); << 1432 fpViewer->SetView(); << 1433 fpViewer->ClearView(); << 1434 fpViewer->FinishView(); << 1435 } << 1436 } << 1437 } 847 } 1438 } << 1439 848 >> 849 } 1440 void G4VisManager::NotifyHandlers () { 850 void G4VisManager::NotifyHandlers () { 1441 851 1442 if (fVerbosity >= confirmations) { 852 if (fVerbosity >= confirmations) { 1443 G4cout << "G4VisManager::NotifyHandler() 853 G4cout << "G4VisManager::NotifyHandler() called." << G4endl; 1444 } 854 } 1445 855 1446 if (IsValidView()) { << 856 // Check scenes. 1447 << 857 G4SceneList& sceneList = fSceneList; 1448 // Check scenes. << 858 G4int iScene, nScenes = sceneList.size (); 1449 G4SceneList& sceneList = fSceneList; << 859 for (iScene = 0; iScene < nScenes; iScene++) { 1450 std::size_t iScene, nScenes = sceneList.s << 860 G4Scene* pScene = sceneList [iScene]; 1451 for (iScene = 0; iScene < nScenes; ++iSce << 861 std::vector<G4VModel*>& modelList = pScene -> SetRunDurationModelList (); 1452 G4Scene* pScene = sceneList [iScene]; << 862 1453 std::vector<G4Scene::Model>& modelList << 863 if (modelList.size ()) { 1454 << 864 pScene->CalculateExtent(); 1455 if (modelList.size ()) { << 865 G4UImanager::GetUIpointer () -> 1456 pScene->CalculateExtent(); << 1457 G4UImanager::GetUIpointer () -> << 1458 ApplyCommand (G4String("/vis/scene/no 866 ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName())); 1459 } << 1460 } 867 } >> 868 } 1461 869 1462 // Check the manager's current scene... << 870 // Check the manager's current scene... 1463 if (fpScene && fpScene -> GetRunDurationM << 871 if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) { 1464 if (fVerbosity >= warnings) { << 872 if (fVerbosity >= warnings) { 1465 G4warn << "WARNING: The current scene << 873 G4cout << "WARNING: The current scene \"" 1466 << fpScene -> GetName () << 874 << fpScene -> GetName () 1467 << "\" has no run duration models." << 875 << "\" has no models." 1468 << "\n Use \"/vis/scene/add/volume\" << 876 << G4endl; 1469 << G4endl; << 1470 } << 1471 fpSceneHandler->ClearTransientStore(); << 1472 fpSceneHandler->ClearStore(); << 1473 fpViewer->NeedKernelVisit(); << 1474 fpViewer->SetView(); << 1475 fpViewer->ClearView(); << 1476 fpViewer->FinishView(); << 1477 } 877 } 1478 } 878 } >> 879 1479 } 880 } 1480 881 1481 G4bool G4VisManager::FilterTrajectory(const G 882 G4bool G4VisManager::FilterTrajectory(const G4VTrajectory& trajectory) 1482 { 883 { 1483 return fpTrajFilterMgr->Accept(trajectory); 884 return fpTrajFilterMgr->Accept(trajectory); 1484 } 885 } 1485 886 1486 G4bool G4VisManager::FilterHit(const G4VHit& 887 G4bool G4VisManager::FilterHit(const G4VHit& hit) 1487 { 888 { 1488 return fpHitFilterMgr->Accept(hit); 889 return fpHitFilterMgr->Accept(hit); 1489 } 890 } 1490 891 1491 G4bool G4VisManager::FilterDigi(const G4VDigi 892 G4bool G4VisManager::FilterDigi(const G4VDigi& digi) 1492 { 893 { 1493 return fpDigiFilterMgr->Accept(digi); 894 return fpDigiFilterMgr->Accept(digi); 1494 } 895 } 1495 896 1496 void G4VisManager::DispatchToModel(const G4VT 897 void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory) 1497 { 898 { 1498 G4bool visible(true); 899 G4bool visible(true); 1499 900 1500 // See if trajectory passes filter 901 // See if trajectory passes filter 1501 G4bool passed = FilterTrajectory(trajectory 902 G4bool passed = FilterTrajectory(trajectory); 1502 903 1503 if (!passed) { 904 if (!passed) { 1504 // Draw invisible trajectory if trajector 905 // Draw invisible trajectory if trajectory failed filter and 1505 // are filtering in soft mode 906 // are filtering in soft mode 1506 if (fpTrajFilterMgr->GetMode() == FilterM 907 if (fpTrajFilterMgr->GetMode() == FilterMode::Soft) visible = false; 1507 else {return;} 908 else {return;} 1508 } 909 } 1509 910 1510 // Go on to draw trajectory 911 // Go on to draw trajectory 1511 assert (0 != fpTrajDrawModelMgr); 912 assert (0 != fpTrajDrawModelMgr); 1512 913 1513 const G4VTrajectoryModel* trajectoryModel = 914 const G4VTrajectoryModel* trajectoryModel = CurrentTrajDrawModel(); 1514 915 1515 assert (0 != trajectoryModel); // Should ex 916 assert (0 != trajectoryModel); // Should exist 1516 917 1517 if (IsValidView()) { << 918 trajectoryModel->Draw(trajectory, visible); 1518 trajectoryModel->Draw(trajectory, visib << 1519 } << 1520 } 919 } 1521 920 1522 void G4VisManager::RegisterRunDurationUserVis << 921 void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory, G4int i_mode) 1523 (const G4String& name, << 922 { 1524 G4VUserVisAction* pVisAction, << 923 G4bool visible(true); 1525 const G4VisExtent& extent) { << 924 1526 fRunDurationUserVisActions.push_back(UserVi << 925 // See if trajectory passes filter 1527 if (extent.GetExtentRadius() > 0.) { << 926 G4bool passed = FilterTrajectory(trajectory); 1528 fUserVisActionExtents[pVisAction] = exten << 927 1529 } else { << 928 if (!passed) { 1530 if (fVerbosity >= warnings) { << 929 // Draw invisible trajectory if trajectory failed filter and 1531 G4warn << << 930 // are filtering in soft mode 1532 "WARNING: No extent set for user vis action << 931 if (fpTrajFilterMgr->GetMode() == FilterMode::Soft) visible = false; 1533 << G4endl; << 932 else {return;} 1534 } << 1535 } << 1536 if (fVerbosity >= confirmations) { << 1537 G4cout << 1538 << "Run duration user vis action \"" << n << 1539 << G4endl; << 1540 } 933 } 1541 } << 1542 934 1543 void G4VisManager::RegisterEndOfEventUserVisA << 935 // Go on to draw trajectory 1544 (const G4String& name, << 936 assert (0 != fpTrajDrawModelMgr); 1545 G4VUserVisAction* pVisAction, << 937 1546 const G4VisExtent& extent) { << 938 const G4VTrajectoryModel* trajectoryModel = CurrentTrajDrawModel(); 1547 fEndOfEventUserVisActions.push_back(UserVis << 939 1548 if (extent.GetExtentRadius() > 0.) { << 940 assert (0 != trajectoryModel); // Should exist 1549 fUserVisActionExtents[pVisAction] = exten << 941 1550 } else { << 942 if (IsValidView()) { 1551 if (fVerbosity >= warnings) { << 943 G4TrajectoriesModel* trajectoriesModel = 1552 G4warn << << 944 dynamic_cast<G4TrajectoriesModel*>(fpSceneHandler->GetModel()); 1553 "WARNING: No extent set for user vis action << 945 if (trajectoriesModel) { 1554 << G4endl; << 946 if (trajectoriesModel->IsDrawingModeSet()) { >> 947 trajectoryModel->Draw(trajectory, i_mode, visible); >> 948 } else { >> 949 trajectoryModel->Draw(trajectory, visible); >> 950 } >> 951 } else { >> 952 // Just draw at user's request >> 953 trajectoryModel->Draw(trajectory, i_mode, visible); 1555 } 954 } 1556 } 955 } 1557 if (fVerbosity >= confirmations) { << 1558 G4cout << 1559 << "End of event user vis action \"" << n << 1560 << G4endl; << 1561 } << 1562 } 956 } 1563 957 1564 void G4VisManager::RegisterEndOfRunUserVisAct << 958 void G4VisManager::SetUserAction 1565 (const G4String& name, << 959 (G4VUserVisAction* pVisAction, 1566 G4VUserVisAction* pVisAction, << 1567 const G4VisExtent& extent) { 960 const G4VisExtent& extent) { 1568 fEndOfRunUserVisActions.push_back(UserVisAc << 961 fpUserVisAction = pVisAction; 1569 if (extent.GetExtentRadius() > 0.) { << 962 fUserVisActionExtent = extent; 1570 fUserVisActionExtents[pVisAction] = exten << 963 if (extent.GetExtentRadius() <= 0.) { 1571 } else { << 1572 if (fVerbosity >= warnings) { 964 if (fVerbosity >= warnings) { 1573 G4warn << << 965 G4cout << 1574 "WARNING: No extent set for user vis action << 966 "WARNING: No extent set for user vis action. (You may" >> 967 "\n set it later when adding with /vis/scene/add/userAction.)" 1575 << G4endl; 968 << G4endl; 1576 } 969 } 1577 } 970 } 1578 if (fVerbosity >= confirmations) { << 1579 G4cout << 1580 << "End of run user vis action \"" << nam << 1581 << G4endl; << 1582 } << 1583 } 971 } 1584 972 1585 void G4VisManager::SetCurrentScene (G4Scene* 973 void G4VisManager::SetCurrentScene (G4Scene* pScene) { 1586 if (pScene != fpScene) { 974 if (pScene != fpScene) { 1587 // A change of scene. Therefore reset tr 975 // A change of scene. Therefore reset transients drawn flags. All 1588 // memory of previous transient proceessi 976 // memory of previous transient proceessing thereby erased... 1589 ResetTransientsDrawnFlags(); 977 ResetTransientsDrawnFlags(); 1590 } 978 } 1591 fpScene = pScene; 979 fpScene = pScene; 1592 } 980 } 1593 981 1594 void G4VisManager::SetCurrentGraphicsSystem ( 982 void G4VisManager::SetCurrentGraphicsSystem (G4VGraphicsSystem* pSystem) { 1595 fpGraphicsSystem = pSystem; 983 fpGraphicsSystem = pSystem; 1596 if (fVerbosity >= confirmations) { 984 if (fVerbosity >= confirmations) { 1597 G4cout << "G4VisManager::SetCurrentGraphi 985 G4cout << "G4VisManager::SetCurrentGraphicsSystem: system now " 1598 << pSystem -> GetName () << G4endl; 986 << pSystem -> GetName () << G4endl; 1599 } 987 } 1600 // If current scene handler is of same grap 988 // If current scene handler is of same graphics system, leave unchanged. 1601 // Else find the most recent scene handler 989 // Else find the most recent scene handler of same graphics system. 1602 // Or clear pointers. 990 // Or clear pointers. 1603 if (!(fpSceneHandler && fpSceneHandler -> G 991 if (!(fpSceneHandler && fpSceneHandler -> GetGraphicsSystem () == pSystem)) { 1604 const G4SceneHandlerList& sceneHandlerLis 992 const G4SceneHandlerList& sceneHandlerList = fAvailableSceneHandlers; 1605 G4int nSH = (G4int)sceneHandlerList.size << 993 G4int nSH = sceneHandlerList.size (); // No. of scene handlers. 1606 G4int iSH; 994 G4int iSH; 1607 for (iSH = nSH - 1; iSH >= 0; iSH--) { 995 for (iSH = nSH - 1; iSH >= 0; iSH--) { 1608 if (sceneHandlerList [iSH] -> GetGraphi 996 if (sceneHandlerList [iSH] -> GetGraphicsSystem () == pSystem) break; 1609 } 997 } 1610 if (iSH >= 0) { 998 if (iSH >= 0) { 1611 fpSceneHandler = sceneHandlerList [iSH] 999 fpSceneHandler = sceneHandlerList [iSH]; 1612 if (fVerbosity >= confirmations) { 1000 if (fVerbosity >= confirmations) { 1613 G4cout << " Scene Handler now " 1001 G4cout << " Scene Handler now " 1614 << fpSceneHandler -> GetName () << G 1002 << fpSceneHandler -> GetName () << G4endl; 1615 } 1003 } 1616 if (fpScene != fpSceneHandler -> GetSce 1004 if (fpScene != fpSceneHandler -> GetScene ()) { 1617 fpScene = fpSceneHandler -> GetScene (); 1005 fpScene = fpSceneHandler -> GetScene (); 1618 if (fVerbosity >= confirmations) { 1006 if (fVerbosity >= confirmations) { 1619 G4cout << " Scene now \"" 1007 G4cout << " Scene now \"" 1620 << fpScene -> GetName () << "\"" << G4en 1008 << fpScene -> GetName () << "\"" << G4endl; 1621 } 1009 } 1622 } 1010 } 1623 const G4ViewerList& viewerList = fpScen 1011 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList (); 1624 if (viewerList.size ()) { 1012 if (viewerList.size ()) { 1625 fpViewer = viewerList [0]; 1013 fpViewer = viewerList [0]; 1626 if (fVerbosity >= confirmations) { 1014 if (fVerbosity >= confirmations) { 1627 G4cout << " Viewer now " << fpViewer -> 1015 G4cout << " Viewer now " << fpViewer -> GetName () << G4endl; 1628 } 1016 } 1629 } 1017 } 1630 else { 1018 else { 1631 fpViewer = 0; 1019 fpViewer = 0; 1632 } 1020 } 1633 } 1021 } 1634 else { 1022 else { 1635 fpSceneHandler = 0; 1023 fpSceneHandler = 0; 1636 fpViewer = 0; 1024 fpViewer = 0; 1637 } 1025 } 1638 } 1026 } 1639 } 1027 } 1640 1028 1641 void G4VisManager::SetCurrentSceneHandler (G4 1029 void G4VisManager::SetCurrentSceneHandler (G4VSceneHandler* pSceneHandler) { 1642 fpSceneHandler = pSceneHandler; 1030 fpSceneHandler = pSceneHandler; 1643 if (fVerbosity >= confirmations) { 1031 if (fVerbosity >= confirmations) { 1644 G4cout << "G4VisManager::SetCurrentSceneH 1032 G4cout << "G4VisManager::SetCurrentSceneHandler: scene handler now \"" 1645 << pSceneHandler -> GetName () << "\"" < 1033 << pSceneHandler -> GetName () << "\"" << G4endl; 1646 } 1034 } 1647 if (fpScene != fpSceneHandler -> GetScene ( 1035 if (fpScene != fpSceneHandler -> GetScene ()) { 1648 fpScene = fpSceneHandler -> GetScene (); 1036 fpScene = fpSceneHandler -> GetScene (); 1649 if (fVerbosity >= confirmations) { 1037 if (fVerbosity >= confirmations) { 1650 G4cout << " Scene now \"" 1038 G4cout << " Scene now \"" 1651 << fpScene -> GetName () << "\"" << G4 1039 << fpScene -> GetName () << "\"" << G4endl; 1652 } 1040 } 1653 } 1041 } 1654 if (fpGraphicsSystem != pSceneHandler -> Ge 1042 if (fpGraphicsSystem != pSceneHandler -> GetGraphicsSystem ()) { 1655 fpGraphicsSystem = pSceneHandler -> GetGr 1043 fpGraphicsSystem = pSceneHandler -> GetGraphicsSystem (); 1656 if (fVerbosity >= confirmations) { 1044 if (fVerbosity >= confirmations) { 1657 G4cout << " Graphics system now \"" 1045 G4cout << " Graphics system now \"" 1658 << fpGraphicsSystem -> GetName () << " 1046 << fpGraphicsSystem -> GetName () << "\"" << G4endl; 1659 } 1047 } 1660 } 1048 } 1661 const G4ViewerList& viewerList = fpSceneHan 1049 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList (); 1662 std::size_t nViewers = viewerList.size (); << 1050 G4int nViewers = viewerList.size (); 1663 if (nViewers) { 1051 if (nViewers) { 1664 std::size_t iViewer; << 1052 G4int iViewer; 1665 for (iViewer = 0; iViewer < nViewers; ++i << 1053 for (iViewer = 0; iViewer < nViewers; iViewer++) { 1666 if (fpViewer == viewerList [iViewer]) b 1054 if (fpViewer == viewerList [iViewer]) break; 1667 } 1055 } 1668 if (iViewer >= nViewers) { 1056 if (iViewer >= nViewers) { 1669 fpViewer = viewerList [0]; 1057 fpViewer = viewerList [0]; 1670 if (fVerbosity >= confirmations) { 1058 if (fVerbosity >= confirmations) { 1671 G4cout << " Viewer now \"" << fpViewer -> 1059 G4cout << " Viewer now \"" << fpViewer -> GetName () << "\"" 1672 << G4endl; 1060 << G4endl; 1673 } 1061 } 1674 } 1062 } 1675 if (!IsValidView ()) { 1063 if (!IsValidView ()) { 1676 if (fVerbosity >= warnings) { 1064 if (fVerbosity >= warnings) { 1677 G4warn << << 1065 G4cout << 1678 "WARNING: Problem setting scene handler - p 1066 "WARNING: Problem setting scene handler - please report circumstances." 1679 << G4endl; 1067 << G4endl; 1680 } 1068 } 1681 } 1069 } 1682 } 1070 } 1683 else { 1071 else { 1684 fpViewer = 0; 1072 fpViewer = 0; 1685 if (fVerbosity >= warnings) { 1073 if (fVerbosity >= warnings) { 1686 G4warn << << 1074 G4cout << 1687 "WARNING: No viewers for this scene handler 1075 "WARNING: No viewers for this scene handler - please create one." 1688 << G4endl; 1076 << G4endl; 1689 } 1077 } 1690 } 1078 } 1691 } 1079 } 1692 1080 1693 void G4VisManager::SetCurrentViewer (G4VViewe 1081 void G4VisManager::SetCurrentViewer (G4VViewer* pViewer) { 1694 fpViewer = pViewer; 1082 fpViewer = pViewer; 1695 if (fpViewer == nullptr) { << 1696 if (fVerbosity >= confirmations) { << 1697 G4cout << "G4VisManager::SetCurrentView << 1698 << G4endl; << 1699 } << 1700 return; << 1701 } << 1702 if (fVerbosity >= confirmations) { 1083 if (fVerbosity >= confirmations) { 1703 G4cout << "G4VisManager::SetCurrentViewer 1084 G4cout << "G4VisManager::SetCurrentViewer: viewer now " 1704 << pViewer -> GetName () 1085 << pViewer -> GetName () 1705 << G4endl; 1086 << G4endl; 1706 } 1087 } 1707 fpSceneHandler = fpViewer -> GetSceneHandle 1088 fpSceneHandler = fpViewer -> GetSceneHandler (); 1708 if (!fpSceneHandler) { << 1709 if (fVerbosity >= warnings) { << 1710 G4warn << << 1711 "WARNING: No scene handler for this vie << 1712 << G4endl; << 1713 } << 1714 return; << 1715 } << 1716 // JA: I don't think we need this. Setview << 1717 // fpViewer->SetView(); << 1718 fpSceneHandler -> SetCurrentViewer (pViewer 1089 fpSceneHandler -> SetCurrentViewer (pViewer); 1719 fpScene = fpSceneHandler -> GetScene (); 1090 fpScene = fpSceneHandler -> GetScene (); 1720 fpGraphicsSystem = fpSceneHandler -> GetGra 1091 fpGraphicsSystem = fpSceneHandler -> GetGraphicsSystem (); 1721 if (!IsValidView ()) { 1092 if (!IsValidView ()) { 1722 if (fVerbosity >= warnings) { 1093 if (fVerbosity >= warnings) { 1723 G4warn << << 1094 G4cout << 1724 "WARNING: Problem setting viewer - please r 1095 "WARNING: Problem setting viewer - please report circumstances." 1725 << G4endl; 1096 << G4endl; 1726 } 1097 } 1727 } 1098 } 1728 } 1099 } 1729 1100 1730 void G4VisManager::PrintAvailableGraphicsSyst << 1101 void G4VisManager::RegisterMessengers () { 1731 (Verbosity verbosity, std::ostream& out) cons << 1102 1732 { << 1103 // Instantiate individual messengers/commands (often - but not 1733 out << "Registered graphics systems are:\n" << 1104 // always - one command per messenger). 1734 if (fAvailableGraphicsSystems.size ()) { << 1105 1735 for (const auto& gs: fAvailableGraphicsSy << 1106 G4UIcommand* directory; 1736 const G4String& name = gs->GetName(); << 1107 1737 const std::vector<G4String>& nicknames << 1108 // Top level commands... 1738 if (verbosity >= warnings) { << 1109 RegisterMessenger(new G4VisCommandAbortReviewKeptEvents); 1739 // Brief output << 1110 RegisterMessenger(new G4VisCommandEnable); 1740 out << " " << name << " ("; << 1111 RegisterMessenger(new G4VisCommandList); 1741 for (std::size_t i = 0; i < nicknames << 1112 RegisterMessenger(new G4VisCommandReviewKeptEvents); 1742 if (i != 0) { << 1113 1743 out << ", "; << 1114 // Compound commands... 1744 } << 1115 RegisterMessenger(new G4VisCommandDrawTree); 1745 out << nicknames[i]; << 1116 RegisterMessenger(new G4VisCommandDrawView); 1746 } << 1117 RegisterMessenger(new G4VisCommandDrawVolume); 1747 out << ')'; << 1118 RegisterMessenger(new G4VisCommandOpen); 1748 } else { << 1119 RegisterMessenger(new G4VisCommandSpecify); 1749 // Full output << 1120 1750 out << *gs; << 1121 directory = new G4UIdirectory ("/vis/geometry/"); >> 1122 directory -> SetGuidance("Operations on vis attributes of Geant4 geometry."); >> 1123 fDirectoryList.push_back (directory); >> 1124 RegisterMessenger(new G4VisCommandGeometryList); >> 1125 RegisterMessenger(new G4VisCommandGeometryRestore); >> 1126 >> 1127 directory = new G4UIdirectory ("/vis/geometry/set/"); >> 1128 directory -> SetGuidance("Set vis attributes of Geant4 geometry."); >> 1129 fDirectoryList.push_back (directory); >> 1130 RegisterMessenger(new G4VisCommandGeometrySetColour); >> 1131 RegisterMessenger(new G4VisCommandGeometrySetDaughtersInvisible); >> 1132 RegisterMessenger(new G4VisCommandGeometrySetLineStyle); >> 1133 RegisterMessenger(new G4VisCommandGeometrySetLineWidth); >> 1134 RegisterMessenger(new G4VisCommandGeometrySetForceAuxEdgeVisible); >> 1135 RegisterMessenger(new G4VisCommandGeometrySetForceLineSegmentsPerCircle); >> 1136 RegisterMessenger(new G4VisCommandGeometrySetForceSolid); >> 1137 RegisterMessenger(new G4VisCommandGeometrySetForceWireframe); >> 1138 RegisterMessenger(new G4VisCommandGeometrySetVisibility); >> 1139 >> 1140 directory = new G4UIdirectory ("/vis/scene/"); >> 1141 directory -> SetGuidance ("Operations on Geant4 scenes."); >> 1142 fDirectoryList.push_back (directory); >> 1143 RegisterMessenger(new G4VisCommandSceneCreate); >> 1144 RegisterMessenger(new G4VisCommandSceneEndOfEventAction); >> 1145 RegisterMessenger(new G4VisCommandSceneEndOfRunAction); >> 1146 RegisterMessenger(new G4VisCommandSceneList); >> 1147 RegisterMessenger(new G4VisCommandSceneNotifyHandlers); >> 1148 RegisterMessenger(new G4VisCommandSceneSelect); >> 1149 >> 1150 directory = new G4UIdirectory ("/vis/scene/add/"); >> 1151 directory -> SetGuidance ("Add model to current scene."); >> 1152 fDirectoryList.push_back (directory); >> 1153 RegisterMessenger(new G4VisCommandSceneAddAxes); >> 1154 RegisterMessenger(new G4VisCommandSceneAddEventID); >> 1155 RegisterMessenger(new G4VisCommandSceneAddGhosts); >> 1156 RegisterMessenger(new G4VisCommandSceneAddHits); >> 1157 RegisterMessenger(new G4VisCommandSceneAddDigis); >> 1158 RegisterMessenger(new G4VisCommandSceneAddLogicalVolume); >> 1159 RegisterMessenger(new G4VisCommandSceneAddLogo); >> 1160 RegisterMessenger(new G4VisCommandSceneAddPSHits); >> 1161 RegisterMessenger(new G4VisCommandSceneAddScale); >> 1162 RegisterMessenger(new G4VisCommandSceneAddText); >> 1163 RegisterMessenger(new G4VisCommandSceneAddTrajectories); >> 1164 RegisterMessenger(new G4VisCommandSceneAddUserAction); >> 1165 RegisterMessenger(new G4VisCommandSceneAddVolume); >> 1166 >> 1167 directory = new G4UIdirectory ("/vis/sceneHandler/"); >> 1168 directory -> SetGuidance ("Operations on Geant4 scene handlers."); >> 1169 fDirectoryList.push_back (directory); >> 1170 RegisterMessenger(new G4VisCommandSceneHandlerAttach); >> 1171 RegisterMessenger(new G4VisCommandSceneHandlerCreate); >> 1172 RegisterMessenger(new G4VisCommandSceneHandlerList); >> 1173 RegisterMessenger(new G4VisCommandSceneHandlerSelect); >> 1174 >> 1175 directory = new G4UIdirectory ("/vis/viewer/"); >> 1176 directory -> SetGuidance ("Operations on Geant4 viewers."); >> 1177 fDirectoryList.push_back (directory); >> 1178 RegisterMessenger(new G4VisCommandViewerAddCutawayPlane); >> 1179 RegisterMessenger(new G4VisCommandViewerChangeCutawayPlane); >> 1180 RegisterMessenger(new G4VisCommandViewerClear); >> 1181 RegisterMessenger(new G4VisCommandViewerClearCutawayPlanes); >> 1182 RegisterMessenger(new G4VisCommandViewerClearTransients); >> 1183 RegisterMessenger(new G4VisCommandViewerClone); >> 1184 RegisterMessenger(new G4VisCommandViewerCreate); >> 1185 RegisterMessenger(new G4VisCommandViewerDolly); >> 1186 RegisterMessenger(new G4VisCommandViewerFlush); >> 1187 RegisterMessenger(new G4VisCommandViewerList); >> 1188 RegisterMessenger(new G4VisCommandViewerPan); >> 1189 RegisterMessenger(new G4VisCommandViewerRebuild); >> 1190 RegisterMessenger(new G4VisCommandViewerRefresh); >> 1191 RegisterMessenger(new G4VisCommandViewerReset); >> 1192 RegisterMessenger(new G4VisCommandViewerScale); >> 1193 RegisterMessenger(new G4VisCommandViewerSelect); >> 1194 RegisterMessenger(new G4VisCommandViewerUpdate); >> 1195 RegisterMessenger(new G4VisCommandViewerZoom); >> 1196 >> 1197 directory = new G4UIdirectory ("/vis/viewer/set/"); >> 1198 directory -> SetGuidance ("Set view parameters of current viewer."); >> 1199 fDirectoryList.push_back (directory); >> 1200 RegisterMessenger(new G4VisCommandsViewerSet); >> 1201 >> 1202 // List manager commands >> 1203 RegisterMessenger(new G4VisCommandListManagerList< G4VisModelManager<G4VTrajectoryModel> > >> 1204 (fpTrajDrawModelMgr, fpTrajDrawModelMgr->Placement())); >> 1205 RegisterMessenger(new G4VisCommandListManagerSelect< G4VisModelManager<G4VTrajectoryModel> > >> 1206 (fpTrajDrawModelMgr, fpTrajDrawModelMgr->Placement())); >> 1207 >> 1208 // Trajectory filter manager commands >> 1209 RegisterMessenger(new G4VisCommandListManagerList< G4VisFilterManager<G4VTrajectory> > >> 1210 (fpTrajFilterMgr, fpTrajFilterMgr->Placement())); >> 1211 RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VTrajectory> > >> 1212 (fpTrajFilterMgr, fpTrajFilterMgr->Placement())); >> 1213 >> 1214 // Hit filter manager commands >> 1215 RegisterMessenger(new G4VisCommandListManagerList< G4VisFilterManager<G4VHit> > >> 1216 (fpHitFilterMgr, fpHitFilterMgr->Placement())); >> 1217 RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VHit> > >> 1218 (fpHitFilterMgr, fpHitFilterMgr->Placement())); >> 1219 >> 1220 // Digi filter manager commands >> 1221 RegisterMessenger(new G4VisCommandListManagerList< G4VisFilterManager<G4VDigi> > >> 1222 (fpDigiFilterMgr, fpDigiFilterMgr->Placement())); >> 1223 RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VDigi> > >> 1224 (fpDigiFilterMgr, fpDigiFilterMgr->Placement())); >> 1225 } >> 1226 >> 1227 void G4VisManager::PrintAvailableGraphicsSystems () const { >> 1228 G4int nSystems = fAvailableGraphicsSystems.size (); >> 1229 G4cout << "Current available graphics systems are:"; >> 1230 if (nSystems) { >> 1231 for (int i = 0; i < nSystems; i++) { >> 1232 const G4VGraphicsSystem* pSystem = fAvailableGraphicsSystems [i]; >> 1233 G4cout << "\n " << pSystem -> GetName (); >> 1234 if (pSystem -> GetNickname () != "") { >> 1235 G4cout << " (" << pSystem -> GetNickname () << ")"; 1751 } 1236 } 1752 out << std::endl; << 1753 } 1237 } 1754 out << << 1755 "You may choose a graphics system (driver << 1756 "\nthe command \"/vis/open\" or \"/vis/sc << 1757 "\nor you may omit the driver parameter a << 1758 "\n- by argument in the construction of G << 1759 "\n- by environment variable \"G4VIS_DEFA << 1760 "\n- by entry in \"~/.g4session\";" << 1761 "\n- by build flags." << 1762 "\n- Note: This feature is not allowed in << 1763 "\nFor further information see \"examples << 1764 "\nand \"vis.mac\"." << 1765 << std::endl; << 1766 } else { << 1767 out << " NONE!!! None registered - yet! << 1768 } 1238 } >> 1239 else { >> 1240 G4cout << "\n NONE!!! None registered - yet! Mmmmm!"; >> 1241 } >> 1242 G4cout << G4endl; 1769 } 1243 } 1770 1244 1771 void G4VisManager::PrintAvailableModels (Verb 1245 void G4VisManager::PrintAvailableModels (Verbosity verbosity) const 1772 { 1246 { 1773 { 1247 { 1774 //fpTrajDrawModelMgr->Print(G4cout); 1248 //fpTrajDrawModelMgr->Print(G4cout); 1775 G4cout << "Registered model factories:" < 1249 G4cout << "Registered model factories:" << G4endl; 1776 const std::vector<G4VModelFactory<G4VTraj 1250 const std::vector<G4VModelFactory<G4VTrajectoryModel>*>& factoryList = 1777 fpTrajDrawModelMgr->FactoryList(); 1251 fpTrajDrawModelMgr->FactoryList(); 1778 if (factoryList.empty()) G4cout << " Non 1252 if (factoryList.empty()) G4cout << " None" << G4endl; 1779 else { 1253 else { 1780 std::vector<G4VModelFactory<G4VTrajecto 1254 std::vector<G4VModelFactory<G4VTrajectoryModel>*>::const_iterator i; 1781 for (i = factoryList.begin(); i != fact << 1255 for (i = factoryList.begin(); i != factoryList.end(); ++i) 1782 (*i)->Print(G4cout); << 1256 (*i)->Print(G4cout); 1783 } << 1784 } 1257 } 1785 G4cout << "\nRegistered models:" << G4end << 1786 const G4VisListManager<G4VTrajectoryModel 1258 const G4VisListManager<G4VTrajectoryModel>* listManager = 1787 fpTrajDrawModelMgr->ListManager(); 1259 fpTrajDrawModelMgr->ListManager(); 1788 const std::map<G4String, G4VTrajectoryMod 1260 const std::map<G4String, G4VTrajectoryModel*>& modelMap = 1789 listManager->Map(); 1261 listManager->Map(); 1790 if (modelMap.empty()) G4cout << " None" << 1262 if (!modelMap.empty()) { 1791 else { << 1263 G4cout << "\nRegistered models:" << G4endl; 1792 std::map<G4String, G4VTrajectoryModel*> 1264 std::map<G4String, G4VTrajectoryModel*>::const_iterator i; 1793 for (i = modelMap.begin(); i != modelMa 1265 for (i = modelMap.begin(); i != modelMap.end(); ++i) { 1794 G4cout << " " << i->second->Name(); 1266 G4cout << " " << i->second->Name(); 1795 if (i->second == listManager->Current()) G4 1267 if (i->second == listManager->Current()) G4cout << " (Current)"; 1796 G4cout << G4endl; 1268 G4cout << G4endl; 1797 if (verbosity >= parameters) i->second->Pri 1269 if (verbosity >= parameters) i->second->Print(G4cout); 1798 } 1270 } 1799 } 1271 } 1800 } 1272 } 1801 1273 1802 G4cout << G4endl; 1274 G4cout << G4endl; 1803 1275 1804 { 1276 { 1805 //fpTrajFilterMgr->Print(G4cout); 1277 //fpTrajFilterMgr->Print(G4cout); 1806 G4cout << "Registered filter factories:" 1278 G4cout << "Registered filter factories:" << G4endl; 1807 const std::vector<G4VModelFactory<G4VFilt 1279 const std::vector<G4VModelFactory<G4VFilter<G4VTrajectory> >*>& 1808 factoryList = fpTrajFilterMgr->FactoryL 1280 factoryList = fpTrajFilterMgr->FactoryList(); 1809 if (factoryList.empty()) G4cout << " Non 1281 if (factoryList.empty()) G4cout << " None" << G4endl; 1810 else { 1282 else { 1811 std::vector<G4VModelFactory<G4VFilter<G 1283 std::vector<G4VModelFactory<G4VFilter<G4VTrajectory> >*>::const_iterator i; 1812 for (i = factoryList.begin(); i != fact << 1284 for (i = factoryList.begin(); i != factoryList.end(); ++i) 1813 (*i)->Print(G4cout); << 1285 (*i)->Print(G4cout); 1814 } << 1815 } 1286 } 1816 << 1817 G4cout << "\nRegistered filters:" << G4en << 1818 const std::vector<G4VFilter<G4VTrajectory 1287 const std::vector<G4VFilter<G4VTrajectory>*>& 1819 filterList = fpTrajFilterMgr->FilterLis 1288 filterList = fpTrajFilterMgr->FilterList(); 1820 if (filterList.empty()) G4cout << " None << 1289 if (!filterList.empty()) { 1821 else { << 1290 G4cout << "\nRegistered filters:" << G4endl; 1822 std::vector<G4VFilter<G4VTrajectory>*>: 1291 std::vector<G4VFilter<G4VTrajectory>*>::const_iterator i; 1823 for (i = filterList.begin(); i != filte 1292 for (i = filterList.begin(); i != filterList.end(); ++i) { 1824 G4cout << " " << (*i)->GetName() << G4endl 1293 G4cout << " " << (*i)->GetName() << G4endl; 1825 if (verbosity >= parameters) (*i)->PrintAll 1294 if (verbosity >= parameters) (*i)->PrintAll(G4cout); 1826 } 1295 } 1827 } 1296 } 1828 } 1297 } 1829 } 1298 } 1830 1299 1831 void G4VisManager::PrintAvailableUserVisActio << 1832 { << 1833 G4cout << << 1834 "You have successfully registered the fol << 1835 << G4endl; << 1836 G4cout << "Run Duration User Vis Actions:"; << 1837 if (fRunDurationUserVisActions.empty()) G4c << 1838 else { << 1839 G4cout << G4endl; << 1840 for (std::size_t i = 0; i < fRunDurationU << 1841 const G4String& name = fRunDurationUser << 1842 G4cout << " " << name << G4endl; << 1843 } << 1844 } << 1845 << 1846 G4cout << "End of Event User Vis Actions:"; << 1847 if (fEndOfEventUserVisActions.empty()) G4co << 1848 else { << 1849 G4cout << G4endl; << 1850 for (std::size_t i = 0; i < fEndOfEventUs << 1851 const G4String& name = fEndOfEventUserV << 1852 G4cout << " " << name << G4endl; << 1853 } << 1854 } << 1855 << 1856 G4cout << "End of Run User Vis Actions:"; << 1857 if (fEndOfRunUserVisActions.empty()) G4cout << 1858 else { << 1859 G4cout << G4endl; << 1860 for (std::size_t i = 0; i < fEndOfRunUser << 1861 const G4String& name = fEndOfRunUserVis << 1862 G4cout << " " << name << G4endl; << 1863 } << 1864 } << 1865 } << 1866 << 1867 void G4VisManager::PrintAvailableColours (Ver << 1868 G4cout << << 1869 "Some /vis commands (optionally) take a str << 1870 "\nThey are also available in your C++ code << 1871 "\n G4Colour niceColour; // Default - whi << 1872 "\n G4Colour::GetColour(\"pink\", niceColo << 1873 "\n logical->SetVisAttributes(niceColour); << 1874 "\nSee G4Colour.hh." << 1875 "\nAvailable colours"; << 1876 for (const auto& i: G4Colour::GetMap()) { << 1877 G4cout << ", " << i.first; << 1878 } << 1879 G4cout << G4endl; << 1880 } << 1881 << 1882 void G4VisManager::PrintInvalidPointers () co 1300 void G4VisManager::PrintInvalidPointers () const { 1883 if (fVerbosity >= errors) { 1301 if (fVerbosity >= errors) { 1884 G4warn << "ERROR: G4VisManager::PrintInva << 1302 G4cout << "ERROR: G4VisManager::PrintInvalidPointers:"; 1885 if (!fpGraphicsSystem) { 1303 if (!fpGraphicsSystem) { 1886 G4warn << "\n null graphics system poin << 1304 G4cout << "\n null graphics system pointer."; 1887 } 1305 } 1888 else { 1306 else { 1889 G4warn << "\n Graphics system is " << << 1307 G4cout << "\n Graphics system is " << fpGraphicsSystem -> GetName () 1890 << " but:"; 1308 << " but:"; 1891 if (!fpScene) 1309 if (!fpScene) 1892 G4warn << << 1310 G4cout << 1893 "\n Null scene pointer. Use \"/vis/drawV 1311 "\n Null scene pointer. Use \"/vis/drawVolume\" or" 1894 " \"/vis/scene/create\"."; 1312 " \"/vis/scene/create\"."; 1895 if (!fpSceneHandler) 1313 if (!fpSceneHandler) 1896 G4warn << << 1314 G4cout << 1897 "\n Null scene handler pointer. Use \"/v 1315 "\n Null scene handler pointer. Use \"/vis/open\" or" 1898 " \"/vis/sceneHandler/create\"."; 1316 " \"/vis/sceneHandler/create\"."; 1899 if (!fpViewer ) 1317 if (!fpViewer ) 1900 G4warn << << 1318 G4cout << 1901 "\n Null viewer pointer. Use \"/vis/view 1319 "\n Null viewer pointer. Use \"/vis/viewer/create\"."; 1902 } 1320 } 1903 G4warn << G4endl; << 1321 G4cout << G4endl; 1904 } << 1905 } << 1906 << 1907 << 1908 G4ThreadFunReturnType G4VisManager::G4VisSubT << 1909 { << 1910 #ifdef G4MULTITHREADED << 1911 G4VisManager* pVisManager = (G4VisManager*) << 1912 G4VSceneHandler* pSceneHandler = pVisManage << 1913 if (!pSceneHandler) return 0; << 1914 G4Scene* pScene = pSceneHandler->GetScene() << 1915 if (!pScene) return 0; << 1916 G4VViewer* pViewer = pVisManager->GetCurren << 1917 if (!pViewer) return 0; << 1918 << 1919 G4UImanager::GetUIpointer()->SetUpForSpecia << 1920 << 1921 // Set up geometry and navigation for a thr << 1922 G4GeometryWorkspace::GetPool()->CreateAndUs << 1923 G4SolidsWorkspace::GetPool()->CreateAndUseW << 1924 G4Navigator* navigator = G4TransportationMa << 1925 ->GetNavigatorFo << 1926 navigator->SetWorldVolume( << 1927 G4RunManagerFactory::GetMasterRunManagerK << 1928 << 1929 pViewer->SwitchToVisSubThread(); << 1930 << 1931 while (true) { << 1932 << 1933 G4MUTEXLOCK(&mtVisSubThreadMutex); << 1934 std::size_t eventQueueSize = mtVisEventQu << 1935 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 1936 // G4cout << "Event queue size (A): " << << 1937 << 1938 while (eventQueueSize) { << 1939 << 1940 G4MUTEXLOCK(&mtVisSubThreadMutex); << 1941 const G4Event* event = mtVisEventQueue. << 1942 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 1943 << 1944 // Here comes the event drawing << 1945 pVisManager->SetTransientsDrawnThisEven << 1946 pSceneHandler->SetTransientsDrawnThisEv << 1947 << 1948 // We are about to draw the event (traj << 1949 // have to clear the previous event(s) << 1950 // needs to be drawn afresh, e.g., the << 1951 // "accumulate" is not requested, the o << 1952 // We have postponed this so that, for << 1953 // previous event(s) stay on screen unt << 1954 // along. For a file-writing viewer th << 1955 // See, for example, G4HepRepFileSceneH << 1956 pVisManager->ClearTransientStoreIfMarke << 1957 << 1958 // Now draw the event... << 1959 pSceneHandler->DrawEvent(event); << 1960 ++pVisManager->fNoOfEventsDrawnThisRun; << 1961 << 1962 // Then pop and release event << 1963 G4MUTEXLOCK(&mtVisSubThreadMutex); << 1964 mtVisEventQueue.pop_front(); << 1965 pVisManager->EndOfEventCleanup(event); << 1966 eventQueueSize = mtVisEventQueue.size() << 1967 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 1968 } << 1969 << 1970 G4MUTEXLOCK(&mtVisSubThreadMutex); << 1971 G4bool runInProgress = mtRunInProgress; << 1972 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 1973 if (!runInProgress) { << 1974 // EndOfRun on master thread has signal << 1975 // nothing to draw so... << 1976 break; << 1977 } << 1978 << 1979 // Run still in progress but nothing to d << 1980 std::this_thread::sleep_for(std::chrono:: << 1981 } 1322 } 1982 << 1983 // Inform viewer that we have finished all << 1984 pViewer->DoneWithVisSubThread(); << 1985 pViewer->MovingToMasterThread(); << 1986 #else << 1987 G4ConsumeParameters(p); << 1988 #endif << 1989 return nullptr; << 1990 } 1323 } 1991 1324 1992 void G4VisManager::BeginOfRun () 1325 void G4VisManager::BeginOfRun () 1993 { 1326 { 1994 if (fIgnoreStateChanges) return; << 1327 //G4cout << "G4VisManager::BeginOfRun" << G4endl; 1995 if (G4Threading::IsWorkerThread()) return; << 1328 fKeptLastEvent = false; 1996 if (!GetConcreteInstance()) return; << 1997 << 1998 // Check if view is valid << 1999 // Protect IsValidView() with fpSceneHandle << 2000 isValidViewForRun = fpSceneHandler && IsVal << 2001 if (!isValidViewForRun) return; << 2002 << 2003 // For a fake run... << 2004 G4RunManager* runManager = G4RunManagerFact << 2005 G4int nEventsToBeProcessed = runManager->Ge << 2006 isFakeRun = (nEventsToBeProcessed == 0); << 2007 if (isFakeRun) return; << 2008 << 2009 // Is the run manager a sub-event type? << 2010 G4RunManager::RMType rmType = runManager->G << 2011 isSubEventRunManagerType = << 2012 (rmType == G4RunManager::subEventMasterRM) << 2013 (rmType == G4RunManager::subEventWorkerRM); << 2014 << 2015 fNKeepForPostProcessingRequests = 0; << 2016 fNKeepTheEventRequests = 0; << 2017 fEventKeepingSuspended = false; 1329 fEventKeepingSuspended = false; 2018 fTransientsDrawnThisRun = false; 1330 fTransientsDrawnThisRun = false; 2019 if (fpSceneHandler) fpSceneHandler->SetTran 1331 if (fpSceneHandler) fpSceneHandler->SetTransientsDrawnThisRun(false); 2020 fNoOfEventsDrawnThisRun = 0; << 2021 << 2022 // Check to see if the user has created a t << 2023 // a default one. To avoid code duplication << 2024 // and its result (a const G4VTrajectoryMod << 2025 // The function is called again later when << 2026 CurrentTrajDrawModel(); << 2027 << 2028 // Actions only in MT mode << 2029 if (G4Threading::IsMultithreadedApplication << 2030 << 2031 // Inform viewer that we have finished al << 2032 if (fpViewer) fpViewer->DoneWithMasterThr << 2033 << 2034 // Start vis sub-thread << 2035 G4MUTEXLOCK(&mtVisSubThreadMutex); << 2036 mtRunInProgress = true; << 2037 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 2038 mtVisSubThread = new G4Thread; << 2039 // Launch vis thread << 2040 G4THREADCREATE(mtVisSubThread,G4VisSubThr << 2041 << 2042 // Tricky things for some viewers (e.g., << 2043 // - Launch the vis thread << 2044 // - Wait for the vis thread to set its Q << 2045 // - Then move current QOpenGL context (i << 2046 // - Go ahead << 2047 if (fpViewer) fpViewer->MovingToVisSubThr << 2048 } << 2049 } 1332 } 2050 1333 2051 void G4VisManager::BeginOfEvent () 1334 void G4VisManager::BeginOfEvent () 2052 { 1335 { 2053 if (fIgnoreStateChanges) return; << 1336 //G4cout << "G4VisManager::BeginOfEvent" << G4endl; 2054 if (!GetConcreteInstance()) return; << 2055 if (!isValidViewForRun) return; << 2056 if (isFakeRun) return; << 2057 << 2058 // Some instructions that should NOT be in << 2059 // TODO: protect with G4Threading::IsMultit << 2060 #ifndef G4MULTITHREADED << 2061 // These instructions are in G4VisSubThread << 2062 fTransientsDrawnThisEvent = false; 1337 fTransientsDrawnThisEvent = false; 2063 if (fpSceneHandler) fpSceneHandler->SetTran 1338 if (fpSceneHandler) fpSceneHandler->SetTransientsDrawnThisEvent(false); 2064 #endif << 2065 } 1339 } 2066 1340 2067 // Here begins a sequence of functions that d << 2068 // Sequential/Serial mode: << 2069 // EndOfEvent is invoked by a state change << 2070 // EndOfEvent pulls the event from the Ev << 2071 // EndOfEventKernel draws the event and c << 2072 // (Unless the user him/herself has reque << 2073 // also sets KeepTheEvent for a certain << 2074 // of events. The run manager keeps thes << 2075 // run, so, for example, the vis manager << 2076 // Multithreading/Tasking: << 2077 // EndOfEvent is invoked by a state change << 2078 // EndOfEvent pulls the event from the (w << 2079 // EndOfEventKernel pushes it to the vis << 2080 // are marked KeepForPostProcessing so << 2081 // PostProcessingFinished in EndOfEvent << 2082 // EndOfEventKernel also sets KeepTheEven << 2083 // The vis sub thread pulls events from t << 2084 // calls EndOfEventCleanup, which calls << 2085 // Sub-event parallelism: << 2086 // EndOfEvent is invoked by a state change << 2087 // multithreading, but actually, the even << 2088 // employed on sub-events, so we ignore s << 2089 // G4SubEvtRunManager knows when the even << 2090 // Events are pushed to the Vis Manager by << 2091 // when the event is ready. EventReadyFo << 2092 // processsing continues as for Multithr << 2093 << 2094 void G4VisManager::EndOfEvent () 1341 void G4VisManager::EndOfEvent () 2095 { 1342 { 2096 if (fIgnoreStateChanges) return; << 1343 //G4cout << "G4VisManager::EndOfEvent" << G4endl; 2097 if (!GetConcreteInstance()) return; << 2098 if (!isValidViewForRun) return; << 2099 if (isFakeRun) return; << 2100 << 2101 // For sub-event parallelism, this is not t << 2102 if (isSubEventRunManagerType) return; << 2103 << 2104 G4AutoLock al(&visEndOfEventMutex); << 2105 1344 2106 G4RunManager* runManager = G4RunManagerFact << 1345 // Don't call IsValidView unless there is a scene handler. This >> 1346 // avoids WARNING message at end of event and run when the user has >> 1347 // not instantiated a scene handler, e.g., in batch mode. >> 1348 G4bool valid = GetConcreteInstance() && fpSceneHandler && IsValidView(); >> 1349 if (!valid) return; 2107 1350 >> 1351 G4RunManager* runManager = G4RunManager::GetRunManager(); 2108 const G4Run* currentRun = runManager->GetCu 1352 const G4Run* currentRun = runManager->GetCurrentRun(); 2109 if (!currentRun) return; << 2110 1353 2111 // This gets the appropriate event manager << 2112 G4EventManager* eventManager = G4EventManag 1354 G4EventManager* eventManager = G4EventManager::GetEventManager(); 2113 const G4Event* currentEvent = eventManager- 1355 const G4Event* currentEvent = eventManager->GetConstCurrentEvent(); 2114 if (!currentEvent) return; 1356 if (!currentEvent) return; 2115 1357 2116 // Call kernel << 1358 ClearTransientStoreIfMarked(); 2117 EndOfEventKernel(currentEvent); << 1359 fpSceneHandler->DrawEvent(currentEvent); 2118 } << 2119 << 2120 void G4VisManager::EventReadyForVis(const G4E << 2121 // This is invoked by G4SubEvtRunManager. << 2122 // The event is passed to EndOfEventKernel. << 2123 { << 2124 if (fIgnoreStateChanges) return; << 2125 if (!GetConcreteInstance()) return; << 2126 if (!isValidViewForRun) return; << 2127 if (isFakeRun) return; << 2128 << 2129 G4AutoLock al(&visEndOfEventMutex); << 2130 EndOfEventKernel(event); << 2131 } << 2132 << 2133 void G4VisManager::EndOfEventKernel (const G4 << 2134 { << 2135 // Note: we are still subject to the mutex << 2136 << 2137 // Discard event if fDrawEventOnlyIfToBeKep << 2138 // user has requested the event to be kept. << 2139 if (fDrawEventOnlyIfToBeKept) { << 2140 if (!currentEvent->KeepTheEventFlag()) re << 2141 } << 2142 << 2143 if (G4Threading::IsMultithreadedApplication << 2144 << 2145 // Wait if too many events in the queue. << 2146 G4MUTEXLOCK(&mtVisSubThreadMutex); << 2147 std::size_t eventQueueSize = mtVisEventQu << 2148 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 2149 << 2150 G4bool eventQueueFull = false; << 2151 while (fMaxEventQueueSize > 0 && (G4int)e << 2152 << 2153 if (fWaitOnEventQueueFull) { << 2154 << 2155 static G4bool warned = false; << 2156 if (!warned) { << 2157 G4warn << << 2158 "WARNING: The number of events in t << 2159 "\n the maximum, " << 2160 << fMaxEventQueueSize << << 2161 ".\n If, during a multithreaded ru << 2162 "\n visualisation by more than thi << 2163 "\n until the vis sub-thread has d << 2164 "\n from the queue. You may chang << 2165 "\n \"/vis/multithreading/maxEvent << 2166 "\n number you wish to allow. N < << 2167 "\n Alternatively you may choose t << 2168 "\n \"/vis/multithreading/actionOn << 2169 "\n To avoid visualisation altoget << 2170 "\n And maybe \"/tracking/storeTra << 2171 << G4endl; << 2172 warned = true; << 2173 } << 2174 1360 2175 // Wait a while to give event drawing << 1361 G4int nEventsToBeProcessed = 0; 2176 std::this_thread::sleep_for(std::chro << 1362 G4int nKeptEvents = 0; 2177 << 1363 G4int eventID = -2; // (If no run manager, triggers ShowView as normal.) 2178 } else { << 1364 if (currentRun) { 2179 << 1365 nEventsToBeProcessed = currentRun->GetNumberOfEventToBeProcessed(); 2180 static G4bool warned = false; << 1366 eventID = currentEvent->GetEventID(); 2181 if (!warned) { << 1367 const std::vector<const G4Event*>* events = 2182 G4warn << << 1368 currentRun->GetEventVector(); 2183 "WARNING: The number of events in t << 1369 if (events) nKeptEvents = events->size(); 2184 "\n the maximum, " << 2185 << fMaxEventQueueSize << << 2186 ".\n Some events have been discard << 2187 "\n behaviour with \"/vis/multithr << 2188 "\n To avoid visualisation altoget << 2189 "\n And maybe \"/tracking/storeTra << 2190 << G4endl; << 2191 warned = true; << 2192 } << 2193 << 2194 eventQueueFull = true; // Causes eve << 2195 break; << 2196 } << 2197 << 2198 G4MUTEXLOCK(&mtVisSubThreadMutex); << 2199 eventQueueSize = mtVisEventQueue.size() << 2200 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 2201 } << 2202 << 2203 if (!eventQueueFull) { << 2204 << 2205 if (RequiredToBeKeptForVis(currentEvent << 2206 currentEvent->KeepTheEvent(); << 2207 fNKeepTheEventRequests++; // Counts << 2208 } << 2209 << 2210 G4MUTEXLOCK(&mtVisSubThreadMutex); << 2211 << 2212 // Keep while post processing (i.e., dr << 2213 // Make sure the event is not deleted b << 2214 currentEvent->KeepForPostProcessing(); << 2215 fNKeepForPostProcessingRequests++; << 2216 << 2217 // Put event on vis queue << 2218 mtVisEventQueue.push_back(currentEvent) << 2219 << 2220 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 2221 } << 2222 << 2223 } else { << 2224 << 2225 // Sequential mode << 2226 << 2227 // We are about to draw the event (trajec << 2228 // have to clear the previous event(s) if << 2229 // needs to be drawn afresh, e.g., the fi << 2230 // "accumulate" is not requested, the old << 2231 // We have postponed this so that, for no << 2232 // previous event(s) stay on screen until << 2233 // along. For a file-writing viewer the << 2234 // See, for example, G4HepRepFileSceneHan << 2235 ClearTransientStoreIfMarked(); << 2236 << 2237 // Keep while post processing (i.e., draw << 2238 currentEvent->KeepForPostProcessing(); << 2239 fNKeepForPostProcessingRequests++; << 2240 << 2241 if (RequiredToBeKeptForVis(currentEvent-> << 2242 currentEvent->KeepTheEvent(); << 2243 fNKeepTheEventRequests++; // Counts nu << 2244 } << 2245 << 2246 // Now draw the event... << 2247 fpSceneHandler->DrawEvent(currentEvent); << 2248 ++fNoOfEventsDrawnThisRun; << 2249 << 2250 EndOfEventCleanup(currentEvent); << 2251 } 1370 } 2252 } << 2253 1371 2254 void G4VisManager::EndOfEventCleanup(const G4 << 2255 { << 2256 if (fpScene->GetRefreshAtEndOfEvent()) { 1372 if (fpScene->GetRefreshAtEndOfEvent()) { 2257 1373 2258 fpSceneHandler->SetMarkForClearingTransie << 1374 // Unless last event (in which case wait end of run)... 2259 << 1375 if (eventID < nEventsToBeProcessed - 1) { 2260 // ShowView guarantees the view is flushe << 1376 fpViewer->ShowView(); 2261 // triggers other features such as pickin << 1377 fpViewer->DrawView(); 2262 // file-writing viewers to close the file << 1378 fpSceneHandler->SetMarkForClearingTransientStore(true); 2263 fpViewer->ShowView(); << 1379 } else { // Last event... 2264 } << 1380 // Keep, but only if user has not kept any... 2265 << 1381 if (!nKeptEvents) { 2266 currentEvent->PostProcessingFinished(); << 1382 eventManager->KeepTheCurrentEvent(); 2267 } << 1383 fKeptLastEvent = true; 2268 << 1384 } 2269 G4bool G4VisManager::RequiredToBeKeptForVis ( << 2270 // i.e., kept by the run manager at least to << 2271 { << 2272 G4bool requiredToBeKept = false; << 2273 << 2274 G4RunManager* runManager = G4RunManagerFact << 2275 G4int nEventsToBeProcessed = runManager->Ge << 2276 << 2277 if (fpScene->GetRefreshAtEndOfEvent()) { / << 2278 << 2279 // Keep last event only << 2280 if (eventID == nEventsToBeProcessed - 1) << 2281 requiredToBeKept = true; << 2282 } 1385 } 2283 1386 2284 } else { // Accumulating events << 1387 } else { // Accumulating events... 2285 1388 2286 G4int maxNumberOfKeptEvents = fpScene->Ge 1389 G4int maxNumberOfKeptEvents = fpScene->GetMaxNumberOfKeptEvents(); 2287 << 1390 if (maxNumberOfKeptEvents > 0 && nKeptEvents >= maxNumberOfKeptEvents) { 2288 if (maxNumberOfKeptEvents >= 0) { // Eve << 1391 fEventKeepingSuspended = true; 2289 << 1392 static G4bool warned = false; 2290 if (fNKeepTheEventRequests < maxNumberO << 1393 if (!warned) { 2291 << 1394 if (fVerbosity >= warnings) { 2292 // Not yet reached the limit << 1395 G4cout << 2293 requiredToBeKept = true; << 1396 "WARNING: G4VisManager::EndOfEvent: Automatic event keeping suspended." 2294 << 1397 "\n The number of events exceeds the maximum, " 2295 } else { << 1398 << maxNumberOfKeptEvents << 2296 << 1399 ", that can be kept by the vis manager." 2297 // We have already reached the limit << 1400 << G4endl; 2298 fEventKeepingSuspended = true; << 1401 } 2299 static G4bool warned = false; << 1402 warned = true; 2300 if (!warned) { << 2301 if (fVerbosity >= warnings) { << 2302 G4warn << << 2303 "WARNING: G4VisManager::EndOfEven << 2304 << G4endl; << 2305 if (maxNumberOfKeptEvents > 0) { << 2306 G4warn << << 2307 "\n The number of events excee << 2308 << maxNumberOfKeptEvents << << 2309 ", that may be kept by\n the v << 2310 << G4endl; << 2311 } << 2312 } << 2313 warned = true; << 2314 } << 2315 } 1403 } 2316 << 1404 } else if (maxNumberOfKeptEvents != 0) { 2317 } else { // Indefinite event keeping (ma << 1405 eventManager->KeepTheCurrentEvent(); 2318 << 2319 requiredToBeKept = true; << 2320 << 2321 } 1406 } 2322 } 1407 } 2323 << 2324 return requiredToBeKept; << 2325 } 1408 } 2326 1409 2327 void G4VisManager::EndOfRun () 1410 void G4VisManager::EndOfRun () 2328 { 1411 { 2329 if (fIgnoreStateChanges) return; << 1412 //G4cout << "G4VisManager::EndOfRun" << G4endl; 2330 if (G4Threading::IsWorkerThread()) return; << 2331 if (!GetConcreteInstance()) return; << 2332 if (!isValidViewForRun) return; << 2333 if (isFakeRun) return; << 2334 << 2335 G4RunManager* runManager = G4RunManagerFact << 2336 << 2337 // For a fake run... << 2338 G4int nEventsToBeProcessed = runManager->Ge << 2339 if (nEventsToBeProcessed == 0) return; << 2340 << 2341 const G4Run* currentRun = runManager->GetCu << 2342 if (!currentRun) return; << 2343 1413 2344 // G4AutoLock al(&visEndOfRunMutex); ??? << 1414 // Don't call IsValidView unless there is a scene handler. This 2345 if (G4Threading::IsMultithreadedApplication << 1415 // avoids WARNING message at end of event and run when the user has 2346 // Reset flag so that sub-thread exits wh << 1416 // not instantiated a scene handler, e.g., in batch mode. 2347 G4MUTEXLOCK(&mtVisSubThreadMutex); << 1417 G4bool valid = GetConcreteInstance() && fpSceneHandler && IsValidView(); 2348 mtRunInProgress = false; << 1418 if (valid) { 2349 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 1419 if (!fpSceneHandler->GetMarkForClearingTransientStore()) { 2350 // Wait for sub-thread to finish. << 1420 if (fpScene->GetRefreshAtEndOfRun()) { 2351 G4THREADJOIN(*mtVisSubThread); << 1421 fpSceneHandler->DrawEndOfRunModels(); 2352 delete mtVisSubThread; << 1422 fpViewer->ShowView(); 2353 fpViewer->SwitchToMasterThread(); << 1423 fpSceneHandler->SetMarkForClearingTransientStore(true); 2354 } << 2355 << 2356 if (G4Threading::IsMultithreadedApplication << 2357 G4int noOfEventsRequested = runManager->G << 2358 if (fNoOfEventsDrawnThisRun != noOfEvents << 2359 if (!fWaitOnEventQueueFull && fVerbosit << 2360 G4warn << 2361 << "WARNING: Number of events drawn t << 2362 << fNoOfEventsDrawnThisRun << ", is d << 2363 << noOfEventsRequested << << 2364 ".\n (This is because you requested << 2365 << G4endl; << 2366 } 1424 } 2367 } 1425 } 2368 } << 2369 1426 2370 G4int nKeptEvents = currentRun->GetNumberOf << 1427 if (fEventKeepingSuspended && fVerbosity >= warnings) { 2371 if (fVerbosity >= warnings && nKeptEvents > << 1428 G4cout << 2372 G4warn << nKeptEvents; << 1429 "WARNING: G4VisManager::EndOfRun: Automatic event keeping has been suspended." 2373 if (nKeptEvents == 1) G4warn << " event h << 1430 "\n The number of events in the run exceeded the maximum, " 2374 else G4warn << " events have"; << 1431 << fpScene->GetMaxNumberOfKeptEvents() << 2375 G4warn << " been kept for refreshing and/ << 1432 ", that can be kept by the vis manager." << 2376 if (nKeptEvents != fNKeepTheEventRequests << 1433 "\n The number of events kept by the vis manager can be changed with" 2377 if (fNKeepTheEventRequests == 0) { << 1434 "\n \"/vis/scene/endOfEventAction accumulate <N>\", where N is the" 2378 G4warn << "No keep requests were"; << 1435 "\n maximum number you wish to allow. N < 0 means \"unlimited\"." 2379 } else if (fNKeepTheEventRequests == 1) << 1436 << G4endl; 2380 G4warn << "1 keep request was"; << 2381 } else { << 2382 G4warn << fNKeepTheEventRequests << " << 2383 } << 2384 G4warn << " made by the vis manager."; << 2385 if (fNKeepTheEventRequests == 0) { << 2386 G4warn << << 2387 "\n The kept events are those you ha << 2388 } else { << 2389 G4warn << << 2390 "\n The same or further events may h << 2391 "\n To turn off event keeping by the << 2392 "\n or use /vis/scene/endOfEventActi << 2393 } << 2394 G4warn << G4endl; << 2395 } << 2396 G4warn << << 2397 " \"/vis/reviewKeptEvents\" to review one << 2398 "\n To see accumulated, \"/vis/enable\", t << 2399 << G4endl; << 2400 } << 2401 << 2402 if (fVerbosity >= warnings) PrintListOfPlot << 2403 << 2404 if (fEventKeepingSuspended && fVerbosity >= << 2405 G4warn << << 2406 "WARNING: G4VisManager::EndOfRun: Automat << 2407 << G4endl; << 2408 if (fpScene->GetMaxNumberOfKeptEvents() > << 2409 G4warn << << 2410 " The number of events in the run exce << 2411 << fpScene->GetMaxNumberOfKeptEvents() << 2412 ", that may be\n kept by the vis manag << 2413 "\n The number of events kept by the v << 2414 "\n \"/vis/scene/endOfEventAction accu << 2415 "\n maximum number you wish to allow. << 2416 << G4endl; << 2417 } 1437 } 2418 } 1438 } >> 1439 fEventRefreshing = false; 2419 1440 2420 // // if (!fpSceneHandler->GetMarkForClear << 1441 G4RunManager* runManager = G4RunManager::GetRunManager(); 2421 // // is here. It prevents ShowView at en << 1442 const G4Run* currentRun = runManager->GetCurrentRun(); 2422 // // for sequential mode, but MT mode see << 1443 2423 // // figured out why). ???? JA ???? << 1444 G4int nKeptEvents = 0; 2424 // if (!fpSceneHandler->GetMarkForClearing << 1445 const std::vector<const G4Event*>* events = 2425 if (fpScene->GetRefreshAtEndOfRun()) { << 1446 currentRun? currentRun->GetEventVector(): 0; 2426 fpSceneHandler->DrawEndOfRunModels(); << 1447 if (events) nKeptEvents = events->size(); 2427 // An extra refresh for auto-refresh view << 1448 2428 // ???? I DON'T WHY THIS IS NECESSARY ??? << 1449 if (nKeptEvents && !fKeptLastEvent) { 2429 if (fpViewer->GetViewParameters().IsAutoR << 1450 if (!valid && fVerbosity >= warnings) G4cout << "WARNING: "; 2430 fpViewer->RefreshView(); << 1451 if (fVerbosity >= warnings) { 2431 } << 1452 G4cout << nKeptEvents; 2432 // ShowView guarantees the view is flushe << 1453 if (nKeptEvents == 1) G4cout << " event has"; 2433 // triggers other features such picking ( << 1454 else G4cout << " events have"; 2434 // file-writing viewers to close the file << 1455 G4cout << " been kept for refreshing and/or reviewing." << G4endl; 2435 fpViewer->ShowView(); << 1456 } 2436 fpSceneHandler->SetMarkForClearingTransie << 1457 static G4bool warned = false; 2437 } else { << 1458 if (!valid && fVerbosity >= warnings && !warned) { 2438 if (fpGraphicsSystem->GetFunctionality() << 1459 G4cout << 2439 G4VGraphicsSystem::fileWriter) { << 1460 " Only useful if before starting the run:" 2440 if (fVerbosity >= warnings) { << 1461 "\n a) trajectories are stored (\"/vis/scene/add/trajectories [smooth|rich]\"), or" 2441 G4warn << "\"/vis/viewer/update\" to << 1462 "\n b) the Draw method of any hits or digis is implemented." 2442 } << 1463 "\n To view trajectories, hits or digis:" >> 1464 "\n open a viewer, draw a volume, \"/vis/scene/add/trajectories\"" >> 1465 "\n \"/vis/scene/add/hits\" or \"/vis/scene/add/digitisations\"" >> 1466 "\n and, possibly, \"/vis/viewer/flush\"." >> 1467 "\n To see all events: \"/vis/scene/endOfEventAction accumulate\"." >> 1468 "\n To see events individually: \"/vis/reviewKeptEvents\"." >> 1469 << G4endl; >> 1470 warned = true; 2443 } 1471 } 2444 } 1472 } 2445 //} << 2446 fEventRefreshing = false; << 2447 } 1473 } 2448 1474 2449 void G4VisManager::ClearTransientStoreIfMarke 1475 void G4VisManager::ClearTransientStoreIfMarked(){ 2450 // Assumes valid view. 1476 // Assumes valid view. 2451 if (fpSceneHandler->GetMarkForClearingTrans 1477 if (fpSceneHandler->GetMarkForClearingTransientStore()) { 2452 fpSceneHandler->SetMarkForClearingTransie 1478 fpSceneHandler->SetMarkForClearingTransientStore(false); 2453 fpSceneHandler->ClearTransientStore(); 1479 fpSceneHandler->ClearTransientStore(); 2454 } 1480 } 2455 // Record if transients drawn. These local 1481 // Record if transients drawn. These local flags are only set 2456 // *after* ClearTransientStore. In the cod 1482 // *after* ClearTransientStore. In the code in G4VSceneHandler 2457 // triggered by ClearTransientStore, use th 1483 // triggered by ClearTransientStore, use these flags so that 2458 // event refreshing is not done too early. 1484 // event refreshing is not done too early. 2459 fTransientsDrawnThisEvent = fpSceneHandler- 1485 fTransientsDrawnThisEvent = fpSceneHandler->GetTransientsDrawnThisEvent(); 2460 fTransientsDrawnThisRun = fpSceneHandler->G 1486 fTransientsDrawnThisRun = fpSceneHandler->GetTransientsDrawnThisRun(); 2461 } 1487 } 2462 1488 2463 void G4VisManager::ResetTransientsDrawnFlags( 1489 void G4VisManager::ResetTransientsDrawnFlags() 2464 { 1490 { 2465 fTransientsDrawnThisRun = false; 1491 fTransientsDrawnThisRun = false; 2466 fTransientsDrawnThisEvent = false; 1492 fTransientsDrawnThisEvent = false; 2467 G4SceneHandlerListConstIterator i; 1493 G4SceneHandlerListConstIterator i; 2468 for (i = fAvailableSceneHandlers.begin(); 1494 for (i = fAvailableSceneHandlers.begin(); 2469 i != fAvailableSceneHandlers.end(); ++ 1495 i != fAvailableSceneHandlers.end(); ++i) { 2470 (*i)->SetTransientsDrawnThisEvent(false); 1496 (*i)->SetTransientsDrawnThisEvent(false); 2471 (*i)->SetTransientsDrawnThisRun(false); 1497 (*i)->SetTransientsDrawnThisRun(false); 2472 } 1498 } 2473 } 1499 } 2474 1500 2475 G4String G4VisManager::ViewerShortName (const 1501 G4String G4VisManager::ViewerShortName (const G4String& viewerName) const { 2476 const G4String& viewerShortName = viewerNam << 1502 G4String viewerShortName (viewerName); 2477 return G4StrUtil::strip_copy(viewerShortNam << 1503 viewerShortName = viewerShortName (0, viewerShortName.find (' ')); >> 1504 return viewerShortName.strip (); 2478 } 1505 } 2479 1506 2480 G4VViewer* G4VisManager::GetViewer (const G4S 1507 G4VViewer* G4VisManager::GetViewer (const G4String& viewerName) const { 2481 G4String viewerShortName = ViewerShortName 1508 G4String viewerShortName = ViewerShortName (viewerName); 2482 std::size_t nHandlers = fAvailableSceneHand << 1509 size_t nHandlers = fAvailableSceneHandlers.size (); 2483 std::size_t iHandler, iViewer; << 1510 size_t iHandler, iViewer; 2484 G4VViewer* viewer = 0; 1511 G4VViewer* viewer = 0; 2485 G4bool found = false; 1512 G4bool found = false; 2486 for (iHandler = 0; iHandler < nHandlers; iH 1513 for (iHandler = 0; iHandler < nHandlers; iHandler++) { 2487 G4VSceneHandler* sceneHandler = fAvailabl 1514 G4VSceneHandler* sceneHandler = fAvailableSceneHandlers [iHandler]; 2488 const G4ViewerList& viewerList = sceneHan 1515 const G4ViewerList& viewerList = sceneHandler -> GetViewerList (); 2489 for (iViewer = 0; iViewer < viewerList.si 1516 for (iViewer = 0; iViewer < viewerList.size (); iViewer++) { 2490 viewer = viewerList [iViewer]; 1517 viewer = viewerList [iViewer]; 2491 if (viewerShortName == viewer -> GetSho 1518 if (viewerShortName == viewer -> GetShortName ()) { 2492 found = true; 1519 found = true; 2493 break; 1520 break; 2494 } 1521 } 2495 } 1522 } 2496 if (found) break; 1523 if (found) break; 2497 } 1524 } 2498 if (found) return viewer; 1525 if (found) return viewer; 2499 else return 0; 1526 else return 0; 2500 } 1527 } 2501 1528 2502 std::vector<G4String> G4VisManager::Verbosity 1529 std::vector<G4String> G4VisManager::VerbosityGuidanceStrings; 2503 1530 2504 G4String G4VisManager::VerbosityString(Verbos 1531 G4String G4VisManager::VerbosityString(Verbosity verbosity) { 2505 G4String rs; << 1532 G4String s; 2506 switch (verbosity) { 1533 switch (verbosity) { 2507 case quiet: rs = "quiet (0)"; break << 1534 case quiet: s = "quiet (0)"; break; 2508 case startup: rs = "startup (1)"; bre << 1535 case startup: s = "startup (1)"; break; 2509 case errors: rs = "errors (2)"; brea << 1536 case errors: s = "errors (2)"; break; 2510 case warnings: rs = "warnings (3)"; br << 1537 case warnings: s = "warnings (3)"; break; 2511 case confirmations: rs = "confirmations (4) << 1538 case confirmations: s = "confirmations (4)"; break; 2512 case parameters: rs = "parameters (5)"; << 1539 case parameters: s = "parameters (5)"; break; 2513 case all: rs = "all (6)"; break; << 1540 case all: s = "all (6)"; break; 2514 } 1541 } 2515 return rs; << 1542 return s; 2516 } << 2517 << 2518 void G4VisManager::PrintAvailableVerbosity(st << 2519 { << 2520 os << "Available verbosity options:"; << 2521 for (std::size_t i = 0; i < VerbosityGuidan << 2522 os << '\n' << VerbosityGuidanceStrings[i] << 2523 } << 2524 os << "\nCurrent verbosity: " << G4VisManag << 2525 os << std::endl; << 2526 } 1543 } 2527 1544 2528 G4VisManager::Verbosity 1545 G4VisManager::Verbosity 2529 G4VisManager::GetVerbosityValue(const G4Strin 1546 G4VisManager::GetVerbosityValue(const G4String& verbosityString) { 2530 G4String ss = G4StrUtil::to_lower_copy(verb << 1547 G4String s(verbosityString); s.toLower(); 2531 Verbosity verbosity; 1548 Verbosity verbosity; 2532 if (ss[0] == 'q') verbosity = quiet; << 1549 if (s(0) == 'q') verbosity = quiet; 2533 else if (ss[0] == 's') verbosity = startup; << 1550 else if (s(0) == 's') verbosity = startup; 2534 else if (ss[0] == 'e') verbosity = errors; << 1551 else if (s(0) == 'e') verbosity = errors; 2535 else if (ss[0] == 'w') verbosity = warnings << 1552 else if (s(0) == 'w') verbosity = warnings; 2536 else if (ss[0] == 'c') verbosity = confirma << 1553 else if (s(0) == 'c') verbosity = confirmations; 2537 else if (ss[0] == 'p') verbosity = paramete << 1554 else if (s(0) == 'p') verbosity = parameters; 2538 else if (ss[0] == 'a') verbosity = all; << 1555 else if (s(0) == 'a') verbosity = all; 2539 else { 1556 else { 2540 // Could be an integer << 2541 G4int intVerbosity; 1557 G4int intVerbosity; 2542 std::istringstream is(ss); << 1558 std::istringstream is(s); 2543 is >> intVerbosity; 1559 is >> intVerbosity; 2544 if (!is) { 1560 if (!is) { 2545 G4warn << "ERROR: G4VisManager::GetVerb << 1561 G4cout << "ERROR: G4VisManager::GetVerbosityValue: invalid verbosity \"" 2546 << verbosityString << "\"\n"; << 1562 << verbosityString << "\""; 2547 PrintAvailableVerbosity(G4warn); << 1563 for (size_t i = 0; i < VerbosityGuidanceStrings.size(); ++i) { 2548 // Return existing verbosity << 1564 G4cout << '\n' << VerbosityGuidanceStrings[i]; 2549 return fVerbosity; << 1565 } >> 1566 verbosity = warnings; >> 1567 G4cout << "\n Returning " << VerbosityString(verbosity) >> 1568 << G4endl; 2550 } 1569 } 2551 else { 1570 else { 2552 verbosity = GetVerbosityValue(intVerbos 1571 verbosity = GetVerbosityValue(intVerbosity); 2553 } 1572 } 2554 } 1573 } 2555 return verbosity; 1574 return verbosity; 2556 } 1575 } 2557 1576 2558 G4VisManager::Verbosity G4VisManager::GetVerb 1577 G4VisManager::Verbosity G4VisManager::GetVerbosityValue(G4int intVerbosity) { 2559 Verbosity verbosity; 1578 Verbosity verbosity; 2560 if (intVerbosity < quiet) verbosity = 1579 if (intVerbosity < quiet) verbosity = quiet; 2561 else if (intVerbosity > all) verbosity = 1580 else if (intVerbosity > all) verbosity = all; 2562 else verbosity = 1581 else verbosity = Verbosity(intVerbosity); 2563 return verbosity; 1582 return verbosity; 2564 } 1583 } 2565 1584 2566 G4VisManager::Verbosity G4VisManager::GetVerb 1585 G4VisManager::Verbosity G4VisManager::GetVerbosity () { 2567 return fVerbosity; 1586 return fVerbosity; 2568 } 1587 } 2569 1588 2570 void G4VisManager::SetVerboseLevel (G4int int 1589 void G4VisManager::SetVerboseLevel (G4int intVerbosity) { 2571 fVerbosity = GetVerbosityValue(intVerbosity 1590 fVerbosity = GetVerbosityValue(intVerbosity); 2572 } 1591 } 2573 1592 2574 void G4VisManager::SetVerboseLevel (const G4S 1593 void G4VisManager::SetVerboseLevel (const G4String& verbosityString) { 2575 fVerbosity = GetVerbosityValue(verbosityStr 1594 fVerbosity = GetVerbosityValue(verbosityString); 2576 } 1595 } 2577 1596 2578 G4bool G4VisManager::IsValidView () { 1597 G4bool G4VisManager::IsValidView () { 2579 1598 2580 if (!fInitialised) Initialise (); 1599 if (!fInitialised) Initialise (); 2581 1600 2582 static G4bool noGSPrinting = true; 1601 static G4bool noGSPrinting = true; 2583 if (!fpGraphicsSystem) { 1602 if (!fpGraphicsSystem) { 2584 // Limit printing - we do not want printi 1603 // Limit printing - we do not want printing if the user simply does 2585 // not want to use graphics, e.g., in bat 1604 // not want to use graphics, e.g., in batch mode. 2586 if (noGSPrinting) { 1605 if (noGSPrinting) { 2587 noGSPrinting = false; 1606 noGSPrinting = false; 2588 if (fVerbosity >= warnings) { 1607 if (fVerbosity >= warnings) { 2589 G4warn << << 1608 G4cout << 2590 "WARNING: G4VisManager::IsValidView(): Atte 1609 "WARNING: G4VisManager::IsValidView(): Attempt to draw when no graphics system" 2591 "\n has been instantiated. Use \"/vis/ope 1610 "\n has been instantiated. Use \"/vis/open\" or \"/vis/sceneHandler/create\"." 2592 "\n Alternatively, to avoid this message, 1611 "\n Alternatively, to avoid this message, suppress instantiation of vis" 2593 "\n manager (G4VisExecutive) and ensure dr << 1612 "\n manager (G4VisExecutive), possibly by setting G4VIS_NONE, and ensure" 2594 "\n G4VVisManager::GetConcreteInstance() i << 1613 "\n drawing code is executed only if G4VVisManager::GetConcreteInstance()" 2595 << G4endl; << 1614 "\n is non-zero." >> 1615 << G4endl; 2596 } 1616 } 2597 } 1617 } 2598 return false; 1618 return false; 2599 } 1619 } 2600 1620 2601 if ((!fpScene) || (!fpSceneHandler) || (!fp 1621 if ((!fpScene) || (!fpSceneHandler) || (!fpViewer)) { 2602 if (fVerbosity >= errors) { 1622 if (fVerbosity >= errors) { 2603 G4warn << << 1623 G4cout << 2604 "ERROR: G4VisManager::IsValidView(): Curren 1624 "ERROR: G4VisManager::IsValidView(): Current view is not valid." 2605 << G4endl; 1625 << G4endl; 2606 PrintInvalidPointers (); 1626 PrintInvalidPointers (); 2607 } 1627 } 2608 return false; 1628 return false; 2609 } 1629 } 2610 1630 2611 if (fpScene != fpSceneHandler -> GetScene ( 1631 if (fpScene != fpSceneHandler -> GetScene ()) { 2612 if (fVerbosity >= errors) { 1632 if (fVerbosity >= errors) { 2613 G4warn << "ERROR: G4VisManager::IsValid << 1633 G4cout << "ERROR: G4VisManager::IsValidView ():"; 2614 if (fpSceneHandler -> GetScene ()) { 1634 if (fpSceneHandler -> GetScene ()) { 2615 G4warn << << 1635 G4cout << 2616 "\n The current scene \"" 1636 "\n The current scene \"" 2617 << fpScene -> GetName () 1637 << fpScene -> GetName () 2618 << "\" is not handled by" 1638 << "\" is not handled by" 2619 "\n the current scene handler \"" 1639 "\n the current scene handler \"" 2620 << fpSceneHandler -> GetName () 1640 << fpSceneHandler -> GetName () 2621 << "\"" 1641 << "\"" 2622 "\n (it currently handles scene \"" 1642 "\n (it currently handles scene \"" 2623 << fpSceneHandler -> GetScene () -> 1643 << fpSceneHandler -> GetScene () -> GetName () 2624 << "\")." 1644 << "\")." 2625 "\n Either:" 1645 "\n Either:" 2626 "\n (a) attach it to the scene handler w 1646 "\n (a) attach it to the scene handler with" 2627 "\n /vis/sceneHandler/attach " 1647 "\n /vis/sceneHandler/attach " 2628 << fpScene -> GetName () 1648 << fpScene -> GetName () 2629 << ", or" 1649 << ", or" 2630 "\n (b) create a new scene handler with 1650 "\n (b) create a new scene handler with " 2631 "\n /vis/sceneHandler/create <graphi 1651 "\n /vis/sceneHandler/create <graphics-system>," 2632 "\n in which case it should pick up 1652 "\n in which case it should pick up the the new scene." 2633 << G4endl; 1653 << G4endl; 2634 } 1654 } 2635 else { 1655 else { 2636 G4warn << "\n Scene handler \"" << 1656 G4cout << "\n Scene handler \"" 2637 << fpSceneHandler -> GetName () 1657 << fpSceneHandler -> GetName () 2638 << "\" has null scene pointer." 1658 << "\" has null scene pointer." 2639 "\n Attach a scene with /vis/sceneHandle 1659 "\n Attach a scene with /vis/sceneHandler/attach [<scene-name>]" 2640 << G4endl; 1660 << G4endl; 2641 } 1661 } 2642 } 1662 } 2643 return false; 1663 return false; 2644 } 1664 } 2645 1665 2646 const G4ViewerList& viewerList = fpSceneHan 1666 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList (); 2647 if (viewerList.size () == 0) { 1667 if (viewerList.size () == 0) { 2648 if (fVerbosity >= errors) { 1668 if (fVerbosity >= errors) { 2649 G4warn << << 1669 G4cout << 2650 "ERROR: G4VisManager::IsValidView (): the c 1670 "ERROR: G4VisManager::IsValidView (): the current scene handler\n \"" 2651 << fpSceneHandler -> GetName () 1671 << fpSceneHandler -> GetName () 2652 << "\" has no viewers. Do /vis/viewer 1672 << "\" has no viewers. Do /vis/viewer/create." 2653 << G4endl; 1673 << G4endl; 2654 } 1674 } 2655 return false; 1675 return false; 2656 } 1676 } 2657 1677 2658 G4bool isValid = true; 1678 G4bool isValid = true; 2659 if (fpScene -> IsEmpty ()) { // Add world 1679 if (fpScene -> IsEmpty ()) { // Add world by default if possible... 2660 G4bool warn(fVerbosity >= warnings); 1680 G4bool warn(fVerbosity >= warnings); 2661 G4bool successful = fpScene -> AddWorldIf 1681 G4bool successful = fpScene -> AddWorldIfEmpty (warn); 2662 if (!successful || fpScene -> IsEmpty ()) 1682 if (!successful || fpScene -> IsEmpty ()) { // If still empty... 2663 if (fVerbosity >= errors) { 1683 if (fVerbosity >= errors) { 2664 G4warn << "ERROR: G4VisManager::IsValidView << 1684 G4cout << "ERROR: G4VisManager::IsViewValid ():"; 2665 G4warn << << 1685 G4cout << 2666 "\n Attempt at some drawing operation wh 1686 "\n Attempt at some drawing operation when scene is empty." 2667 "\n Maybe the geometry has not yet been 1687 "\n Maybe the geometry has not yet been defined." 2668 " Try /run/initialize." 1688 " Try /run/initialize." 2669 "\n Or use \"/vis/scene/add/extent << 2670 << G4endl; 1689 << G4endl; 2671 } 1690 } 2672 isValid = false; 1691 isValid = false; 2673 } 1692 } 2674 else { 1693 else { 2675 G4UImanager::GetUIpointer()->ApplyComma 1694 G4UImanager::GetUIpointer()->ApplyCommand ("/vis/scene/notifyHandlers"); 2676 if (fVerbosity >= warnings) { 1695 if (fVerbosity >= warnings) { 2677 G4warn << << 1696 G4cout << 2678 "WARNING: G4VisManager: the scene was emp 1697 "WARNING: G4VisManager: the scene was empty, \"world\" has been" 2679 "\n added and the scene handlers notifie 1698 "\n added and the scene handlers notified."; 2680 G4warn << G4endl; << 1699 G4cout << G4endl; 2681 } 1700 } 2682 } 1701 } 2683 } 1702 } >> 1703 if (isValid) SetConcreteInstance(this); 2684 return isValid; 1704 return isValid; 2685 } 1705 } 2686 1706 2687 void 1707 void 2688 G4VisManager::RegisterModelFactories() 1708 G4VisManager::RegisterModelFactories() 2689 { 1709 { 2690 if (fVerbosity >= warnings) { 1710 if (fVerbosity >= warnings) { 2691 G4warn<<"G4VisManager: No model factories << 1711 G4cout<<"G4VisManager: No model factories registered with G4VisManager."<<G4endl; 2692 G4warn<<"G4VisManager::RegisterModelFacto << 1712 G4cout<<"G4VisManager::RegisterModelFactories() should be overridden in derived"<<G4endl; 2693 G4warn<<"class. See G4VisExecutive for an << 1713 G4cout<<"class. See G4VisExecutive for an example."<<G4endl; 2694 } 1714 } 2695 } << 2696 << 2697 void G4VisManager::SetUpForAThread() << 2698 { << 2699 // TODO: protect with G4Threading::IsMultit << 2700 #ifdef G4MULTITHREADED << 2701 new G4VisStateDependent(this); << 2702 #endif << 2703 } << 2704 << 2705 void G4VisManager::IgnoreStateChanges(G4bool << 2706 { << 2707 fIgnoreStateChanges = val; << 2708 } 1715 } 2709 1716