Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // 7 // >> 8 // $Id: G4VisManager.cc,v 1.13 1999/12/15 14:54:27 gunter Exp $ >> 9 // GEANT4 tag $Name: geant4-01-01 $ 26 // 10 // 27 // 11 // 28 // GEANT4 Visualization Manager - John Allison 12 // GEANT4 Visualization Manager - John Allison 02/Jan/1996. 29 // Michael Kelsey 31 Jan 2019 -- Add new comm << 30 13 31 #include "G4VisManager.hh" 14 #include "G4VisManager.hh" 32 15 33 #include "G4VisCommands.hh" << 34 #include "G4VisCommandsCompound.hh" << 35 #include "G4VisCommandsGeometry.hh" << 36 #include "G4VisCommandsGeometrySet.hh" << 37 #include "G4VisCommandsMultithreading.hh" << 38 #include "G4VisCommandsSet.hh" << 39 #include "G4VisCommandsScene.hh" << 40 #include "G4VisCommandsSceneAdd.hh" << 41 #include "G4VisCommandsPlotter.hh" << 42 #include "G4VisCommandsSceneHandler.hh" << 43 #include "G4VisCommandsTouchable.hh" << 44 #include "G4VisCommandsTouchableSet.hh" << 45 #include "G4VisCommandsViewer.hh" << 46 #include "G4VisCommandsViewerDefault.hh" << 47 #include "G4VisCommandsViewerSet.hh" << 48 #include "G4UImanager.hh" 16 #include "G4UImanager.hh" 49 #include "G4VisStateDependent.hh" 17 #include "G4VisStateDependent.hh" 50 #include "G4UIdirectory.hh" 18 #include "G4UIdirectory.hh" >> 19 #include "G4VisFeaturesOfFukuiRenderer.hh" >> 20 #include "G4VisFeaturesOfDAWNFILE.hh" >> 21 #include "G4VisFeaturesOfOpenGL.hh" >> 22 #include "G4VisFeaturesOfOpenInventor.hh" 51 #include "G4VGraphicsSystem.hh" 23 #include "G4VGraphicsSystem.hh" 52 #include "G4VSceneHandler.hh" 24 #include "G4VSceneHandler.hh" 53 #include "G4VViewer.hh" 25 #include "G4VViewer.hh" 54 #include "G4VPhysicalVolume.hh" 26 #include "G4VPhysicalVolume.hh" 55 #include "G4LogicalVolume.hh" 27 #include "G4LogicalVolume.hh" 56 #include "G4VSolid.hh" 28 #include "G4VSolid.hh" 57 #include "G4Vector3D.hh" 29 #include "G4Vector3D.hh" 58 #include "G4Point3D.hh" 30 #include "G4Point3D.hh" 59 #include "G4RotationMatrix.hh" 31 #include "G4RotationMatrix.hh" 60 #include "G4Polyline.hh" 32 #include "G4Polyline.hh" 61 #include "G4Polyhedron.hh" 33 #include "G4Polyhedron.hh" >> 34 #include "G4NURBS.hh" 62 #include "G4NullModel.hh" 35 #include "G4NullModel.hh" 63 #include "G4ModelingParameters.hh" 36 #include "G4ModelingParameters.hh" 64 #include "G4TransportationManager.hh" 37 #include "G4TransportationManager.hh" 65 #include "G4VisCommandModelCreate.hh" << 66 #include "G4VisCommandsListManager.hh" << 67 #include "G4VisModelManager.hh" << 68 #include "G4VModelFactory.hh" << 69 #include "G4VisFilterManager.hh" << 70 #include "G4VTrajectoryModel.hh" << 71 #include "G4TrajectoryDrawByCharge.hh" << 72 #include "Randomize.hh" << 73 #include "G4RunManager.hh" << 74 #include "G4RunManagerFactory.hh" << 75 #include "G4EventManager.hh" << 76 #include "G4Run.hh" << 77 #include "G4Event.hh" << 78 #include <map> << 79 #include <set> << 80 #include <vector> << 81 #include <sstream> << 82 << 83 #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 38 110 // Class statics << 39 #include "G4VisManMessenger.hh" 111 G4VisManager* G4VisManager::fpInstance = 0; << 40 // TEMPORARY /vis/ -> /vis~/ equivalence. >> 41 #include "G4VisToOldVisCommands.hh" 112 42 113 G4VisManager::Verbosity G4VisManager::fVerbosi << 43 #include "G4ios.hh" 114 44 115 G4VisManager::G4VisManager (const G4String& ve << 45 G4VisManager* G4VisManager::fpInstance = 0; 116 : fVerbose (1) << 117 , fDefaultGraphicsSystemName("OGL") / << 118 , fDefaultXGeometryString ("600x600-0+0") / << 119 , fDefaultGraphicsSystemBasis ("G4VisManager i << 120 , fDefaultXGeometryStringBasis("G4VisManager i << 121 , fInitialised (false) << 122 , fpGraphicsSystem (0) << 123 , fpScene (0) << 124 , fpSceneHandler (0) << 125 , fpViewer (0) << 126 , fpStateDependent (0) << 127 , fEventRefreshing (false) << 128 , fTransientsDrawnThisRun (false) << 129 , fTransientsDrawnThisEvent (false) << 130 , fNoOfEventsDrawnThisRun (0) << 131 , fNKeepForPostProcessingRequests (0) << 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 { << 147 fpTrajDrawModelMgr = new G4VisModelManager<G << 148 fpTrajFilterMgr = new G4VisFilterManager<G4V << 149 fpHitFilterMgr = new G4VisFilterManager<G4VH << 150 fpDigiFilterMgr = new G4VisFilterManager<G4V << 151 << 152 VerbosityGuidanceStrings.push_back << 153 ("Simple graded message scheme - digit or << 154 VerbosityGuidanceStrings.push_back << 155 (" 0) quiet, // Nothing is printe << 156 VerbosityGuidanceStrings.push_back << 157 (" 1) startup, // Startup and endup << 158 VerbosityGuidanceStrings.push_back << 159 (" 2) errors, // ...and errors..." << 160 VerbosityGuidanceStrings.push_back << 161 (" 3) warnings, // ...and warnings.. << 162 VerbosityGuidanceStrings.push_back << 163 (" 4) confirmations, // ...and confirming << 164 VerbosityGuidanceStrings.push_back << 165 (" 5) parameters, // ...and parameters << 166 VerbosityGuidanceStrings.push_back << 167 (" 6) all // ...and everything << 168 46 >> 47 G4VisManager::G4VisManager (): >> 48 fInitialised (false), >> 49 fpGraphicsSystem (0), >> 50 fpScene (0), >> 51 fpSceneHandler (0), >> 52 fpViewer (0), >> 53 fVerbose (0) // All other objects use default constructors. >> 54 { 169 if (fpInstance) { 55 if (fpInstance) { 170 G4Exception 56 G4Exception 171 ("G4VisManager::G4VisManager", << 57 ("G4VisManager: attempt to Construct more than one VisManager."); 172 "visman0001", FatalException, << 173 "Attempt to Construct more than one Vis << 174 } << 175 << 176 fpInstance = this; << 177 SetConcreteInstance(this); << 178 << 179 fpStateDependent = new G4VisStateDependent ( << 180 // No need to delete this; G4StateManager do << 181 << 182 fVerbosity = GetVerbosityValue(verbosityStri << 183 if (fVerbosity >= startup) { << 184 G4cout << 185 << "Visualization Manager instantiating with << 186 << VerbosityString(fVerbosity) << 187 << "\"..." << G4endl; << 188 } << 189 << 190 // Note: The specific graphics systems must << 191 // higher level library to avoid circular de << 192 // some specifically need additional externa << 193 // user must supply. Therefore we ask the u << 194 // RegisterGraphicsSystems() and RegisterMod << 195 // in a subclass. We have to wait for the s << 196 // so RegisterGraphicsSystems() cannot be ca << 197 // constructor; it is called from Initialise << 198 // user: << 199 // (a) to write a subclass and implement << 200 // and RegisterModelFactories(). See << 201 // visualization/include/G4VisExecutiv << 202 // (b) instantiate the subclass. << 203 // (c) invoke the Initialise() method of t << 204 // For example: << 205 // ... << 206 // // Instantiate and initialise Visualiza << 207 // G4VisManager* visManager = new G4VisExe << 208 // visManager -> SetVerboseLevel (Verbose) << 209 // visManager -> Initialise (); << 210 // // (Don't forget to delete visManager;) << 211 // ... << 212 << 213 // Make top level command directory... << 214 // vis commands should *not* be broadcast to << 215 G4bool propagateToWorkers; << 216 auto directory = new G4UIdirectory ("/vis/", << 217 directory -> SetGuidance ("Visualization com << 218 // Request commands in name order << 219 directory -> Sort(); // Ordering propagates << 220 fDirectoryList.push_back (directory); << 221 << 222 // Instantiate *basic* top level commands so << 223 // immediately after instantiation of the vi << 224 // level and lower level commands are instan << 225 // RegisterMessengers. << 226 G4VVisCommand::SetVisManager (this); // Set << 227 RegisterMessenger(new G4VisCommandVerbose); << 228 RegisterMessenger(new G4VisCommandInitialize << 229 } << 230 << 231 G4VisManager::~G4VisManager() << 232 { << 233 G4UImanager* UImanager = G4UImanager::GetUIp << 234 UImanager->SetCoutDestination(nullptr); << 235 std::size_t i; << 236 for (i = 0; i < fSceneList.size (); ++i) { << 237 delete fSceneList[i]; << 238 } << 239 for (i = 0; i < fAvailableSceneHandlers.size << 240 if (fAvailableSceneHandlers[i] != NULL) { << 241 delete fAvailableSceneHandlers[i]; << 242 } << 243 } 58 } 244 for (i = 0; i < fAvailableGraphicsSystems.si << 59 else { 245 if (fAvailableGraphicsSystems[i]) { << 60 246 delete fAvailableGraphicsSystems[i]; << 61 fpInstance = this; 247 } << 62 248 } << 63 fpStateDependent = new G4VisStateDependent (this); 249 if (fVerbosity >= startup) { << 64 // No need to delete this; G4StateManager does this. 250 G4cout << "Graphics systems deleted." << G << 65 251 G4cout << "Visualization Manager deleting. << 66 G4cout << "Constructing Visualization Manager...." << G4endl; 252 } << 67 // Note: You might think that we could register graphics systems 253 for (i = 0; i < fMessengerList.size (); ++i) << 68 // and messengers here but we have to give the subclass time to 254 delete fMessengerList[i]; << 69 // instantiate. So the user has to invoke Initialise(). 255 } << 256 for (i = 0; i < fDirectoryList.size (); ++i) << 257 delete fDirectoryList[i]; << 258 } 70 } >> 71 } 259 72 260 delete fpDigiFilterMgr; << 73 G4VisManager::~G4VisManager () { 261 delete fpHitFilterMgr; << 262 delete fpTrajFilterMgr; << 263 delete fpTrajDrawModelMgr; << 264 fpInstance = 0; 74 fpInstance = 0; >> 75 fSceneList.clearAndDestroy (); >> 76 fAvailableSceneHandlers.clearAndDestroy (); >> 77 fAvailableGraphicsSystems.clearAndDestroy (); >> 78 G4cout << "Graphics systems deleted." << G4endl; >> 79 G4cout << "VisManager deleting." << G4endl; >> 80 fMessengerList.clearAndDestroy (); >> 81 delete fpMessenger; 265 } 82 } 266 83 267 G4VisManager* G4VisManager::GetInstance () { 84 G4VisManager* G4VisManager::GetInstance () { 268 if (!fpInstance) { 85 if (!fpInstance) { 269 G4Exception 86 G4Exception 270 ("G4VisManager::GetInstance", << 87 ("G4VisManager::GetInstance: VisManager not yet instantiated!"); 271 "visman0002", FatalException, "VisManag << 272 } 88 } 273 return fpInstance; 89 return fpInstance; 274 } 90 } 275 91 276 void G4VisManager::Initialise () { 92 void G4VisManager::Initialise () { 277 93 278 if (fInitialised && fVerbosity >= warnings) << 94 G4cout << "Initialising Visualization Manager...." << G4endl; 279 G4warn << "WARNING: G4VisManager::Initiali << 280 << G4endl; << 281 return; << 282 } << 283 95 284 if (fVerbosity >= startup) { << 96 if (fVerbose > 0) { 285 G4cout << "Visualization Manager initialis << 97 PrintAllGraphicsSystems (); 286 } << 98 PrintInstalledGraphicsSystems (); 287 << 288 if (fVerbosity >= parameters) { << 289 G4cout << 99 G4cout << 290 "\nYou have instantiated your own Visual 100 "\nYou have instantiated your own Visualization Manager, inheriting" 291 "\n G4VisManager and implementing Regis << 101 "\n G4VisManager and implementing RegisterGraphicsSystems. An example" 292 "\n you should, normally, instantiate d << 102 "\n class MyVisManager is provided which is controlled by the" 293 "\n external packages or libraries, and << 103 "\n following environment variables:" 294 "\n control of environment variables." << 104 #ifdef G4VIS_BUILD_DAWN_DRIVER 295 "\n Also you should implement RegisterM << 105 "\n G4VIS_USE_DAWN" 296 "\n See visualization/management/includ << 106 #endif 297 "\n In your main() you will have someth << 107 #ifdef G4VIS_BUILD_DAWNFILE_DRIVER 298 "\n G4VisManager* visManager = new G4 << 108 "\n G4VIS_USE_DAWNFILE" 299 "\n visManager -> SetVerboseLevel (Ve << 109 #endif >> 110 #ifdef G4VIS_BUILD_OPACS_DRIVER >> 111 "\n G4VIS_USE_OPACS" >> 112 #endif >> 113 #ifdef G4VIS_BUILD_OPENGLX_DRIVER >> 114 "\n G4VIS_USE_OPENGLX" >> 115 #endif >> 116 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER >> 117 "\n G4VIS_USE_OPENGLXM" >> 118 #endif >> 119 #ifdef G4VIS_BUILD_OIX_DRIVER >> 120 "\n G4VIS_USE_OIX" >> 121 #endif >> 122 #ifdef G4VIS_BUILD_OIWIN32_DRIVER >> 123 "\n G4VIS_USE_OIWIN32" >> 124 #endif >> 125 #ifdef G4VIS_BUILD_VRML_DRIVER >> 126 "\n G4VIS_USE_VRML" >> 127 #endif >> 128 #ifdef G4VIS_BUILD_VRMLFILE_DRIVER >> 129 "\n G4VIS_USE_VRMLFILE" >> 130 #endif >> 131 "\n Thus, in your main() you have something like:" >> 132 "\n G4VisManager* visManager = new MyVisManager;" 300 "\n visManager -> Initialize ();" 133 "\n visManager -> Initialize ();" 301 "\n (Don't forget to delete visManager; 134 "\n (Don't forget to delete visManager;)" 302 "\n" << 303 << G4endl; 135 << G4endl; 304 } 136 } 305 << 137 306 if (fVerbosity >= startup) { << 138 G4cout << "Registering graphics systems...." << G4endl; 307 G4cout << "Registering graphics systems... << 308 } << 309 139 310 RegisterGraphicsSystems (); 140 RegisterGraphicsSystems (); 311 141 312 if (fVerbosity >= startup) { << 313 G4cout << << 314 "\nYou have successfully registered the << 315 << G4endl; << 316 PrintAvailableGraphicsSystems (fVerbosity) << 317 G4cout << G4endl; << 318 } << 319 << 320 // Make command directories for commands ins << 321 // modeling subcategory... << 322 G4UIcommand* directory; << 323 directory = new G4UIdirectory ("/vis/modelin << 324 directory -> SetGuidance ("Modeling commands << 325 fDirectoryList.push_back (directory); << 326 directory = new G4UIdirectory ("/vis/modelin << 327 directory -> SetGuidance ("Trajectory model << 328 fDirectoryList.push_back (directory); << 329 directory = new G4UIdirectory ("/vis/modelin << 330 directory -> SetGuidance ("Create trajectory << 331 fDirectoryList.push_back (directory); << 332 << 333 // Filtering command directory << 334 directory = new G4UIdirectory ("/vis/filteri << 335 directory -> SetGuidance ("Filtering command << 336 fDirectoryList.push_back (directory); << 337 directory = new G4UIdirectory ("/vis/filteri << 338 directory -> SetGuidance ("Trajectory filter << 339 fDirectoryList.push_back (directory); << 340 directory = new G4UIdirectory ("/vis/filteri << 341 directory -> SetGuidance ("Create trajectory << 342 fDirectoryList.push_back (directory); << 343 directory = new G4UIdirectory ("/vis/filteri << 344 directory -> SetGuidance ("Hit filtering com << 345 fDirectoryList.push_back (directory); << 346 directory = new G4UIdirectory ("/vis/filteri << 347 directory -> SetGuidance ("Create hit filter << 348 fDirectoryList.push_back (directory); << 349 directory = new G4UIdirectory ("/vis/filteri << 350 directory -> SetGuidance ("Digi filtering co << 351 fDirectoryList.push_back (directory); << 352 directory = new G4UIdirectory ("/vis/filteri << 353 directory -> SetGuidance ("Create digi filte << 354 fDirectoryList.push_back (directory); << 355 << 356 RegisterMessengers (); 142 RegisterMessengers (); 357 143 358 if (fVerbosity >= startup) { << 144 // Remaining commands - not yet template-ised. 359 G4cout << "Registering model factories..." << 145 fpMessenger = new G4VisManMessenger (this); 360 } << 361 146 362 RegisterModelFactories(); << 147 // TEMPORARY /vis/ -> /vis~/ equivalence. 363 << 148 fMessengerList.append (new G4VisToOldVisCommands); 364 if (fVerbosity >= startup) { << 365 G4cout << << 366 "\nYou have successfully registered the << 367 << G4endl; << 368 PrintAvailableModels (fVerbosity); << 369 G4cout << G4endl; << 370 } << 371 << 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 149 386 fInitialised = true; 150 fInitialised = true; 387 } 151 } 388 152 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() { << 751 if (IsValidView ()) { << 752 SetConcreteInstance(this); << 753 if (fVerbosity >= confirmations) { << 754 G4cout << "G4VisManager::Enable: visuali << 755 } << 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 } << 774 else { << 775 if (fVerbosity >= warnings) { << 776 G4warn << << 777 "G4VisManager::Enable: WARNING: visualizatio << 778 "\n above reasons. Rectifying with valid v << 779 "\n automatically enable." << 780 << G4endl; << 781 } << 782 } << 783 } << 784 << 785 void G4VisManager::Disable() { << 786 SetConcreteInstance(0); << 787 if (fVerbosity >= confirmations) { << 788 G4cout << << 789 "G4VisManager::Disable: visualization disa << 790 "\n The pointer returned by GetConcreteIn << 791 "\n Note that it will become enabled afte << 792 << G4endl; << 793 } << 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 } << 809 << 810 const G4GraphicsSystemList& G4VisManager::GetA 153 const G4GraphicsSystemList& G4VisManager::GetAvailableGraphicsSystems () { 811 std::size_t nSystems = fAvailableGraphicsSys << 154 G4int nSystems = fAvailableGraphicsSystems.entries (); 812 if (nSystems == 0) { 155 if (nSystems == 0) { 813 if (fVerbosity >= warnings) { << 156 G4cout << "G4VisManager::GetAvailableGraphicsSystems: WARNING: no graphics" 814 G4warn << "G4VisManager::GetAvailableGra << 157 " system available!" 815 "\n graphics system available!" << 158 "\n 1) Did you have environment variables G4VIS_BUILD_xxxx_DRIVER set" 816 "\n 1) Did you have environment variables G << 159 "\n when you compiled/built the visualization code?" 817 "\n when you compiled/built the visualiz << 160 "\n 2) Did you instantiate your own Visualization Manager and forget" 818 "\n 2) Did you instantiate your own Visuali << 161 "\n to implement RegisterGraphicsSystems correctly?" 819 "\n to implement RegisterGraphicsSystems << 162 "\n 3) You can register your own graphics system, e.g.," 820 "\n 3) You can register your own graphics s << 163 "\n G4VisManager::GetInstance () ->" 821 "\n visManager->RegisterGraphicsSystem(n << 164 "\n RegisterGraphicsSystem (new MyGraphicsSystem);)" 822 "\n after instantiating your vis manager << 165 << G4endl; 823 "\n visManager->Initialize()." << 824 << G4endl; << 825 } << 826 } 166 } 827 return fAvailableGraphicsSystems; 167 return fAvailableGraphicsSystems; 828 } 168 } 829 169 830 G4bool G4VisManager::RegisterGraphicsSystem (G 170 G4bool G4VisManager::RegisterGraphicsSystem (G4VGraphicsSystem* pSystem) { 831 G4bool happy = true; << 171 if (pSystem -> GetFunctionality () == G4VGraphicsSystem::noFunctionality) { 832 if (pSystem) { << 172 G4cout << "G4VisManager::RegisterGraphicsSystem: WARNING: attempt to" 833 fAvailableGraphicsSystems.push_back (pSyst << 173 "\n register a \"no functionality\" graphics system, probably an" 834 if (fVerbosity >= confirmations) { << 174 "\n unbuilt system, i.e., a system not available locally. Please" >> 175 "\n consult your computer manager. System was " >> 176 << pSystem -> GetName (); >> 177 if (pSystem -> GetNickname () != "") { >> 178 G4cout << " (" << pSystem -> GetNickname () << ")"; >> 179 } >> 180 G4cout << G4endl; >> 181 return false; >> 182 } >> 183 else { >> 184 fAvailableGraphicsSystems.append (pSystem); >> 185 if (fVerbose > 0) { 835 G4cout << "G4VisManager::RegisterGraphic 186 G4cout << "G4VisManager::RegisterGraphicsSystem: " 836 << pSystem -> GetName (); << 187 << pSystem -> GetName (); 837 if (pSystem -> GetNickname () != "") { 188 if (pSystem -> GetNickname () != "") { 838 G4cout << " (" << pSystem -> GetNickname () 189 G4cout << " (" << pSystem -> GetNickname () << ")"; 839 } 190 } 840 G4cout << " registered." << G4endl; 191 G4cout << " registered." << G4endl; 841 } 192 } >> 193 return true; 842 } 194 } 843 else { << 195 } 844 if (fVerbosity >= errors) { << 196 845 G4warn << "G4VisManager::RegisterGraphic << 197 void G4VisManager::CopyViewParameters () { 846 << G4endl; << 198 if (IsValidView ()) { 847 } << 199 fVP = fpViewer -> GetViewParameters (); 848 happy=false; << 849 } 200 } 850 return happy; << 851 } 201 } 852 202 853 const G4VTrajectoryModel* << 203 /*********** 854 G4VisManager::CurrentTrajDrawModel() const << 204 void G4VisManager::Clear () { 855 { << 856 assert (0 != fpTrajDrawModelMgr); << 857 205 858 const G4VTrajectoryModel* model = fpTrajDraw << 206 // Clear current scene and current view, marking all its views as >> 207 // needing refreshing. This is a comprehensive clear which clears >> 208 // both framebuffers of a double buffered system and clears the >> 209 // scene's graphics databse (display lists, etc.) and clears the >> 210 // current scene data. 859 211 860 if (0 == model) { << 212 if (IsValidView ()) { 861 // No model was registered with the trajec << 862 // Use G4TrajectoryDrawByCharge as a fallb << 863 fpTrajDrawModelMgr->Register(new G4Traject << 864 if (fVerbosity >= warnings) { << 865 G4warn<<"G4VisManager: Using G4Trajector << 866 G4warn<<"See commands in /vis/modeling/t << 867 } << 868 } << 869 213 870 model = fpTrajDrawModelMgr->Current(); << 214 fpViewer -> ClearView (); 871 assert (0 != model); // Should definitely ex << 215 // Clears current buffer, i.e., back buffer in case of double >> 216 // buffered system. 872 217 873 return model; << 218 fpViewer -> FinishView (); 874 } << 219 // Swaps buffers of double buffered systems. 875 220 876 void G4VisManager::RegisterModel(G4VTrajectory << 221 fpViewer -> ClearView (); 877 { << 222 // Clears the swapped buffer. 878 fpTrajDrawModelMgr->Register(model); << 879 } << 880 223 881 void << 224 fpViewer -> NeedKernelVisit (); 882 G4VisManager::RegisterModelFactory(G4TrajDrawM << 225 // Informs all views of need to revisit kernel. 883 { << 884 fpTrajDrawModelMgr->Register(factory); << 885 } << 886 226 887 void G4VisManager::RegisterModel(G4VFilter<G4V << 227 fpSceneHandler -> ClearStore (); 888 { << 228 // Clears the graphics database (display lists) if any. 889 fpTrajFilterMgr->Register(model); << 890 } << 891 229 892 void << 230 fSD.Clear (); 893 G4VisManager::RegisterModelFactory(G4TrajFilte << 231 fpSceneHandler -> SetSceneData (fSD); 894 { << 232 // Clears current scene data - then updates scene. 895 fpTrajFilterMgr->Register(factory); << 233 } 896 } 234 } >> 235 *****************/ 897 236 898 void G4VisManager::RegisterModel(G4VFilter<G4V << 237 /**************** 899 { << 238 void G4VisManager::ClearScene () { 900 fpHitFilterMgr->Register(model); << 901 } << 902 239 903 void << 240 // Clear current scene, marking all its views as needing refreshing. 904 G4VisManager::RegisterModelFactory(G4HitFilter << 241 // Clears the scene handler's graphics database (display lists, etc.) 905 { << 906 fpHitFilterMgr->Register(factory); << 907 } << 908 242 909 void G4VisManager::RegisterModel(G4VFilter<G4V << 243 if (IsValidView ()) { 910 { << 911 fpDigiFilterMgr->Register(model); << 912 } << 913 244 914 void << 245 fpViewer -> NeedKernelVisit (); 915 G4VisManager::RegisterModelFactory(G4DigiFilte << 246 // Informs all views of need to revisit kernel. 916 { << 917 fpDigiFilterMgr->Register(factory); << 918 } << 919 247 920 void G4VisManager::SelectTrajectoryModel(const << 248 fpSceneHandler -> ClearStore (); 921 { << 249 // Clears the graphics database (display lists) if any. 922 fpTrajDrawModelMgr->SetCurrent(model); << 923 } << 924 250 925 void G4VisManager::BeginDraw (const G4Transfor << 251 fSD.Clear (); 926 { << 252 fpSceneHandler -> SetSceneData (fSD); 927 if (G4Threading::IsWorkerThread()) return; << 253 // Clears current scene data - then updates scene. 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 ()) { << 939 ClearTransientStoreIfMarked(); << 940 fpSceneHandler -> BeginPrimitives (objectT << 941 fIsDrawGroup = true; << 942 } 254 } 943 } 255 } >> 256 ********************/ >> 257 >> 258 void G4VisManager::ClearView () { >> 259 >> 260 // Clear visible window of current view (both buffers of a double >> 261 // buffered system). 944 262 945 void G4VisManager::EndDraw () << 946 { << 947 if (G4Threading::IsWorkerThread()) return; << 948 << 949 fDrawGroupNestingDepth--; << 950 if (fDrawGroupNestingDepth != 0) { << 951 if (fDrawGroupNestingDepth < 0) fDrawGroup << 952 return; << 953 } << 954 if (IsValidView ()) { 263 if (IsValidView ()) { 955 fpSceneHandler -> EndPrimitives (); << 264 >> 265 fpViewer -> ClearView (); >> 266 // Clears current buffer, i.e., back buffer in case of double >> 267 // buffered system. >> 268 >> 269 fpViewer -> FinishView (); >> 270 // Swaps buffers of double buffered systems. >> 271 >> 272 fpViewer -> ClearView (); >> 273 // Clears the swapped buffer. 956 } 274 } 957 fIsDrawGroup = false; << 958 } 275 } 959 276 960 void G4VisManager::BeginDraw2D (const G4Transf << 277 void G4VisManager::Draw () { 961 { << 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 ()) { 278 if (IsValidView ()) { 974 ClearTransientStoreIfMarked(); << 279 fpViewer -> SetViewParameters (fVP); 975 fpSceneHandler -> BeginPrimitives2D (objec << 280 fpViewer -> DrawView (); 976 fIsDrawGroup = true; << 977 } 281 } 978 } 282 } 979 283 980 void G4VisManager::EndDraw2D () << 284 void G4VisManager::Show () { 981 { << 982 if (G4Threading::IsWorkerThread()) return; << 983 << 984 fDrawGroupNestingDepth--; << 985 if (fDrawGroupNestingDepth != 0) { << 986 if (fDrawGroupNestingDepth < 0) fDrawGroup << 987 return; << 988 } << 989 if (IsValidView ()) { 285 if (IsValidView ()) { 990 fpSceneHandler -> EndPrimitives2D (); << 286 fpViewer -> ShowView (); 991 } 287 } 992 fIsDrawGroup = false; << 993 } 288 } 994 289 995 template <class T> void G4VisManager::DrawT << 290 void G4VisManager::Draw (const G4Polyline& line, 996 (const T& graphics_primitive, const G4Transfor << 291 const G4Transform3D& objectTransform) { 997 if (G4Threading::IsWorkerThread()) return; << 292 if (IsValidView ()) { 998 << 293 G4ModelingParameters* pMP = fpSceneHandler -> CreateModelingParameters (); 999 if (fIsDrawGroup) { << 294 G4VModel* pModel = new G4NullModel (pMP); 1000 if (objectTransform != fpSceneHandler->Ge << 295 fpSceneHandler -> SetModel (pModel); 1001 G4Exception << 296 fpSceneHandler -> BeginPrimitives (objectTransform); 1002 ("G4VSceneHandler::DrawT", << 297 fpSceneHandler -> AddPrimitive (line); 1003 "visman0010", FatalException, << 298 fpSceneHandler -> EndPrimitives (); 1004 "Different transform detected in Begin/End << 299 fpSceneHandler -> SetModel (0); 1005 } << 300 delete pModel; 1006 fpSceneHandler -> AddPrimitive (graphics_ << 301 delete pMP; 1007 } else { << 1008 if (IsValidView ()) { << 1009 ClearTransientStoreIfMarked(); << 1010 fpSceneHandler -> BeginPrimitives (obje << 1011 fpSceneHandler -> AddPrimitive (graphic << 1012 fpSceneHandler -> EndPrimitives (); << 1013 } << 1014 } 302 } 1015 } 303 } 1016 304 1017 template <class T> void G4VisManager::DrawT2D << 305 void G4VisManager::Draw (const G4Text& text, 1018 (const T& graphics_primitive, const G4Transfo << 306 const G4Transform3D& objectTransform) { 1019 if (G4Threading::IsWorkerThread()) return; << 307 if (IsValidView ()) { 1020 << 308 G4ModelingParameters* pMP = fpSceneHandler -> CreateModelingParameters (); 1021 if (fIsDrawGroup) { << 309 G4VModel* pModel = new G4NullModel (pMP); 1022 if (objectTransform != fpSceneHandler->Ge << 310 fpSceneHandler -> SetModel (pModel); 1023 G4Exception << 311 fpSceneHandler -> BeginPrimitives (objectTransform); 1024 ("G4VSceneHandler::DrawT", << 312 fpSceneHandler -> AddPrimitive (text); 1025 "visman0011", FatalException, << 313 fpSceneHandler -> EndPrimitives (); 1026 "Different transform detected in Begin/End << 314 fpSceneHandler -> SetModel (0); 1027 } << 315 delete pModel; 1028 fpSceneHandler -> AddPrimitive (graphics_ << 316 delete pMP; 1029 } else { << 1030 if (IsValidView ()) { << 1031 ClearTransientStoreIfMarked(); << 1032 fpSceneHandler -> BeginPrimitives2D (ob << 1033 fpSceneHandler -> AddPrimitive (graphic << 1034 fpSceneHandler -> EndPrimitives2D (); << 1035 } << 1036 } 317 } 1037 } 318 } 1038 319 1039 void G4VisManager::Draw (const G4Circle& circ 320 void G4VisManager::Draw (const G4Circle& circle, 1040 const G4Transform3D& objectTransform) << 321 const G4Transform3D& objectTransform) { 1041 { << 322 if (IsValidView ()) { 1042 DrawT (circle, objectTransform); << 323 G4ModelingParameters* pMP = fpSceneHandler -> CreateModelingParameters (); 1043 } << 324 G4VModel* pModel = new G4NullModel (pMP); 1044 << 325 fpSceneHandler -> SetModel (pModel); 1045 void G4VisManager::Draw (const G4Polyhedron& << 326 fpSceneHandler -> BeginPrimitives (objectTransform); 1046 const G4Transform3D& objectTransform) << 327 fpSceneHandler -> AddPrimitive (circle); 1047 { << 328 fpSceneHandler -> EndPrimitives (); 1048 DrawT (polyhedron, objectTransform); << 329 fpSceneHandler -> SetModel (0); >> 330 delete pModel; >> 331 delete pMP; >> 332 } 1049 } 333 } 1050 334 1051 void G4VisManager::Draw (const G4Polyline& li << 335 void G4VisManager::Draw (const G4Square& Square, 1052 const G4Transform3D& objectTransform) << 336 const G4Transform3D& objectTransform) { 1053 { << 337 if (IsValidView ()) { 1054 DrawT (line, objectTransform); << 338 G4ModelingParameters* pMP = fpSceneHandler -> CreateModelingParameters (); >> 339 G4VModel* pModel = new G4NullModel (pMP); >> 340 fpSceneHandler -> SetModel (pModel); >> 341 fpSceneHandler -> BeginPrimitives (objectTransform); >> 342 fpSceneHandler -> AddPrimitive (Square); >> 343 fpSceneHandler -> EndPrimitives (); >> 344 fpSceneHandler -> SetModel (0); >> 345 delete pModel; >> 346 delete pMP; >> 347 } 1055 } 348 } 1056 349 1057 void G4VisManager::Draw (const G4Polymarker& 350 void G4VisManager::Draw (const G4Polymarker& polymarker, 1058 const G4Transform3D& objectTransform) << 351 const G4Transform3D& objectTransform) { 1059 { << 352 if (IsValidView ()) { 1060 DrawT (polymarker, objectTransform); << 353 G4ModelingParameters* pMP = fpSceneHandler -> CreateModelingParameters (); 1061 } << 354 G4VModel* pModel = new G4NullModel (pMP); 1062 << 355 fpSceneHandler -> SetModel (pModel); 1063 void G4VisManager::Draw (const G4Square& squa << 356 fpSceneHandler -> BeginPrimitives (objectTransform); 1064 const G4Transform3D& objectTransform) << 357 fpSceneHandler -> AddPrimitive (polymarker); 1065 { << 358 fpSceneHandler -> EndPrimitives (); 1066 DrawT (square, objectTransform); << 359 fpSceneHandler -> SetModel (0); 1067 } << 360 delete pModel; 1068 << 361 delete pMP; 1069 void G4VisManager::Draw (const G4Text& text, << 362 } 1070 const G4Transform3D& objectTransform) << 1071 { << 1072 DrawT (text, objectTransform); << 1073 } << 1074 << 1075 void G4VisManager::Draw2D (const G4Circle& ci << 1076 const G4Transform3D& objectTransform << 1077 { << 1078 DrawT2D (circle, objectTransform); << 1079 } << 1080 << 1081 void G4VisManager::Draw2D (const G4Polyhedron << 1082 const G4Transform3D& objectTransform << 1083 { << 1084 DrawT2D (polyhedron, objectTransform); << 1085 } << 1086 << 1087 void G4VisManager::Draw2D (const G4Polyline& << 1088 const G4Transform3D& objectTransform << 1089 { << 1090 DrawT2D (line, objectTransform); << 1091 } << 1092 << 1093 void G4VisManager::Draw2D (const G4Polymarker << 1094 const G4Transform3D& objectTransform << 1095 { << 1096 DrawT2D (polymarker, objectTransform); << 1097 } << 1098 << 1099 void G4VisManager::Draw2D (const G4Square& sq << 1100 const G4Transform3D& objectTransform << 1101 { << 1102 DrawT2D (square, objectTransform); << 1103 } << 1104 << 1105 void G4VisManager::Draw2D (const G4Text& text << 1106 const G4Transform3D& objectTransform << 1107 { << 1108 DrawT2D (text, objectTransform); << 1109 } 363 } 1110 364 1111 void G4VisManager::Draw (const G4VHit& hit) { << 365 void G4VisManager::Draw (const G4Polyhedron& polyhedron, 1112 if (G4Threading::IsWorkerThread()) return; << 366 const G4Transform3D& objectTransform) { 1113 << 367 if (IsValidView ()) { 1114 if (fIsDrawGroup) { << 368 G4ModelingParameters* pMP = fpSceneHandler -> CreateModelingParameters (); 1115 fpSceneHandler -> AddCompound (hit); << 369 G4VModel* pModel = new G4NullModel (pMP); 1116 } else { << 370 fpSceneHandler -> SetModel (pModel); 1117 if (IsValidView ()) { << 371 fpSceneHandler -> BeginPrimitives (objectTransform); 1118 ClearTransientStoreIfMarked(); << 372 fpSceneHandler -> AddPrimitive (polyhedron); 1119 fpSceneHandler -> AddCompound (hit); << 373 fpSceneHandler -> EndPrimitives (); 1120 } << 374 fpSceneHandler -> SetModel (0); >> 375 delete pModel; >> 376 delete pMP; 1121 } 377 } 1122 } 378 } 1123 379 1124 void G4VisManager::Draw (const G4VDigi& digi) << 380 void G4VisManager::Draw (const G4NURBS& nurbs, 1125 if (G4Threading::IsWorkerThread()) return; << 381 const G4Transform3D& objectTransform) { 1126 << 382 if (IsValidView ()) { 1127 if (fIsDrawGroup) { << 383 G4ModelingParameters* pMP = fpSceneHandler -> CreateModelingParameters (); 1128 fpSceneHandler -> AddCompound (digi); << 384 G4VModel* pModel = new G4NullModel (pMP); 1129 } else { << 385 fpSceneHandler -> SetModel (pModel); 1130 if (IsValidView ()) { << 386 fpSceneHandler -> BeginPrimitives (objectTransform); 1131 ClearTransientStoreIfMarked(); << 387 fpSceneHandler -> AddPrimitive (nurbs); 1132 fpSceneHandler -> AddCompound (digi); << 388 fpSceneHandler -> EndPrimitives (); 1133 } << 389 fpSceneHandler -> SetModel (0); >> 390 delete pModel; >> 391 delete pMP; 1134 } 392 } 1135 } 393 } 1136 394 1137 void G4VisManager::Draw (const G4VTrajectory& << 395 void G4VisManager::Draw (const G4VSolid& solid, 1138 if (G4Threading::IsWorkerThread()) return; << 396 const G4VisAttributes& attribs, 1139 << 397 const G4Transform3D& objectTransform) { 1140 // A trajectory needs a trajectories model << 398 if (IsValidView ()) { 1141 static G4TrajectoriesModel trajectoriesMode << 399 G4ModelingParameters* pMP = fpSceneHandler -> CreateModelingParameters (); 1142 trajectoriesModel.SetCurrentTrajectory(&tra << 400 G4VModel* pModel = new G4NullModel (pMP); 1143 G4RunManager* runManager = G4RunManagerFact << 401 fpSceneHandler -> SetModel (pModel); 1144 const G4Run* currentRun = runManager->GetC << 402 fpSceneHandler -> PreAddThis (objectTransform, attribs); 1145 if (currentRun) { << 403 solid.DescribeYourselfTo (*fpSceneHandler); 1146 trajectoriesModel.SetRunID(currentRun->Ge << 404 fpSceneHandler -> PostAddThis (); 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); << 1156 fpSceneHandler -> SetModel (0); 405 fpSceneHandler -> SetModel (0); 1157 } else { << 406 delete pModel; 1158 if (IsValidView ()) { << 407 delete pMP; 1159 ClearTransientStoreIfMarked(); << 1160 fpSceneHandler -> SetModel (&trajectori << 1161 fpSceneHandler -> AddCompound (traj); << 1162 fpSceneHandler -> SetModel (0); << 1163 } << 1164 } 408 } 1165 } 409 } 1166 410 1167 void G4VisManager::Draw (const G4LogicalVolum 411 void G4VisManager::Draw (const G4LogicalVolume& logicalVol, 1168 const G4VisAttributes& attribs, 412 const G4VisAttributes& attribs, 1169 const G4Transform3D& objectTransform) 413 const G4Transform3D& objectTransform) { 1170 if (G4Threading::IsWorkerThread()) return; << 1171 << 1172 // Find corresponding solid. 414 // Find corresponding solid. 1173 G4VSolid* pSol = logicalVol.GetSolid (); 415 G4VSolid* pSol = logicalVol.GetSolid (); 1174 Draw (*pSol, attribs, objectTransform); 416 Draw (*pSol, attribs, objectTransform); 1175 } 417 } 1176 418 1177 void G4VisManager::Draw (const G4VSolid& soli << 1178 const G4VisAttributes& attribs, << 1179 const G4Transform3D& objectTransform) << 1180 if (G4Threading::IsWorkerThread()) return; << 1181 << 1182 if (fIsDrawGroup) { << 1183 fpSceneHandler -> PreAddSolid (objectTran << 1184 solid.DescribeYourselfTo (*fpSceneHandler << 1185 fpSceneHandler -> PostAddSolid (); << 1186 } else { << 1187 if (IsValidView ()) { << 1188 ClearTransientStoreIfMarked(); << 1189 fpSceneHandler -> PreAddSolid (objectTr << 1190 solid.DescribeYourselfTo (*fpSceneHandl << 1191 fpSceneHandler -> PostAddSolid (); << 1192 } << 1193 } << 1194 } << 1195 << 1196 void G4VisManager::Draw (const G4VPhysicalVol 419 void G4VisManager::Draw (const G4VPhysicalVolume& physicalVol, 1197 const G4VisAttributes& attribs, 420 const G4VisAttributes& attribs, 1198 const G4Transform3D& objectTransform) 421 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 422 // Find corresponding logical volume and solid. 1213 G4LogicalVolume* pLV = physicalVol.GetLogi 423 G4LogicalVolume* pLV = physicalVol.GetLogicalVolume (); 1214 G4VSolid* pSol = pLV -> GetSolid (); 424 G4VSolid* pSol = pLV -> GetSolid (); 1215 Draw (*pSol, attribs, objectTransform); 425 Draw (*pSol, attribs, objectTransform); 1216 } 426 } 1217 427 1218 void G4VisManager::DrawGeometry << 428 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 (); 429 if (!fInitialised) Initialise (); 1232 if (fpGraphicsSystem) { 430 if (fpGraphicsSystem) { 1233 G4VSceneHandler* pSceneHandler = 431 G4VSceneHandler* pSceneHandler = 1234 fpGraphicsSystem -> CreateSceneHandler 432 fpGraphicsSystem -> CreateSceneHandler (name); >> 433 G4VViewer* pViewer; 1235 if (pSceneHandler) { 434 if (pSceneHandler) { 1236 fAvailableSceneHandlers.push_back (pSce << 435 fAvailableSceneHandlers.append (pSceneHandler); 1237 fpSceneHandler = pSceneHandler; 436 fpSceneHandler = pSceneHandler; // Make current. 1238 } 437 } 1239 else { 438 else { 1240 if (fVerbosity >= errors) { << 439 G4cout << "Error in G4VisManager::CreateSceneHandler during " 1241 G4warn << "ERROR in G4VisManager::CreateSce << 440 << fpGraphicsSystem -> GetName () 1242 << fpGraphicsSystem -> GetName () << 441 << " scene creation." 1243 << " scene handler creation.\n No a << 442 << G4endl; 1244 << G4endl; << 443 fpSceneHandler = 0; 1245 } << 444 fpViewer = 0; >> 445 // Make it impossible for user action code to Draw. >> 446 fpConcreteInstance = 0; 1246 } 447 } 1247 } 448 } 1248 else PrintInvalidPointers (); 449 else PrintInvalidPointers (); 1249 } 450 } 1250 451 1251 void G4VisManager::CreateViewer << 452 void G4VisManager::CreateViewer (G4String name) { 1252 (const G4String& name, const G4String& XGeome << 1253 { << 1254 453 1255 if (!fInitialised) Initialise (); 454 if (!fInitialised) Initialise (); 1256 455 1257 if (!fpSceneHandler) { << 456 if (fpSceneHandler) { 1258 PrintInvalidPointers (); << 457 G4VViewer* p = fpGraphicsSystem -> CreateViewer (*fpSceneHandler, name); 1259 return; << 458 if (p) { 1260 } << 459 fpViewer = p; // Make current. 1261 << 460 fpSceneHandler -> AddViewerToList (fpViewer); 1262 G4VViewer* p = fpGraphicsSystem -> CreateVi << 461 fpSceneHandler -> SetCurrentViewer (fpViewer); 1263 << 462 // Make it possible for user action code to Draw. 1264 if (!p) { << 463 fpConcreteInstance = this; 1265 if (fVerbosity >= errors) { << 464 1266 G4warn << "ERROR in G4VisManager::Creat << 465 G4bool warnings = false; 1267 << fpGraphicsSystem -> GetName () << 466 if (fVP.IsCulling () && fVP.IsCullingInvisible ()) { 1268 << " viewer creation.\n No action tak << 467 warnings = true; >> 468 G4cout << "G4VisManager::CreateViewer: new viewer created:"; >> 469 if (fVerbose > 0) { >> 470 G4cout << " view parameters are:\n " << fVP; >> 471 } >> 472 G4cout << >> 473 "\n NOTE: objects with visibility flag set to \"false\"" >> 474 " will not be drawn!" >> 475 "\n \"/vis~/set/culling off\" to Draw such objects."; >> 476 } >> 477 if (fVP.IsCullingCovered ()) { >> 478 if (!warnings) { >> 479 G4cout << "G4VisManager::CreateViewer: new viewer created:"; >> 480 } >> 481 warnings = true; >> 482 G4cout << >> 483 "\n ALSO: covered objects in solid mode will not be part of" >> 484 " the scene!" >> 485 "\n \"/vis~/set/cull_covered_daughters off\" to reverse this."; >> 486 } >> 487 if (warnings) { >> 488 G4cout << "\n Also see other \"/vis~/set\" commands." 1269 << G4endl; 489 << G4endl; 1270 } << 490 } 1271 return; << 1272 } << 1273 491 1274 if (p -> GetViewId() < 0) { << 1275 if (fVerbosity >= errors) { << 1276 G4warn << "ERROR in G4VisManager::Creat << 1277 << fpGraphicsSystem -> GetName () << 1278 << " viewer instantiation.\n No actio << 1279 << G4endl; << 1280 } 492 } 1281 return; << 1282 } 493 } >> 494 else PrintInvalidPointers (); >> 495 } 1283 496 1284 // Viewer is created, now we can set geomet << 497 void G4VisManager::DeleteCurrentSceneHandler () { 1285 // Before 12/2008, it was done in G4VViewer << 498 G4cout << "G4VisManager::DeleteCurrentSceneHandler: scene handler \"" 1286 << 499 << fpSceneHandler -> GetName () 1287 G4ViewParameters initialvp = p -> GetViewPa << 500 << "\"\n and its viewer(s) are being deleted."; 1288 initialvp.SetXGeometryString(XGeometry); // << 501 if(fpSceneHandler) { 1289 p -> SetViewParameters(initialvp); << 502 fAvailableSceneHandlers.remove (fpSceneHandler); 1290 p -> Initialise (); // (Viewer itself may << 503 delete fpSceneHandler; 1291 if (p -> GetViewId() < 0) { << 504 } 1292 if (fVerbosity >= errors) { << 505 const G4SceneHandlerList& sceneHandlerList = fAvailableSceneHandlers; 1293 G4warn << "ERROR in G4VisManager::Creat << 506 G4int nSH = sceneHandlerList.entries (); 1294 << fpGraphicsSystem -> GetName () << 507 G4int iSH; 1295 << " viewer initialisation.\n No acti << 508 for (iSH = 0; iSH < nSH; iSH++) { 1296 << G4endl; << 509 if (sceneHandlerList [iSH] -> GetViewerList ().entries ()) break; 1297 } << 510 } 1298 return; << 511 if (iSH < nSH) { >> 512 fpSceneHandler = sceneHandlerList [iSH]; >> 513 G4cout << "\n scene handler is now \"" >> 514 << fpSceneHandler -> GetName (); >> 515 fpViewer = fpSceneHandler -> GetViewerList () [0]; >> 516 G4cout << "\"\n and viewer now \"" >> 517 << fpViewer -> GetName () >> 518 << "."; >> 519 IsValidView (); // Check. >> 520 } >> 521 else if (nSH) { >> 522 fpSceneHandler = fAvailableSceneHandlers [0]; >> 523 G4cout << "\n scene handler is now \"" >> 524 << fpSceneHandler -> GetName (); >> 525 fpViewer = 0; >> 526 // Make it impossible for user action code to Draw. >> 527 fpConcreteInstance = 0; >> 528 G4cout << "\" but it has no viewers -\n please create one."; 1299 } 529 } 1300 << 530 else { 1301 fpViewer = p; / << 531 fpSceneHandler = 0; 1302 fpSceneHandler -> AddViewerToList (fpViewer << 532 fpViewer = 0; 1303 fpSceneHandler -> SetCurrentViewer (fpViewe << 533 // Make it impossible for user action code to Draw. 1304 if (fVerbosity >= confirmations) { << 534 fpConcreteInstance = 0; 1305 G4cout << "G4VisManager::CreateViewer: ne << 535 G4cout << 1306 << G4endl; << 536 "\n There are now no scene handlers left. /vis/sceneHandler/select" >> 537 "\n to select a scene handler and /vis/viewer/select to select" >> 538 "\n a viewer, or maybe you will have to create some."; 1307 } 539 } >> 540 G4cout << G4endl; >> 541 } 1308 542 1309 const G4ViewParameters& vp = fpViewer->GetV << 543 void G4VisManager::DeleteCurrentViewer () { 1310 if (fVerbosity >= parameters) { << 544 G4cout << "G4VisManager::DeleteCurrentViewer: viewer \"" 1311 G4cout << " view parameters are:\n " << << 545 << fpViewer -> GetName () >> 546 << "\" being deleted."; >> 547 if (fpViewer ) { >> 548 fpViewer -> GetScene () -> RemoveViewerFromList (fpViewer); >> 549 delete fpViewer; 1312 } 550 } 1313 << 551 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList (); 1314 if (vp.IsCulling () && vp.IsCullingInvisibl << 552 if (viewerList.entries () > 0) { 1315 static G4bool warned = false; << 553 fpViewer = viewerList [0]; 1316 if (fVerbosity >= confirmations) { << 554 fpSceneHandler -> SetCurrentViewer (fpViewer); 1317 if (!warned) { << 555 if (IsValidView ()) { 1318 G4cout << << 556 G4cout << "\n viewer is now \"" 1319 "NOTE: objects with visibility flag set to << 557 << fpViewer -> GetName () 1320 " will not be drawn!" << 558 << "\"."; 1321 "\n \"/vis/viewer/set/culling global false << 1322 "\n Also see other \"/vis/viewer/set\" com << 1323 << G4endl; << 1324 warned = true; << 1325 } << 1326 } 559 } 1327 } 560 } 1328 if (vp.IsCullingCovered ()) { << 561 else { 1329 static G4bool warned = false; << 562 fpViewer = 0; 1330 if (fVerbosity >= warnings) { << 563 fpSceneHandler -> SetCurrentViewer (0); 1331 if (!warned) { << 564 // Make it impossible for user action code to Draw. 1332 G4warn << << 565 fpConcreteInstance = 0; 1333 "WARNING: covered objects in solid mode wil << 566 G4cout << 1334 "\n \"/vis/viewer/set/culling coveredDaugh << 567 "\n There are now no viewers left for this scene handler." 1335 "\n Also see other \"/vis/viewer/set\" com << 568 "\n /vis/sceneHandler/select to select a different scene handler" 1336 << G4endl; << 569 "\n and /vis/viewer/select to select a viewer, or maybe you will" 1337 warned = true; << 570 "\n have to create some."; 1338 } << 1339 } << 1340 } 571 } >> 572 G4cout << G4endl; 1341 } 573 } 1342 574 1343 void G4VisManager::GeometryHasChanged () { 575 void G4VisManager::GeometryHasChanged () { 1344 if (fVerbosity >= confirmations) { << 576 G4cout << "G4VisManager::GeometryHasChanged() called." << G4endl; 1345 G4cout << "G4VisManager::GeometryHasChang << 1346 } << 1347 577 1348 // Change the world... 578 // Change the world... 1349 G4VPhysicalVolume* pWorld = 579 G4VPhysicalVolume* pWorld = 1350 G4TransportationManager::GetTransportatio 580 G4TransportationManager::GetTransportationManager () 1351 -> GetNavigatorForTracking () -> GetWorld 581 -> GetNavigatorForTracking () -> GetWorldVolume (); 1352 if (!pWorld) { 582 if (!pWorld) { 1353 if (fVerbosity >= warnings) { << 583 G4cout << " The world has ended!!! (Is this serious?)" << G4endl; 1354 G4warn << "WARNING: There is no world v << 1355 } << 1356 } 584 } 1357 585 1358 // Check scenes. 586 // Check scenes. 1359 G4SceneList& sceneList = fSceneList; 587 G4SceneList& sceneList = fSceneList; 1360 std::size_t iScene, nScenes = sceneList.siz << 588 G4int iScene, nScenes = sceneList.entries (); 1361 for (iScene = 0; iScene < nScenes; ++iScene << 589 for (iScene = 0; iScene < nScenes; iScene++) { 1362 G4Scene* pScene = sceneList [iScene]; 590 G4Scene* pScene = sceneList [iScene]; 1363 std::vector<G4Scene::Model>& modelList = << 591 G4RWTPtrOrderedVector <G4VModel>& modelList = 1364 if (modelList.size ()) { << 592 pScene -> SetRunDurationModelList (); 1365 G4bool modelInvalid; << 1366 do { // Remove, if required, one at a << 1367 modelInvalid = false; << 1368 std::vector<G4Scene::Model>::iterator iterM << 1369 for (iterModel = modelList.begin(); << 1370 iterModel != modelList.end(); << 1371 ++iterModel) { << 1372 modelInvalid = !(iterModel->fpModel->Vali << 1373 if (modelInvalid) { << 1374 // Model invalid - remove and break. << 1375 if (fVerbosity >= warnings) { << 1376 G4warn << "WARNING: Model \"" << 1377 << iterModel->fpModel->GetGlobalDesc << 1378 << << 1379 "\" is no longer valid - being removed\n << 1380 << pScene -> GetName () << "\"" << 1381 << G4endl; << 1382 } << 1383 modelList.erase (iterModel); << 1384 break; << 1385 } << 1386 } << 1387 } while (modelInvalid); << 1388 593 1389 if (modelList.size () == 0) { << 594 G4int nModels, iModel; 1390 if (fVerbosity >= warnings) { << 595 G4bool modelInvalid; 1391 G4warn << "WARNING: No run-duration model << 596 do { // Remove, if required, one at a time. 1392 << pScene -> GetName () << 597 modelInvalid = false; 1393 << "\"." << 598 nModels = modelList.entries (); >> 599 for (iModel = 0; iModel < nModels; iModel++) { >> 600 if (modelInvalid = !(modelList [iModel] -> Validate ())) { >> 601 // Model invalid - remove and break. >> 602 G4cout << " Model \"" >> 603 << modelList [iModel] -> GetGlobalDescription () >> 604 << >> 605 "\" is no longer valid - being removed\n from scene \"" >> 606 << pScene -> GetName () << "\"" 1394 << G4endl; 607 << G4endl; >> 608 modelList.removeAt (iModel); >> 609 break; 1395 } 610 } 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 } 611 } 1409 else { << 612 } while (modelInvalid); 1410 pScene->CalculateExtent(); // Recalculate << 1411 G4UImanager::GetUIpointer () -> << 1412 ApplyCommand (G4String("/vis/scene/notify << 1413 } << 1414 } << 1415 } << 1416 613 1417 // Check the manager's current scene... << 614 nModels = modelList.entries (); 1418 if (fpScene && fpScene -> GetRunDurationMod << 615 if (nModels == 0) { 1419 if (fVerbosity >= warnings) { << 616 G4cout << " No models left in this scene \"" 1420 G4warn << "WARNING: The current scene \ << 617 << pScene -> GetName () 1421 << fpScene -> GetName () << 618 << "\"." 1422 << "\" has no run duration models." << 1423 << "\n Use \"/vis/scene/add/vol << 1424 << G4endl; 619 << G4endl; 1425 } 620 } 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 } << 1438 } << 1439 << 1440 void G4VisManager::NotifyHandlers () { << 1441 << 1442 if (fVerbosity >= confirmations) { << 1443 G4cout << "G4VisManager::NotifyHandler() << 1444 } 621 } 1445 622 1446 if (IsValidView()) { << 623 // Check the manager's current scene... 1447 << 624 if (fpScene && fpScene -> GetRunDurationModelList ().entries () == 0) { 1448 // Check scenes. << 625 G4cout << " The current scene \"" 1449 G4SceneList& sceneList = fSceneList; << 626 << fpScene -> GetName () 1450 std::size_t iScene, nScenes = sceneList.s << 627 << "\" has no models left." 1451 for (iScene = 0; iScene < nScenes; ++iSce << 628 << G4endl; 1452 G4Scene* pScene = sceneList [iScene]; << 629 } 1453 std::vector<G4Scene::Model>& modelList << 1454 << 1455 if (modelList.size ()) { << 1456 pScene->CalculateExtent(); << 1457 G4UImanager::GetUIpointer () -> << 1458 ApplyCommand (G4String("/vis/scene/no << 1459 } << 1460 } << 1461 << 1462 // Check the manager's current scene... << 1463 if (fpScene && fpScene -> GetRunDurationM << 1464 if (fVerbosity >= warnings) { << 1465 G4warn << "WARNING: The current scene << 1466 << fpScene -> GetName () << 1467 << "\" has no run duration models." << 1468 << "\n Use \"/vis/scene/add/volume\" << 1469 << G4endl; << 1470 } << 1471 fpSceneHandler->ClearTransientStore(); << 1472 fpSceneHandler->ClearStore(); << 1473 fpViewer->NeedKernelVisit(); << 1474 fpViewer->SetView(); << 1475 fpViewer->ClearView(); << 1476 fpViewer->FinishView(); << 1477 } << 1478 } << 1479 } << 1480 << 1481 G4bool G4VisManager::FilterTrajectory(const G << 1482 { << 1483 return fpTrajFilterMgr->Accept(trajectory); << 1484 } << 1485 << 1486 G4bool G4VisManager::FilterHit(const G4VHit& << 1487 { << 1488 return fpHitFilterMgr->Accept(hit); << 1489 } << 1490 << 1491 G4bool G4VisManager::FilterDigi(const G4VDigi << 1492 { << 1493 return fpDigiFilterMgr->Accept(digi); << 1494 } << 1495 << 1496 void G4VisManager::DispatchToModel(const G4VT << 1497 { << 1498 G4bool visible(true); << 1499 << 1500 // See if trajectory passes filter << 1501 G4bool passed = FilterTrajectory(trajectory << 1502 << 1503 if (!passed) { << 1504 // Draw invisible trajectory if trajector << 1505 // are filtering in soft mode << 1506 if (fpTrajFilterMgr->GetMode() == FilterM << 1507 else {return;} << 1508 } << 1509 << 1510 // Go on to draw trajectory << 1511 assert (0 != fpTrajDrawModelMgr); << 1512 << 1513 const G4VTrajectoryModel* trajectoryModel = << 1514 << 1515 assert (0 != trajectoryModel); // Should ex << 1516 << 1517 if (IsValidView()) { << 1518 trajectoryModel->Draw(trajectory, visib << 1519 } << 1520 } << 1521 << 1522 void G4VisManager::RegisterRunDurationUserVis << 1523 (const G4String& name, << 1524 G4VUserVisAction* pVisAction, << 1525 const G4VisExtent& extent) { << 1526 fRunDurationUserVisActions.push_back(UserVi << 1527 if (extent.GetExtentRadius() > 0.) { << 1528 fUserVisActionExtents[pVisAction] = exten << 1529 } else { << 1530 if (fVerbosity >= warnings) { << 1531 G4warn << << 1532 "WARNING: No extent set for user vis action << 1533 << G4endl; << 1534 } << 1535 } << 1536 if (fVerbosity >= confirmations) { << 1537 G4cout << 1538 << "Run duration user vis action \"" << n << 1539 << G4endl; << 1540 } << 1541 } << 1542 << 1543 void G4VisManager::RegisterEndOfEventUserVisA << 1544 (const G4String& name, << 1545 G4VUserVisAction* pVisAction, << 1546 const G4VisExtent& extent) { << 1547 fEndOfEventUserVisActions.push_back(UserVis << 1548 if (extent.GetExtentRadius() > 0.) { << 1549 fUserVisActionExtents[pVisAction] = exten << 1550 } else { << 1551 if (fVerbosity >= warnings) { << 1552 G4warn << << 1553 "WARNING: No extent set for user vis action << 1554 << G4endl; << 1555 } << 1556 } << 1557 if (fVerbosity >= confirmations) { << 1558 G4cout << 1559 << "End of event user vis action \"" << n << 1560 << G4endl; << 1561 } << 1562 } << 1563 << 1564 void G4VisManager::RegisterEndOfRunUserVisAct << 1565 (const G4String& name, << 1566 G4VUserVisAction* pVisAction, << 1567 const G4VisExtent& extent) { << 1568 fEndOfRunUserVisActions.push_back(UserVisAc << 1569 if (extent.GetExtentRadius() > 0.) { << 1570 fUserVisActionExtents[pVisAction] = exten << 1571 } else { << 1572 if (fVerbosity >= warnings) { << 1573 G4warn << << 1574 "WARNING: No extent set for user vis action << 1575 << G4endl; << 1576 } << 1577 } << 1578 if (fVerbosity >= confirmations) { << 1579 G4cout << 1580 << "End of run user vis action \"" << nam << 1581 << G4endl; << 1582 } << 1583 } 630 } 1584 631 1585 void G4VisManager::SetCurrentScene (G4Scene* << 632 void G4VisManager::SetCurrentGraphicsSystemAndCreateViewer 1586 if (pScene != fpScene) { << 633 (G4VGraphicsSystem* pSystem) { 1587 // A change of scene. Therefore reset tr << 634 // This is used only by the deprecated 1588 // memory of previous transient proceessi << 635 // /vis~/create_view/new_graphics_system command. Hence the ad hoc 1589 ResetTransientsDrawnFlags(); << 636 // creation of "scene-vis~" below as a working solution while these >> 637 // old commands exist. >> 638 fpGraphicsSystem = pSystem; >> 639 if (!fpScene) { >> 640 fpScene = new G4Scene ("scene-vis~"); >> 641 fSceneList.append (fpScene); >> 642 G4cout << "G4VisManager::SetCurrentGraphicsSystemAndCreateViewer:" >> 643 "\n Empty scene \"scene-vis~\" created." >> 644 << G4endl; 1590 } 645 } 1591 fpScene = pScene; << 646 CreateSceneHandler (); >> 647 CreateViewer (); 1592 } 648 } 1593 649 1594 void G4VisManager::SetCurrentGraphicsSystem ( 650 void G4VisManager::SetCurrentGraphicsSystem (G4VGraphicsSystem* pSystem) { 1595 fpGraphicsSystem = pSystem; 651 fpGraphicsSystem = pSystem; 1596 if (fVerbosity >= confirmations) { << 652 G4cout << "G4VisManager::SetCurrentGraphicsSystem: system now " 1597 G4cout << "G4VisManager::SetCurrentGraphi << 653 << pSystem -> GetName (); 1598 << pSystem -> GetName () << G4endl; << 1599 } << 1600 // If current scene handler is of same grap 654 // If current scene handler is of same graphics system, leave unchanged. 1601 // Else find the most recent scene handler 655 // Else find the most recent scene handler of same graphics system. 1602 // Or clear pointers. 656 // Or clear pointers. 1603 if (!(fpSceneHandler && fpSceneHandler -> G 657 if (!(fpSceneHandler && fpSceneHandler -> GetGraphicsSystem () == pSystem)) { 1604 const G4SceneHandlerList& sceneHandlerLis 658 const G4SceneHandlerList& sceneHandlerList = fAvailableSceneHandlers; 1605 G4int nSH = (G4int)sceneHandlerList.size << 659 G4int nSH = sceneHandlerList.entries (); // No. of scene handlers. 1606 G4int iSH; 660 G4int iSH; 1607 for (iSH = nSH - 1; iSH >= 0; iSH--) { 661 for (iSH = nSH - 1; iSH >= 0; iSH--) { 1608 if (sceneHandlerList [iSH] -> GetGraphi 662 if (sceneHandlerList [iSH] -> GetGraphicsSystem () == pSystem) break; 1609 } 663 } 1610 if (iSH >= 0) { << 664 if (iSH >= nSH) { 1611 fpSceneHandler = sceneHandlerList [iSH] 665 fpSceneHandler = sceneHandlerList [iSH]; 1612 if (fVerbosity >= confirmations) { << 666 G4cout << "\n Scene Handler now " 1613 G4cout << " Scene Handler now " << 667 << fpSceneHandler -> GetName (); 1614 << fpSceneHandler -> GetName () << G << 1615 } << 1616 if (fpScene != fpSceneHandler -> GetSce << 1617 fpScene = fpSceneHandler -> GetScene (); << 1618 if (fVerbosity >= confirmations) { << 1619 G4cout << " Scene now \"" << 1620 << fpScene -> GetName () << "\"" << G4en << 1621 } << 1622 } << 1623 const G4ViewerList& viewerList = fpScen 668 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList (); 1624 if (viewerList.size ()) { << 669 if (viewerList.entries ()) { 1625 fpViewer = viewerList [0]; 670 fpViewer = viewerList [0]; 1626 if (fVerbosity >= confirmations) { << 671 G4cout << "\n Viewer now " << fpViewer -> GetName (); 1627 G4cout << " Viewer now " << fpViewer -> << 1628 } << 1629 } 672 } 1630 else { 673 else { 1631 fpViewer = 0; 674 fpViewer = 0; >> 675 // Make it impossible for user action code to Draw. >> 676 fpConcreteInstance = 0; 1632 } 677 } 1633 } 678 } 1634 else { 679 else { 1635 fpSceneHandler = 0; 680 fpSceneHandler = 0; 1636 fpViewer = 0; 681 fpViewer = 0; >> 682 // Make it impossible for user action code to Draw. >> 683 fpConcreteInstance = 0; 1637 } 684 } 1638 } 685 } >> 686 G4cout << G4endl; 1639 } 687 } 1640 688 1641 void G4VisManager::SetCurrentSceneHandler (G4 689 void G4VisManager::SetCurrentSceneHandler (G4VSceneHandler* pSceneHandler) { 1642 fpSceneHandler = pSceneHandler; 690 fpSceneHandler = pSceneHandler; 1643 if (fVerbosity >= confirmations) { << 691 G4cout << "G4VisManager::SetCurrentSceneHandler: scene handler now \"" 1644 G4cout << "G4VisManager::SetCurrentSceneH << 692 << pSceneHandler -> GetName () << "\""; 1645 << pSceneHandler -> GetName () << "\"" < << 1646 } << 1647 if (fpScene != fpSceneHandler -> GetScene ( << 1648 fpScene = fpSceneHandler -> GetScene (); << 1649 if (fVerbosity >= confirmations) { << 1650 G4cout << " Scene now \"" << 1651 << fpScene -> GetName () << "\"" << G4 << 1652 } << 1653 } << 1654 if (fpGraphicsSystem != pSceneHandler -> Ge 693 if (fpGraphicsSystem != pSceneHandler -> GetGraphicsSystem ()) { 1655 fpGraphicsSystem = pSceneHandler -> GetGr 694 fpGraphicsSystem = pSceneHandler -> GetGraphicsSystem (); 1656 if (fVerbosity >= confirmations) { << 695 G4cout << "\n graphics system now \"" 1657 G4cout << " Graphics system now \"" << 696 << fpGraphicsSystem -> GetName () << "\""; 1658 << fpGraphicsSystem -> GetName () << " << 1659 } << 1660 } 697 } 1661 const G4ViewerList& viewerList = fpSceneHan 698 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList (); 1662 std::size_t nViewers = viewerList.size (); << 699 G4int nViewers = viewerList.entries (); 1663 if (nViewers) { 700 if (nViewers) { 1664 std::size_t iViewer; << 701 G4int iViewer; 1665 for (iViewer = 0; iViewer < nViewers; ++i << 702 for (iViewer = 0; iViewer < nViewers; iViewer++) { 1666 if (fpViewer == viewerList [iViewer]) b 703 if (fpViewer == viewerList [iViewer]) break; 1667 } 704 } 1668 if (iViewer >= nViewers) { 705 if (iViewer >= nViewers) { 1669 fpViewer = viewerList [0]; 706 fpViewer = viewerList [0]; 1670 if (fVerbosity >= confirmations) { << 707 G4cout << "\n Viewer now \"" << fpViewer -> GetName () << "\""; 1671 G4cout << " Viewer now \"" << fpViewer -> << 1672 << G4endl; << 1673 } << 1674 } << 1675 if (!IsValidView ()) { << 1676 if (fVerbosity >= warnings) { << 1677 G4warn << << 1678 "WARNING: Problem setting scene handler - p << 1679 << G4endl; << 1680 } << 1681 } 708 } >> 709 IsValidView (); // Checks. 1682 } 710 } 1683 else { 711 else { 1684 fpViewer = 0; 712 fpViewer = 0; 1685 if (fVerbosity >= warnings) { << 713 // Make it impossible for user action code to Draw. 1686 G4warn << << 714 fpConcreteInstance = 0; 1687 "WARNING: No viewers for this scene handler << 715 G4cout << "\n No viewers for this scene handler - please create one."; 1688 << G4endl; << 1689 } << 1690 } 716 } >> 717 G4cout << G4endl; 1691 } 718 } 1692 719 1693 void G4VisManager::SetCurrentViewer (G4VViewe 720 void G4VisManager::SetCurrentViewer (G4VViewer* pViewer) { 1694 fpViewer = pViewer; 721 fpViewer = pViewer; 1695 if (fpViewer == nullptr) { << 722 G4cout << "G4VisManager::SetCurrentViewer: viewer now " 1696 if (fVerbosity >= confirmations) { << 723 << pViewer -> GetName () 1697 G4cout << "G4VisManager::SetCurrentView << 724 << G4endl; 1698 << G4endl; << 725 fpSceneHandler = fpViewer -> GetScene (); 1699 } << 1700 return; << 1701 } << 1702 if (fVerbosity >= confirmations) { << 1703 G4cout << "G4VisManager::SetCurrentViewer << 1704 << pViewer -> GetName () << 1705 << G4endl; << 1706 } << 1707 fpSceneHandler = fpViewer -> GetSceneHandle << 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 726 fpSceneHandler -> SetCurrentViewer (pViewer); 1719 fpScene = fpSceneHandler -> GetScene (); << 1720 fpGraphicsSystem = fpSceneHandler -> GetGra 727 fpGraphicsSystem = fpSceneHandler -> GetGraphicsSystem (); 1721 if (!IsValidView ()) { << 728 IsValidView (); // Checks. 1722 if (fVerbosity >= warnings) { << 1723 G4warn << << 1724 "WARNING: Problem setting viewer - please r << 1725 << G4endl; << 1726 } << 1727 } << 1728 } 729 } 1729 730 1730 void G4VisManager::PrintAvailableGraphicsSyst << 731 void G4VisManager::PrintCurrentSystems () const { 1731 (Verbosity verbosity, std::ostream& out) cons << 732 if (fpGraphicsSystem && fpSceneHandler && fpViewer) { 1732 { << 733 G4int nSystems = fAvailableGraphicsSystems.entries (); 1733 out << "Registered graphics systems are:\n" << 734 if (nSystems <= 0) { 1734 if (fAvailableGraphicsSystems.size ()) { << 735 G4cout << "No graphics systems available yet." << G4endl; 1735 for (const auto& gs: fAvailableGraphicsSy << 1736 const G4String& name = gs->GetName(); << 1737 const std::vector<G4String>& nicknames << 1738 if (verbosity >= warnings) { << 1739 // Brief output << 1740 out << " " << name << " ("; << 1741 for (std::size_t i = 0; i < nicknames << 1742 if (i != 0) { << 1743 out << ", "; << 1744 } << 1745 out << nicknames[i]; << 1746 } << 1747 out << ')'; << 1748 } else { << 1749 // Full output << 1750 out << *gs; << 1751 } << 1752 out << std::endl; << 1753 } 736 } 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 } << 1769 } << 1770 << 1771 void G4VisManager::PrintAvailableModels (Verb << 1772 { << 1773 { << 1774 //fpTrajDrawModelMgr->Print(G4cout); << 1775 G4cout << "Registered model factories:" < << 1776 const std::vector<G4VModelFactory<G4VTraj << 1777 fpTrajDrawModelMgr->FactoryList(); << 1778 if (factoryList.empty()) G4cout << " Non << 1779 else { 737 else { 1780 std::vector<G4VModelFactory<G4VTrajecto << 738 PrintAvailableGraphicsSystems (); 1781 for (i = factoryList.begin(); i != fact << 1782 (*i)->Print(G4cout); << 1783 } << 1784 } << 1785 G4cout << "\nRegistered models:" << G4end << 1786 const G4VisListManager<G4VTrajectoryModel << 1787 fpTrajDrawModelMgr->ListManager(); << 1788 const std::map<G4String, G4VTrajectoryMod << 1789 listManager->Map(); << 1790 if (modelMap.empty()) G4cout << " None" << 1791 else { << 1792 std::map<G4String, G4VTrajectoryModel*> << 1793 for (i = modelMap.begin(); i != modelMa << 1794 G4cout << " " << i->second->Name(); << 1795 if (i->second == listManager->Current()) G4 << 1796 G4cout << G4endl; << 1797 if (verbosity >= parameters) i->second->Pri << 1798 } << 1799 } << 1800 } << 1801 << 1802 G4cout << G4endl; << 1803 << 1804 { << 1805 //fpTrajFilterMgr->Print(G4cout); << 1806 G4cout << "Registered filter factories:" << 1807 const std::vector<G4VModelFactory<G4VFilt << 1808 factoryList = fpTrajFilterMgr->FactoryL << 1809 if (factoryList.empty()) G4cout << " Non << 1810 else { << 1811 std::vector<G4VModelFactory<G4VFilter<G << 1812 for (i = factoryList.begin(); i != fact << 1813 (*i)->Print(G4cout); << 1814 } << 1815 } << 1816 << 1817 G4cout << "\nRegistered filters:" << G4en << 1818 const std::vector<G4VFilter<G4VTrajectory << 1819 filterList = fpTrajFilterMgr->FilterLis << 1820 if (filterList.empty()) G4cout << " None << 1821 else { << 1822 std::vector<G4VFilter<G4VTrajectory>*>: << 1823 for (i = filterList.begin(); i != filte << 1824 G4cout << " " << (*i)->GetName() << G4endl << 1825 if (verbosity >= parameters) (*i)->PrintAll << 1826 } << 1827 } 739 } 1828 } 740 } >> 741 else PrintInvalidPointers (); 1829 } 742 } 1830 743 1831 void G4VisManager::PrintAvailableUserVisActio << 744 void G4VisManager::PrintCurrentSystem () const { 1832 { << 745 if (fpGraphicsSystem && fpSceneHandler && fpViewer) { 1833 G4cout << << 746 G4cout << "Current graphics system is: " << *fpGraphicsSystem; 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; 747 G4cout << G4endl; 1860 for (std::size_t i = 0; i < fEndOfRunUser << 1861 const G4String& name = fEndOfRunUserVis << 1862 G4cout << " " << name << G4endl; << 1863 } << 1864 } 748 } >> 749 else PrintInvalidPointers (); 1865 } 750 } 1866 751 1867 void G4VisManager::PrintAvailableColours (Ver << 752 void G4VisManager::PrintCurrentScene () const { 1868 G4cout << << 753 if (fpGraphicsSystem && fpSceneHandler && fpViewer) { 1869 "Some /vis commands (optionally) take a str << 754 G4cout << "Current Scene is: " << fpSceneHandler -> GetName (); 1870 "\nThey are also available in your C++ code << 755 G4cout << '\n' << *fpSceneHandler; 1871 "\n G4Colour niceColour; // Default - whi << 756 G4cout << G4endl; 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 } 757 } 1879 G4cout << G4endl; << 758 else PrintInvalidPointers (); 1880 } 759 } 1881 760 1882 void G4VisManager::PrintInvalidPointers () co << 761 void G4VisManager::PrintCurrentView () const { 1883 if (fVerbosity >= errors) { << 762 if (fpGraphicsSystem && fpSceneHandler && fpViewer) { 1884 G4warn << "ERROR: G4VisManager::PrintInva << 763 G4cout << "Current View is: "; 1885 if (!fpGraphicsSystem) { << 764 G4cout << fpGraphicsSystem -> GetName () << '-' 1886 G4warn << "\n null graphics system poin << 765 << fpSceneHandler -> GetSceneId () << '-' >> 766 << fpViewer -> GetViewId () >> 767 << " selected (check: " << fpViewer -> GetName () << ")."; >> 768 G4cout << '\n' << *fpViewer; >> 769 G4cout << "\nCurrent view parameters"; >> 770 if (fVP != fpViewer -> GetViewParameters ()) { >> 771 G4cout << " differ in the following respect:\n"; >> 772 fVP.PrintDifferences (fpViewer -> GetViewParameters ()); 1887 } 773 } 1888 else { 774 else { 1889 G4warn << "\n Graphics system is " << << 775 G4cout << " are same." 1890 << " but:"; << 776 << G4endl; 1891 if (!fpScene) << 1892 G4warn << << 1893 "\n Null scene pointer. Use \"/vis/drawV << 1894 " \"/vis/scene/create\"."; << 1895 if (!fpSceneHandler) << 1896 G4warn << << 1897 "\n Null scene handler pointer. Use \"/v << 1898 " \"/vis/sceneHandler/create\"."; << 1899 if (!fpViewer ) << 1900 G4warn << << 1901 "\n Null viewer pointer. Use \"/vis/view << 1902 } 777 } 1903 G4warn << G4endl; << 1904 } 778 } >> 779 else PrintInvalidPointers (); 1905 } 780 } 1906 781 1907 << 782 void G4VisManager::PrintAllGraphicsSystems () const { 1908 G4ThreadFunReturnType G4VisManager::G4VisSubT << 783 G4cout << "\nThe following graphics systems drivers are supported in the" 1909 { << 784 " GEANT4 distribution:" 1910 #ifdef G4MULTITHREADED << 785 << "\n\n DAWN (socket connection to the Fukui Renderer DAWN) " << G4VisFeaturesOfFukuiRenderer () 1911 G4VisManager* pVisManager = (G4VisManager*) << 786 << "\n\n DAWNFILE (file connection to the Fukui Renderer DAWN ) " << G4VisFeaturesOfDAWNFILE () 1912 G4VSceneHandler* pSceneHandler = pVisManage << 787 << "\n\n OPACS (the Orsay Package) " 1913 if (!pSceneHandler) return 0; << 788 << "\n\n OpenGLIX (direct/immediate drawing on X Windows)\n" 1914 G4Scene* pScene = pSceneHandler->GetScene() << 789 << G4VisFeaturesOfOpenGLIX () 1915 if (!pScene) return 0; << 790 << "\n\n OpenGLSX (display List/stored drawing on X Windows)\n" 1916 G4VViewer* pViewer = pVisManager->GetCurren << 791 << G4VisFeaturesOfOpenGLSX () 1917 if (!pViewer) return 0; << 792 << "\n\n OpenGLIXm (with Motif widgets)\n" 1918 << 793 << G4VisFeaturesOfOpenGLIXm () 1919 G4UImanager::GetUIpointer()->SetUpForSpecia << 794 << "\n\n OpenGLSXm (with Motif widgets)\n" 1920 << 795 << G4VisFeaturesOfOpenGLSXm () 1921 // Set up geometry and navigation for a thr << 796 << "\n\n Open Inventor" 1922 G4GeometryWorkspace::GetPool()->CreateAndUs << 797 << G4VisFeaturesOfOpenInventor () 1923 G4SolidsWorkspace::GetPool()->CreateAndUseW << 798 << "\n\n VRML1 (produces VRML 1 file over network)" 1924 G4Navigator* navigator = G4TransportationMa << 799 << "\n\n VRML1File (produces VRML 1 file locally )" 1925 ->GetNavigatorFo << 800 << "\n\n VRML2 (produces VRML 2 file over network), in preparation" 1926 navigator->SetWorldVolume( << 801 << "\n\n VRML2File (produces VRML 2 file locally ), in preparation" 1927 G4RunManagerFactory::GetMasterRunManagerK << 802 << G4endl; 1928 << 803 } 1929 pViewer->SwitchToVisSubThread(); << 804 1930 << 805 void G4VisManager::PrintInstalledGraphicsSystems () const { 1931 while (true) { << 806 G4cout << "\nThe following graphics systems drivers are installed on your" 1932 << 807 " system:" 1933 G4MUTEXLOCK(&mtVisSubThreadMutex); << 808 #ifdef G4VIS_BUILD_DAWN_DRIVER 1934 std::size_t eventQueueSize = mtVisEventQu << 809 << "\n DAWN (socket connection to the Fukui Renderer DAWN)" 1935 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 810 #endif 1936 // G4cout << "Event queue size (A): " << << 811 #ifdef G4VIS_BUILD_DAWNFILE_DRIVER 1937 << 812 << "\n DAWNFILE (file connection to the Fukui Renderer DAWN)" 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 } << 1982 << 1983 // Inform viewer that we have finished all << 1984 pViewer->DoneWithVisSubThread(); << 1985 pViewer->MovingToMasterThread(); << 1986 #else << 1987 G4ConsumeParameters(p); << 1988 #endif 813 #endif 1989 return nullptr; << 814 #ifdef G4VIS_BUILD_OPACS_DRIVER >> 815 << "\n OPACS (the Orsay Package)" >> 816 #endif >> 817 #ifdef G4VIS_BUILD_OPENGLX_DRIVER >> 818 << "\n OpenGLIX (direct/immediate drawing on X Windows)" >> 819 << "\n OpenGLSX (display List/stored drawing on X Windows)" >> 820 #endif >> 821 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER >> 822 << "\n OpenGLIXm (with Motif widgets)" >> 823 << "\n OpenGLSXm (with Motif widgets)" >> 824 #endif >> 825 #ifdef G4VIS_BUILD_OIX_DRIVER >> 826 << "\n Open Inventor X11" >> 827 #endif >> 828 #ifdef G4VIS_BUILD_OIWIN32_DRIVER >> 829 << "\n Open Inventor Win32" >> 830 #endif >> 831 #ifdef G4VIS_BUILD_VRML_DRIVER >> 832 << "\n VRML1 (produces VRML 1 file over network)" >> 833 << "\n VRML2 (produces VRML 2 file over network), in preparation" >> 834 #endif >> 835 #ifdef G4VIS_BUILD_VRMLFILE_DRIVER >> 836 << "\n VRML1File (produces VRML 1 file locally)" >> 837 << "\n VRML2File (produces VRML 2 file locally), in preparation" >> 838 #endif >> 839 << G4endl; 1990 } 840 } 1991 841 1992 void G4VisManager::BeginOfRun () << 842 void G4VisManager::PrintAvailableGraphicsSystems () const { 1993 { << 843 G4int nSystems = fAvailableGraphicsSystems.entries (); 1994 if (fIgnoreStateChanges) return; << 844 G4cout << "Current available graphics systems are:"; 1995 if (G4Threading::IsWorkerThread()) return; << 845 if (nSystems) { 1996 if (!GetConcreteInstance()) return; << 846 for (int i = 0; i < nSystems; i++) { 1997 << 847 const G4VGraphicsSystem* pSystem = fAvailableGraphicsSystems [i]; 1998 // Check if view is valid << 848 G4cout << "\n " << pSystem -> GetName (); 1999 // Protect IsValidView() with fpSceneHandle << 849 if (pSystem -> GetNickname () != "") { 2000 isValidViewForRun = fpSceneHandler && IsVal << 850 G4cout << " (" << pSystem -> GetNickname () << ")"; 2001 if (!isValidViewForRun) return; << 851 } 2002 << 852 } 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; << 2018 fTransientsDrawnThisRun = false; << 2019 if (fpSceneHandler) fpSceneHandler->SetTran << 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 } 853 } >> 854 else { >> 855 G4cout << "\n NONE!!! None registered - yet! Mmmmm!"; >> 856 } >> 857 G4cout << G4endl; 2049 } 858 } 2050 859 2051 void G4VisManager::BeginOfEvent () << 860 void G4VisManager::PrintInvalidPointers () const { 2052 { << 861 G4cout << "Error in G4VisManager::PrintInvalidPointers:"; 2053 if (fIgnoreStateChanges) return; << 862 if (!fpGraphicsSystem) { 2054 if (!GetConcreteInstance()) return; << 863 G4cout << "\n null graphics system pointer."; 2055 if (!isValidViewForRun) return; << 864 } 2056 if (isFakeRun) return; << 865 else { 2057 << 866 G4cout << "\n graphics system is " << fpGraphicsSystem -> GetName () 2058 // Some instructions that should NOT be in << 867 << " but:"; 2059 // TODO: protect with G4Threading::IsMultit << 868 if (!fpScene) G4cout << "\nNull scene pointer. "; 2060 #ifndef G4MULTITHREADED << 869 if (!fpSceneHandler) G4cout << "\nNull scene handler pointer. "; 2061 // These instructions are in G4VisSubThread << 870 if (!fpViewer ) G4cout << "\nNull viewer pointer. "; 2062 fTransientsDrawnThisEvent = false; << 871 } 2063 if (fpSceneHandler) fpSceneHandler->SetTran << 872 G4cout << G4endl; 2064 #endif << 2065 } << 2066 << 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 () << 2095 { << 2096 if (fIgnoreStateChanges) return; << 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 << 2106 G4RunManager* runManager = G4RunManagerFact << 2107 << 2108 const G4Run* currentRun = runManager->GetCu << 2109 if (!currentRun) return; << 2110 << 2111 // This gets the appropriate event manager << 2112 G4EventManager* eventManager = G4EventManag << 2113 const G4Event* currentEvent = eventManager- << 2114 if (!currentEvent) return; << 2115 << 2116 // Call kernel << 2117 EndOfEventKernel(currentEvent); << 2118 } 873 } 2119 874 2120 void G4VisManager::EventReadyForVis(const G4E << 875 void G4VisManager::RefreshCurrentView () { // Soft clear, then redraw. 2121 // This is invoked by G4SubEvtRunManager. << 876 if (IsValidView ()) { 2122 // The event is passed to EndOfEventKernel. << 877 fpViewer -> ClearView (); // Soft clear, i.e., clears buffer only. 2123 { << 878 Draw (); 2124 if (fIgnoreStateChanges) return; << 879 Show (); 2125 if (!GetConcreteInstance()) return; << 880 } 2126 if (!isValidViewForRun) return; << 2127 if (isFakeRun) return; << 2128 << 2129 G4AutoLock al(&visEndOfEventMutex); << 2130 EndOfEventKernel(event); << 2131 } 881 } 2132 882 2133 void G4VisManager::EndOfEventKernel (const G4 << 883 void G4VisManager::EndOfEvent () { 2134 { << 884 if (fpConcreteInstance && IsValidView ()) { 2135 // Note: we are still subject to the mutex << 885 G4ModelingParameters* pMP = 2136 << 886 fpSceneHandler -> CreateModelingParameters (); 2137 // Discard event if fDrawEventOnlyIfToBeKep << 887 const G4RWTPtrOrderedVector <G4VModel>& EOEModelList = 2138 // user has requested the event to be kept. << 888 fpScene -> GetEndOfEventModelList (); 2139 if (fDrawEventOnlyIfToBeKept) { << 889 fpSceneHandler->ClearTransientStore(); //GB 2140 if (!currentEvent->KeepTheEventFlag()) re << 890 for (int i = 0; i < EOEModelList.entries (); i++) { 2141 } << 891 G4VModel* pModel = EOEModelList [i]; 2142 << 892 pModel -> SetModelingParameters (pMP); 2143 if (G4Threading::IsMultithreadedApplication << 893 pModel -> DescribeYourselfTo (*fpSceneHandler); 2144 << 894 pModel -> SetModelingParameters (0); 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 << 2175 // Wait a while to give event drawing << 2176 std::this_thread::sleep_for(std::chro << 2177 << 2178 } else { << 2179 << 2180 static G4bool warned = false; << 2181 if (!warned) { << 2182 G4warn << << 2183 "WARNING: The number of events in t << 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 } 895 } >> 896 delete pMP; >> 897 } >> 898 } 2202 899 2203 if (!eventQueueFull) { << 900 G4bool G4VisManager::IsValidView () { 2204 901 2205 if (RequiredToBeKeptForVis(currentEvent << 902 if (!fInitialised) Initialise (); 2206 currentEvent->KeepTheEvent(); << 2207 fNKeepTheEventRequests++; // Counts << 2208 } << 2209 903 2210 G4MUTEXLOCK(&mtVisSubThreadMutex); << 904 fpConcreteInstance = 0; >> 905 // Unless we survive a few preliminary tests, users must not use. 2211 906 2212 // Keep while post processing (i.e., dr << 907 if (!fpGraphicsSystem) return false; 2213 // Make sure the event is not deleted b << 908 // Simply return without printing - we do not want printing if the 2214 currentEvent->KeepForPostProcessing(); << 909 // user simply does not want to use graphics, e.g., in batch mode. 2215 fNKeepForPostProcessingRequests++; << 2216 910 2217 // Put event on vis queue << 911 if ((!fpScene) || (!fpSceneHandler) || (!fpViewer)) { 2218 mtVisEventQueue.push_back(currentEvent) << 912 G4cout << "G4VisManager::IsValidView ():" >> 913 "\n Current view is not valid."; >> 914 G4cout << G4endl; >> 915 PrintInvalidPointers (); >> 916 return false; >> 917 } 2219 918 2220 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 919 if (fpScene != fpSceneHandler -> GetScene ()) { >> 920 G4cout << "G4VisManager::IsValidView ():"; >> 921 if (fpSceneHandler -> GetScene ()) { >> 922 G4cout << >> 923 "\n The current scene \"" >> 924 << fpScene -> GetName () >> 925 << "\" is not handled by" >> 926 "\n the current scene handler \"" >> 927 << fpSceneHandler -> GetName () >> 928 << "\"" >> 929 "\n (it currently handles scene \"" >> 930 << fpSceneHandler -> GetScene () -> GetName () >> 931 << "\")." >> 932 "\n Either:" >> 933 "\n (a) attach it to the scene handler with" >> 934 "\n /vis/sceneHandler/attach " >> 935 << fpScene -> GetName () >> 936 << ", or" >> 937 "\n (b) create a new scene handler with " >> 938 "\n /vis/sceneHandler/create <graphics-system>," >> 939 "\n in which case it should pick up the the new scene." >> 940 << G4endl; 2221 } 941 } 2222 << 942 else { 2223 } else { << 943 G4cout << "\n Scene handler \"" 2224 << 944 << fpSceneHandler -> GetName () 2225 // Sequential mode << 945 << "\" has null scene pointer." 2226 << 946 "\n Attach a scene with /vis/sceneHandler/attach [<scene-name>]" 2227 // We are about to draw the event (trajec << 947 << G4endl; 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 } 948 } 2245 << 949 return false; 2246 // Now draw the event... << 2247 fpSceneHandler->DrawEvent(currentEvent); << 2248 ++fNoOfEventsDrawnThisRun; << 2249 << 2250 EndOfEventCleanup(currentEvent); << 2251 } 950 } 2252 } << 2253 951 2254 void G4VisManager::EndOfEventCleanup(const G4 << 952 const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList (); 2255 { << 953 if (viewerList.entries () == 0) { 2256 if (fpScene->GetRefreshAtEndOfEvent()) { << 954 G4cout << "G4VisManager::IsValidView (): the current scene handler\n \"" 2257 << 955 << fpSceneHandler -> GetName () 2258 fpSceneHandler->SetMarkForClearingTransie << 956 << "\" has no viewers. Do /vis/viewer/create." 2259 << 957 << G4endl; 2260 // ShowView guarantees the view is flushe << 958 return false; 2261 // triggers other features such as pickin << 2262 // file-writing viewers to close the file << 2263 fpViewer->ShowView(); << 2264 } 959 } 2265 960 2266 currentEvent->PostProcessingFinished(); << 961 fpConcreteInstance = this; // Unless we find another problem, users can use! 2267 } << 962 G4bool isValid = true; 2268 << 963 if (fpScene -> IsEmpty ()) { 2269 G4bool G4VisManager::RequiredToBeKeptForVis ( << 964 fpScene -> AddWorldIfEmpty (); // Add world by default if possible. 2270 // i.e., kept by the run manager at least to << 965 if (fpScene -> IsEmpty ()) { // If still empty... 2271 { << 966 G4cout << "G4VisManager::IsViewValid ():"; 2272 G4bool requiredToBeKept = false; << 967 G4cout << 2273 << 968 "\n Attempt at some drawing operation when scene is empty." 2274 G4RunManager* runManager = G4RunManagerFact << 969 "\n Maybe the geometry has not yet been defined." 2275 G4int nEventsToBeProcessed = runManager->Ge << 970 " Try /run/initialize." 2276 << 971 << G4endl; 2277 if (fpScene->GetRefreshAtEndOfEvent()) { / << 972 isValid = false; 2278 << 973 fpConcreteInstance = 0; // Users must not use! 2279 // Keep last event only << 2280 if (eventID == nEventsToBeProcessed - 1) << 2281 requiredToBeKept = true; << 2282 } 974 } >> 975 else { >> 976 G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/camera/reset"); >> 977 G4cout << >> 978 "G4VisManager: the scene was empty, \"world\" has been added" >> 979 "\n and the view parameters have been reset."; >> 980 G4cout << G4endl; >> 981 } >> 982 } >> 983 return isValid; >> 984 } 2283 985 2284 } else { // Accumulating events << 986 // "No functionality" graphics systems to trap accidental attempt to 2285 << 987 // use unbuilt systems. 2286 G4int maxNumberOfKeptEvents = fpScene->Ge << 2287 << 2288 if (maxNumberOfKeptEvents >= 0) { // Eve << 2289 << 2290 if (fNKeepTheEventRequests < maxNumberO << 2291 << 2292 // Not yet reached the limit << 2293 requiredToBeKept = true; << 2294 << 2295 } else { << 2296 988 2297 // We have already reached the limit << 989 #ifndef G4VIS_BUILD_DAWN_DRIVER 2298 fEventKeepingSuspended = true; << 2299 static G4bool warned = false; << 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 } << 2316 990 2317 } else { // Indefinite event keeping (ma << 991 class G4FukuiRenderer: public G4VGraphicsSystem { >> 992 public: >> 993 G4FukuiRenderer (); >> 994 }; >> 995 G4FukuiRenderer::G4FukuiRenderer (): >> 996 G4VGraphicsSystem ("FukuiRenderer", >> 997 "DAWN", >> 998 G4VGraphicsSystem::noFunctionality) {} 2318 999 2319 requiredToBeKept = true; << 1000 #endif 2320 1001 2321 } << 1002 #ifndef G4VIS_BUILD_DAWNFILE_DRIVER 2322 } << 2323 1003 2324 return requiredToBeKept; << 1004 class G4DAWNFILE: public G4VGraphicsSystem { 2325 } << 1005 public: >> 1006 G4DAWNFILE (); >> 1007 }; >> 1008 G4DAWNFILE::G4DAWNFILE (): >> 1009 G4VGraphicsSystem ("FukuiRendererFile", >> 1010 "DAWNFILE", >> 1011 G4VGraphicsSystem::noFunctionality) {} 2326 1012 2327 void G4VisManager::EndOfRun () << 1013 #endif 2328 { << 2329 if (fIgnoreStateChanges) return; << 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 << 2344 // G4AutoLock al(&visEndOfRunMutex); ??? << 2345 if (G4Threading::IsMultithreadedApplication << 2346 // Reset flag so that sub-thread exits wh << 2347 G4MUTEXLOCK(&mtVisSubThreadMutex); << 2348 mtRunInProgress = false; << 2349 G4MUTEXUNLOCK(&mtVisSubThreadMutex); << 2350 // Wait for sub-thread to finish. << 2351 G4THREADJOIN(*mtVisSubThread); << 2352 delete mtVisSubThread; << 2353 fpViewer->SwitchToMasterThread(); << 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 } << 2367 } << 2368 } << 2369 1014 2370 G4int nKeptEvents = currentRun->GetNumberOf << 1015 #ifndef G4VIS_BUILD_OPACS_DRIVER 2371 if (fVerbosity >= warnings && nKeptEvents > << 2372 G4warn << nKeptEvents; << 2373 if (nKeptEvents == 1) G4warn << " event h << 2374 else G4warn << " events have"; << 2375 G4warn << " been kept for refreshing and/ << 2376 if (nKeptEvents != fNKeepTheEventRequests << 2377 if (fNKeepTheEventRequests == 0) { << 2378 G4warn << "No keep requests were"; << 2379 } else if (fNKeepTheEventRequests == 1) << 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 } << 2418 } << 2419 1016 2420 // // if (!fpSceneHandler->GetMarkForClear << 1017 class G4Wo: public G4VGraphicsSystem { 2421 // // is here. It prevents ShowView at en << 1018 public: 2422 // // for sequential mode, but MT mode see << 1019 G4Wo (); 2423 // // figured out why). ???? JA ???? << 1020 }; 2424 // if (!fpSceneHandler->GetMarkForClearing << 1021 G4Wo::G4Wo (): 2425 if (fpScene->GetRefreshAtEndOfRun()) { << 1022 G4VGraphicsSystem ("Wo", 2426 fpSceneHandler->DrawEndOfRunModels(); << 1023 G4VGraphicsSystem::noFunctionality) {} 2427 // An extra refresh for auto-refresh view << 1024 2428 // ???? I DON'T WHY THIS IS NECESSARY ??? << 1025 class G4Xo: public G4VGraphicsSystem { 2429 if (fpViewer->GetViewParameters().IsAutoR << 1026 public: 2430 fpViewer->RefreshView(); << 1027 G4Xo (); 2431 } << 1028 }; 2432 // ShowView guarantees the view is flushe << 1029 G4Xo::G4Xo (): 2433 // triggers other features such picking ( << 1030 G4VGraphicsSystem ("Xo", 2434 // file-writing viewers to close the file << 1031 G4VGraphicsSystem::noFunctionality) {} 2435 fpViewer->ShowView(); << 2436 fpSceneHandler->SetMarkForClearingTransie << 2437 } else { << 2438 if (fpGraphicsSystem->GetFunctionality() << 2439 G4VGraphicsSystem::fileWriter) { << 2440 if (fVerbosity >= warnings) { << 2441 G4warn << "\"/vis/viewer/update\" to << 2442 } << 2443 } << 2444 } << 2445 //} << 2446 fEventRefreshing = false; << 2447 } << 2448 1032 2449 void G4VisManager::ClearTransientStoreIfMarke << 1033 #endif 2450 // Assumes valid view. << 2451 if (fpSceneHandler->GetMarkForClearingTrans << 2452 fpSceneHandler->SetMarkForClearingTransie << 2453 fpSceneHandler->ClearTransientStore(); << 2454 } << 2455 // Record if transients drawn. These local << 2456 // *after* ClearTransientStore. In the cod << 2457 // triggered by ClearTransientStore, use th << 2458 // event refreshing is not done too early. << 2459 fTransientsDrawnThisEvent = fpSceneHandler- << 2460 fTransientsDrawnThisRun = fpSceneHandler->G << 2461 } << 2462 1034 2463 void G4VisManager::ResetTransientsDrawnFlags( << 1035 #ifndef G4VIS_BUILD_OPENGLX_DRIVER 2464 { << 2465 fTransientsDrawnThisRun = false; << 2466 fTransientsDrawnThisEvent = false; << 2467 G4SceneHandlerListConstIterator i; << 2468 for (i = fAvailableSceneHandlers.begin(); << 2469 i != fAvailableSceneHandlers.end(); ++ << 2470 (*i)->SetTransientsDrawnThisEvent(false); << 2471 (*i)->SetTransientsDrawnThisRun(false); << 2472 } << 2473 } << 2474 1036 2475 G4String G4VisManager::ViewerShortName (const << 1037 class G4OpenGLImmediateX: public G4VGraphicsSystem { 2476 const G4String& viewerShortName = viewerNam << 1038 public: 2477 return G4StrUtil::strip_copy(viewerShortNam << 1039 G4OpenGLImmediateX (); 2478 } << 1040 }; 2479 << 1041 G4OpenGLImmediateX::G4OpenGLImmediateX (): 2480 G4VViewer* G4VisManager::GetViewer (const G4S << 1042 G4VGraphicsSystem ("OpenGLImmediateX", 2481 G4String viewerShortName = ViewerShortName << 1043 "OGLIX", 2482 std::size_t nHandlers = fAvailableSceneHand << 1044 G4VGraphicsSystem::noFunctionality) {} 2483 std::size_t iHandler, iViewer; << 1045 2484 G4VViewer* viewer = 0; << 1046 class G4OpenGLStoredX: public G4VGraphicsSystem { 2485 G4bool found = false; << 1047 public: 2486 for (iHandler = 0; iHandler < nHandlers; iH << 1048 G4OpenGLStoredX (); 2487 G4VSceneHandler* sceneHandler = fAvailabl << 1049 }; 2488 const G4ViewerList& viewerList = sceneHan << 1050 G4OpenGLStoredX::G4OpenGLStoredX (): 2489 for (iViewer = 0; iViewer < viewerList.si << 1051 G4VGraphicsSystem ("OpenGLStoredX", 2490 viewer = viewerList [iViewer]; << 1052 "OGLSX", 2491 if (viewerShortName == viewer -> GetSho << 1053 G4VGraphicsSystem::noFunctionality) {} 2492 found = true; << 2493 break; << 2494 } << 2495 } << 2496 if (found) break; << 2497 } << 2498 if (found) return viewer; << 2499 else return 0; << 2500 } << 2501 1054 2502 std::vector<G4String> G4VisManager::Verbosity << 1055 #endif 2503 1056 2504 G4String G4VisManager::VerbosityString(Verbos << 1057 #ifndef G4VIS_BUILD_OPENGLXM_DRIVER 2505 G4String rs; << 2506 switch (verbosity) { << 2507 case quiet: rs = "quiet (0)"; break << 2508 case startup: rs = "startup (1)"; bre << 2509 case errors: rs = "errors (2)"; brea << 2510 case warnings: rs = "warnings (3)"; br << 2511 case confirmations: rs = "confirmations (4) << 2512 case parameters: rs = "parameters (5)"; << 2513 case all: rs = "all (6)"; break; << 2514 } << 2515 return rs; << 2516 } << 2517 1058 2518 void G4VisManager::PrintAvailableVerbosity(st << 1059 class G4OpenGLImmediateXm: public G4VGraphicsSystem { 2519 { << 1060 public: 2520 os << "Available verbosity options:"; << 1061 G4OpenGLImmediateXm (); 2521 for (std::size_t i = 0; i < VerbosityGuidan << 1062 }; 2522 os << '\n' << VerbosityGuidanceStrings[i] << 1063 G4OpenGLImmediateXm::G4OpenGLImmediateXm (): 2523 } << 1064 G4VGraphicsSystem ("OpenGLImmediateXm", 2524 os << "\nCurrent verbosity: " << G4VisManag << 1065 "OGLIXm", 2525 os << std::endl; << 1066 G4VGraphicsSystem::noFunctionality) {} 2526 } << 1067 2527 << 1068 class G4OpenGLStoredXm: public G4VGraphicsSystem { 2528 G4VisManager::Verbosity << 1069 public: 2529 G4VisManager::GetVerbosityValue(const G4Strin << 1070 G4OpenGLStoredXm (); 2530 G4String ss = G4StrUtil::to_lower_copy(verb << 1071 }; 2531 Verbosity verbosity; << 1072 G4OpenGLStoredXm::G4OpenGLStoredXm (): 2532 if (ss[0] == 'q') verbosity = quiet; << 1073 G4VGraphicsSystem ("OpenGLStoredXm", 2533 else if (ss[0] == 's') verbosity = startup; << 1074 "OGLSXm", 2534 else if (ss[0] == 'e') verbosity = errors; << 1075 G4VGraphicsSystem::noFunctionality) {} 2535 else if (ss[0] == 'w') verbosity = warnings << 2536 else if (ss[0] == 'c') verbosity = confirma << 2537 else if (ss[0] == 'p') verbosity = paramete << 2538 else if (ss[0] == 'a') verbosity = all; << 2539 else { << 2540 // Could be an integer << 2541 G4int intVerbosity; << 2542 std::istringstream is(ss); << 2543 is >> intVerbosity; << 2544 if (!is) { << 2545 G4warn << "ERROR: G4VisManager::GetVerb << 2546 << verbosityString << "\"\n"; << 2547 PrintAvailableVerbosity(G4warn); << 2548 // Return existing verbosity << 2549 return fVerbosity; << 2550 } << 2551 else { << 2552 verbosity = GetVerbosityValue(intVerbos << 2553 } << 2554 } << 2555 return verbosity; << 2556 } << 2557 1076 2558 G4VisManager::Verbosity G4VisManager::GetVerb << 1077 #endif 2559 Verbosity verbosity; << 2560 if (intVerbosity < quiet) verbosity = << 2561 else if (intVerbosity > all) verbosity = << 2562 else verbosity = << 2563 return verbosity; << 2564 } << 2565 1078 2566 G4VisManager::Verbosity G4VisManager::GetVerb << 1079 #ifndef G4VIS_BUILD_OIX_DRIVER 2567 return fVerbosity; << 2568 } << 2569 1080 2570 void G4VisManager::SetVerboseLevel (G4int int << 1081 class G4OpenInventorX: public G4VGraphicsSystem { 2571 fVerbosity = GetVerbosityValue(intVerbosity << 1082 public: 2572 } << 1083 G4OpenInventorX (); >> 1084 }; >> 1085 G4OpenInventorX::G4OpenInventorX (): >> 1086 G4VGraphicsSystem ("OpenInventorX", >> 1087 "OIX", >> 1088 G4VGraphicsSystem::noFunctionality) {} 2573 1089 2574 void G4VisManager::SetVerboseLevel (const G4S << 1090 #endif 2575 fVerbosity = GetVerbosityValue(verbosityStr << 2576 } << 2577 1091 2578 G4bool G4VisManager::IsValidView () { << 1092 #ifndef G4VIS_BUILD_OIWIN32_DRIVER 2579 1093 2580 if (!fInitialised) Initialise (); << 1094 class G4OpenInventorWin32: public G4VGraphicsSystem { >> 1095 public: >> 1096 G4OpenInventorWin32 (); >> 1097 }; >> 1098 G4OpenInventorWin32::G4OpenInventorWin32 (): >> 1099 G4VGraphicsSystem ("OpenInventorWin32", >> 1100 "OIWIN32", >> 1101 G4VGraphicsSystem::noFunctionality) {} 2581 1102 2582 static G4bool noGSPrinting = true; << 1103 #endif 2583 if (!fpGraphicsSystem) { << 2584 // Limit printing - we do not want printi << 2585 // not want to use graphics, e.g., in bat << 2586 if (noGSPrinting) { << 2587 noGSPrinting = false; << 2588 if (fVerbosity >= warnings) { << 2589 G4warn << << 2590 "WARNING: G4VisManager::IsValidView(): Atte << 2591 "\n has been instantiated. Use \"/vis/ope << 2592 "\n Alternatively, to avoid this message, << 2593 "\n manager (G4VisExecutive) and ensure dr << 2594 "\n G4VVisManager::GetConcreteInstance() i << 2595 << G4endl; << 2596 } << 2597 } << 2598 return false; << 2599 } << 2600 1104 2601 if ((!fpScene) || (!fpSceneHandler) || (!fp << 1105 #ifndef G4VIS_BUILD_VRML_DRIVER 2602 if (fVerbosity >= errors) { << 2603 G4warn << << 2604 "ERROR: G4VisManager::IsValidView(): Curren << 2605 << G4endl; << 2606 PrintInvalidPointers (); << 2607 } << 2608 return false; << 2609 } << 2610 1106 2611 if (fpScene != fpSceneHandler -> GetScene ( << 1107 class G4VRML1: public G4VGraphicsSystem { 2612 if (fVerbosity >= errors) { << 1108 public: 2613 G4warn << "ERROR: G4VisManager::IsValid << 1109 G4VRML1 (); 2614 if (fpSceneHandler -> GetScene ()) { << 1110 }; 2615 G4warn << << 1111 G4VRML1::G4VRML1 (): 2616 "\n The current scene \"" << 1112 G4VGraphicsSystem ("VRML1.0", 2617 << fpScene -> GetName () << 1113 "VRML1", 2618 << "\" is not handled by" << 1114 G4VGraphicsSystem::noFunctionality) {} 2619 "\n the current scene handler \"" << 1115 2620 << fpSceneHandler -> GetName () << 1116 class G4VRML2: public G4VGraphicsSystem { 2621 << "\"" << 1117 public: 2622 "\n (it currently handles scene \"" << 1118 G4VRML2 (); 2623 << fpSceneHandler -> GetScene () -> << 1119 }; 2624 << "\")." << 1120 G4VRML2::G4VRML2 (): 2625 "\n Either:" << 1121 G4VGraphicsSystem ("VRML2.0", 2626 "\n (a) attach it to the scene handler w << 1122 "VRML2", 2627 "\n /vis/sceneHandler/attach " << 1123 G4VGraphicsSystem::noFunctionality) {} 2628 << fpScene -> GetName () << 2629 << ", or" << 2630 "\n (b) create a new scene handler with << 2631 "\n /vis/sceneHandler/create <graphi << 2632 "\n in which case it should pick up << 2633 << G4endl; << 2634 } << 2635 else { << 2636 G4warn << "\n Scene handler \"" << 2637 << fpSceneHandler -> GetName () << 2638 << "\" has null scene pointer." << 2639 "\n Attach a scene with /vis/sceneHandle << 2640 << G4endl; << 2641 } << 2642 } << 2643 return false; << 2644 } << 2645 1124 2646 const G4ViewerList& viewerList = fpSceneHan << 1125 #endif 2647 if (viewerList.size () == 0) { << 2648 if (fVerbosity >= errors) { << 2649 G4warn << << 2650 "ERROR: G4VisManager::IsValidView (): the c << 2651 << fpSceneHandler -> GetName () << 2652 << "\" has no viewers. Do /vis/viewer << 2653 << G4endl; << 2654 } << 2655 return false; << 2656 } << 2657 1126 2658 G4bool isValid = true; << 1127 #ifndef G4VIS_BUILD_VRMLFILE_DRIVER 2659 if (fpScene -> IsEmpty ()) { // Add world << 2660 G4bool warn(fVerbosity >= warnings); << 2661 G4bool successful = fpScene -> AddWorldIf << 2662 if (!successful || fpScene -> IsEmpty ()) << 2663 if (fVerbosity >= errors) { << 2664 G4warn << "ERROR: G4VisManager::IsValidView << 2665 G4warn << << 2666 "\n Attempt at some drawing operation wh << 2667 "\n Maybe the geometry has not yet been << 2668 " Try /run/initialize." << 2669 "\n Or use \"/vis/scene/add/extent << 2670 << G4endl; << 2671 } << 2672 isValid = false; << 2673 } << 2674 else { << 2675 G4UImanager::GetUIpointer()->ApplyComma << 2676 if (fVerbosity >= warnings) { << 2677 G4warn << << 2678 "WARNING: G4VisManager: the scene was emp << 2679 "\n added and the scene handlers notifie << 2680 G4warn << G4endl; << 2681 } << 2682 } << 2683 } << 2684 return isValid; << 2685 } << 2686 1128 2687 void << 1129 class G4VRML1File: public G4VGraphicsSystem { 2688 G4VisManager::RegisterModelFactories() << 1130 public: 2689 { << 1131 G4VRML1File (); 2690 if (fVerbosity >= warnings) { << 1132 }; 2691 G4warn<<"G4VisManager: No model factories << 1133 G4VRML1File::G4VRML1File (): 2692 G4warn<<"G4VisManager::RegisterModelFacto << 1134 G4VGraphicsSystem ("VRML1.0File", 2693 G4warn<<"class. See G4VisExecutive for an << 1135 "VRML1File", 2694 } << 1136 G4VGraphicsSystem::noFunctionality) {} 2695 } << 1137 >> 1138 class G4VRML2File: public G4VGraphicsSystem { >> 1139 public: >> 1140 G4VRML2File (); >> 1141 }; >> 1142 G4VRML2File::G4VRML2File (): >> 1143 G4VGraphicsSystem ("VRML2.0File", >> 1144 "VRML2File", >> 1145 G4VGraphicsSystem::noFunctionality) {} 2696 1146 2697 void G4VisManager::SetUpForAThread() << 2698 { << 2699 // TODO: protect with G4Threading::IsMultit << 2700 #ifdef G4MULTITHREADED << 2701 new G4VisStateDependent(this); << 2702 #endif 1147 #endif 2703 } << 2704 << 2705 void G4VisManager::IgnoreStateChanges(G4bool << 2706 { << 2707 fIgnoreStateChanges = val; << 2708 } << 2709 1148