Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // >> 27 // $Id: G4VisCommandsScene.cc,v 1.54 2006/06/29 21:29:42 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-01-patch-01 $ 27 29 28 // /vis/scene commands - John Allison 9th Aug 30 // /vis/scene commands - John Allison 9th August 1998 29 31 30 #include "G4VisCommandsScene.hh" 32 #include "G4VisCommandsScene.hh" 31 33 32 #include "G4VisManager.hh" 34 #include "G4VisManager.hh" 33 #include "G4TransportationManager.hh" 35 #include "G4TransportationManager.hh" 34 #include "G4RunManager.hh" << 35 #include "G4RunManagerFactory.hh" << 36 #include "G4Run.hh" << 37 #include "G4PhysicalVolumeModel.hh" 36 #include "G4PhysicalVolumeModel.hh" 38 #include "G4ApplicationState.hh" 37 #include "G4ApplicationState.hh" 39 #include "G4UImanager.hh" 38 #include "G4UImanager.hh" 40 #include "G4UIcommand.hh" 39 #include "G4UIcommand.hh" 41 #include "G4UIcmdWithAString.hh" 40 #include "G4UIcmdWithAString.hh" 42 #include "G4UIcmdWithoutParameter.hh" << 43 #include "G4ios.hh" 41 #include "G4ios.hh" 44 #include <sstream> 42 #include <sstream> 45 43 46 #define G4warn G4cout << 47 << 48 G4VVisCommandScene::G4VVisCommandScene () {} 44 G4VVisCommandScene::G4VVisCommandScene () {} 49 45 50 G4VVisCommandScene::~G4VVisCommandScene () {} 46 G4VVisCommandScene::~G4VVisCommandScene () {} 51 47 52 G4String G4VVisCommandScene::CurrentSceneName 48 G4String G4VVisCommandScene::CurrentSceneName () { 53 const G4Scene* pScene = fpVisManager -> GetC 49 const G4Scene* pScene = fpVisManager -> GetCurrentScene (); 54 G4String currentSceneName = "none"; << 50 G4String currentSceneName; 55 if (pScene) currentSceneName = pScene -> Get 51 if (pScene) currentSceneName = pScene -> GetName (); 56 return currentSceneName; 52 return currentSceneName; 57 } 53 } 58 54 59 ////////////// /vis/scene/activateModel ////// << 60 << 61 G4VisCommandSceneActivateModel::G4VisCommandSc << 62 G4bool omitable; << 63 fpCommand = new G4UIcommand ("/vis/scene/act << 64 fpCommand -> SetGuidance << 65 ("Activate or de-activate model."); << 66 fpCommand -> SetGuidance << 67 ("Attempts to match search string to name << 68 fpCommand -> SetGuidance << 69 ("Use \"/vis/scene/list\" to see model nam << 70 fpCommand -> SetGuidance << 71 ("If name == \"all\" (default), all models << 72 G4UIparameter* parameter; << 73 parameter = new G4UIparameter ("search-strin << 74 parameter -> SetDefaultValue ("all"); << 75 fpCommand -> SetParameter (parameter); << 76 parameter = new G4UIparameter ("activate", ' << 77 parameter -> SetDefaultValue (true); << 78 fpCommand -> SetParameter (parameter); << 79 } << 80 << 81 G4VisCommandSceneActivateModel::~G4VisCommandS << 82 delete fpCommand; << 83 } << 84 << 85 G4String G4VisCommandSceneActivateModel::GetCu << 86 return ""; << 87 } << 88 << 89 void G4VisCommandSceneActivateModel::SetNewVal << 90 G4String newValue) { << 91 << 92 G4VisManager::Verbosity verbosity = fpVisMan << 93 << 94 G4String searchString, activateString; << 95 std::istringstream is (newValue); << 96 // Need to handle the possibility that the s << 97 // contains embedded blanks within quotation << 98 // (This arises if the search string is auto << 99 // global description, as in G4UIQt, clickin << 100 auto lastQuotationMark = newValue.find_last_ << 101 if (lastQuotationMark != std::string::npos) << 102 auto firstQuotationMark = newValue.find_fi << 103 if (lastQuotationMark != firstQuotationMar << 104 // Note: there must not be more quotatio << 105 searchString = newValue.substr << 106 (firstQuotationMark + 1, lastQuotationMa << 107 activateString = newValue.substr(lastQuo << 108 // Perhaps we ought to check number of q << 109 G4int nQuotes = 0; << 110 for (auto c : newValue) { << 111 if (c == '"') nQuotes++; << 112 } << 113 if (nQuotes > 2) { << 114 G4ExceptionDescription ed; << 115 ed << "More than 2 quotation marks in << 116 G4Exception("G4VisCommandSceneActivate << 117 } << 118 } << 119 } << 120 else { << 121 // None or one quotation marks - just inpu << 122 is >> searchString >> activateString; << 123 } << 124 G4bool activate = G4UIcommand::ConvertToBool << 125 << 126 G4Scene* pScene = fpVisManager->GetCurrentSc << 127 if (!pScene) { << 128 if (verbosity >= G4VisManager::errors) { << 129 G4warn << "ERROR: No current scene. Ple << 130 } << 131 return; << 132 } << 133 << 134 G4VSceneHandler* pSceneHandler = fpVisManage << 135 if (!pSceneHandler) { << 136 if (verbosity >= G4VisManager::errors) { << 137 G4warn << "ERROR: No current sceneHandle << 138 } << 139 return; << 140 } << 141 << 142 if (searchString == "all" && !activate) { << 143 if (verbosity >= G4VisManager::warnings) { << 144 G4warn << << 145 "WARNING: You are not allowed to de-activate << 146 "\n Command ignored." << 147 << G4endl; << 148 } << 149 return; << 150 } << 151 << 152 G4bool any = false; << 153 << 154 std::vector<G4Scene::Model>& runDurationMode << 155 pScene->SetRunDurationModelList(); << 156 for (size_t i = 0; i < runDurationModelList. << 157 const G4String& modelName = runDurationMod << 158 if (searchString == "all" || modelName.fin << 159 any = true; << 160 runDurationModelList[i].fActive = activa << 161 if (verbosity >= G4VisManager::warnings) << 162 G4warn << "Model \"" << modelName; << 163 if (activate) G4warn << "\" activated."; << 164 else G4warn << "\" de-activated."; << 165 G4warn << G4endl; << 166 } << 167 } << 168 } << 169 << 170 std::vector<G4Scene::Model>& endOfEventModel << 171 pScene->SetEndOfEventModelList(); << 172 for (size_t i = 0; i < endOfEventModelList.s << 173 const G4String& modelName = endOfEventMode << 174 if (searchString == "all" || modelName.fin << 175 any = true; << 176 endOfEventModelList[i].fActive = activat << 177 if (verbosity >= G4VisManager::warnings) << 178 G4warn << "Model \"" << modelName; << 179 if (activate) G4warn << "\" activated."; << 180 else G4warn << "\" de-activated."; << 181 G4warn << G4endl; << 182 } << 183 } << 184 } << 185 << 186 std::vector<G4Scene::Model>& endOfRunModelLi << 187 pScene->SetEndOfRunModelList(); << 188 for (size_t i = 0; i < endOfRunModelList.siz << 189 const G4String& modelName = endOfRunModelL << 190 if (searchString == "all" || modelName.fin << 191 any = true; << 192 endOfRunModelList[i].fActive = activate; << 193 if (verbosity >= G4VisManager::warnings) << 194 G4warn << "Model \"" << modelName; << 195 if (activate) G4warn << "\" activated."; << 196 else G4warn << "\" de-activated."; << 197 G4warn << G4endl; << 198 } << 199 } << 200 } << 201 << 202 if (!any) { << 203 if (verbosity >= G4VisManager::warnings) { << 204 G4warn << "WARNING: No match found." << << 205 } << 206 return; << 207 } << 208 << 209 CheckSceneAndNotifyHandlers (pScene); << 210 } << 211 << 212 ////////////// /vis/scene/create ///////////// 55 ////////////// /vis/scene/create /////////////////////////////////////// 213 56 214 G4VisCommandSceneCreate::G4VisCommandSceneCrea 57 G4VisCommandSceneCreate::G4VisCommandSceneCreate (): fId (0) { 215 G4bool omitable; 58 G4bool omitable; 216 fpCommand = new G4UIcmdWithAString ("/vis/sc 59 fpCommand = new G4UIcmdWithAString ("/vis/scene/create", this); 217 fpCommand -> SetGuidance 60 fpCommand -> SetGuidance 218 ("Creates an empty scene."); 61 ("Creates an empty scene."); 219 fpCommand -> SetGuidance 62 fpCommand -> SetGuidance 220 ("Invents a name if not supplied. This sc 63 ("Invents a name if not supplied. This scene becomes current."); 221 fpCommand -> SetParameterName ("scene-name", 64 fpCommand -> SetParameterName ("scene-name", omitable = true); 222 } 65 } 223 66 224 G4VisCommandSceneCreate::~G4VisCommandSceneCre 67 G4VisCommandSceneCreate::~G4VisCommandSceneCreate () { 225 delete fpCommand; 68 delete fpCommand; 226 } 69 } 227 70 228 G4String G4VisCommandSceneCreate::NextName () 71 G4String G4VisCommandSceneCreate::NextName () { 229 std::ostringstream oss; 72 std::ostringstream oss; 230 oss << "scene-" << fId; 73 oss << "scene-" << fId; 231 return oss.str(); 74 return oss.str(); 232 } 75 } 233 76 234 G4String G4VisCommandSceneCreate::GetCurrentVa 77 G4String G4VisCommandSceneCreate::GetCurrentValue (G4UIcommand*) { 235 return ""; 78 return ""; 236 } 79 } 237 80 238 void G4VisCommandSceneCreate::SetNewValue (G4U 81 void G4VisCommandSceneCreate::SetNewValue (G4UIcommand*, G4String newValue) { 239 82 240 G4VisManager::Verbosity verbosity = fpVisMan 83 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 241 84 242 G4String& newName = newValue; 85 G4String& newName = newValue; 243 G4String nextName = NextName (); 86 G4String nextName = NextName (); 244 87 245 if (newName == "") { 88 if (newName == "") { 246 newName = nextName; 89 newName = nextName; 247 } 90 } 248 if (newName == nextName) fId++; 91 if (newName == nextName) fId++; 249 92 250 G4SceneList& sceneList = fpVisManager -> Set 93 G4SceneList& sceneList = fpVisManager -> SetSceneList (); 251 std::size_t iScene, nScenes = sceneList.size << 94 G4int iScene, nScenes = sceneList.size (); 252 for (iScene = 0; iScene < nScenes; ++iScene) << 95 for (iScene = 0; iScene < nScenes; iScene++) { 253 if (sceneList [iScene] -> GetName () == ne 96 if (sceneList [iScene] -> GetName () == newName) break; 254 } 97 } 255 if (iScene < nScenes) { 98 if (iScene < nScenes) { 256 if (verbosity >= G4VisManager::warnings) { 99 if (verbosity >= G4VisManager::warnings) { 257 G4warn << "WARNING: Scene \"" << newName << 100 G4cout << "WARNING: Scene \"" << newName << "\" already exists." 258 << "\n New scene not created." << 259 << G4endl; 101 << G4endl; 260 } 102 } 261 } else { 103 } else { 262 104 263 // Add empty scene data object to list... 105 // Add empty scene data object to list... 264 G4Scene* pScene = new G4Scene (newName); 106 G4Scene* pScene = new G4Scene (newName); 265 sceneList.push_back (pScene); 107 sceneList.push_back (pScene); 266 fpVisManager -> SetCurrentScene (pScene); 108 fpVisManager -> SetCurrentScene (pScene); 267 109 268 if (verbosity >= G4VisManager::confirmatio 110 if (verbosity >= G4VisManager::confirmations) { 269 G4cout << "New empty scene \"" << newNam 111 G4cout << "New empty scene \"" << newName << "\" created." << G4endl; 270 } 112 } 271 } 113 } 272 } 114 } 273 115 274 ////////////// /vis/scene/endOfEventAction /// 116 ////////////// /vis/scene/endOfEventAction //////////////////////////// 275 117 276 G4VisCommandSceneEndOfEventAction::G4VisComman 118 G4VisCommandSceneEndOfEventAction::G4VisCommandSceneEndOfEventAction () { 277 G4bool omitable; 119 G4bool omitable; 278 fpCommand = new G4UIcommand ("/vis/scene/end << 120 fpCommand = new G4UIcmdWithAString ("/vis/scene/endOfEventAction", this); 279 fpCommand -> SetGuidance 121 fpCommand -> SetGuidance 280 ("Accumulate or refresh the viewer for eac 122 ("Accumulate or refresh the viewer for each new event."); 281 fpCommand -> SetGuidance 123 fpCommand -> SetGuidance 282 ("\"accumulate\": viewer accumulates hits, 124 ("\"accumulate\": viewer accumulates hits, etc., event by event, or"); 283 fpCommand -> SetGuidance 125 fpCommand -> SetGuidance 284 ("\"refresh\": viewer shows them at end of 126 ("\"refresh\": viewer shows them at end of event or, for direct-screen" 285 "\n viewers, refreshes the screen just b 127 "\n viewers, refreshes the screen just before drawing the next event."); 286 G4UIparameter* parameter; << 128 fpCommand -> SetGuidance ("The detector remains or is redrawn."); 287 parameter = new G4UIparameter ("action", 's' << 129 fpCommand -> SetParameterName ("action", omitable = true); 288 parameter -> SetParameterCandidates ("accumu << 130 fpCommand -> SetCandidates ("accumulate refresh"); 289 parameter -> SetDefaultValue ("refresh"); << 131 fpCommand -> SetDefaultValue ("refresh"); 290 fpCommand -> SetParameter (parameter); << 291 parameter = new G4UIparameter ("maxNumber", << 292 parameter -> SetDefaultValue (100); << 293 parameter -> SetGuidance << 294 ("Maximum number of events kept. Unlimited << 295 fpCommand -> SetParameter (parameter); << 296 } 132 } 297 133 298 G4VisCommandSceneEndOfEventAction::~G4VisComma 134 G4VisCommandSceneEndOfEventAction::~G4VisCommandSceneEndOfEventAction () { 299 delete fpCommand; 135 delete fpCommand; 300 } 136 } 301 137 302 G4String G4VisCommandSceneEndOfEventAction::Ge 138 G4String G4VisCommandSceneEndOfEventAction::GetCurrentValue(G4UIcommand*) { 303 return ""; 139 return ""; 304 } 140 } 305 141 306 void G4VisCommandSceneEndOfEventAction::SetNew 142 void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*, 307 G4String newValue) { 143 G4String newValue) { 308 144 309 G4VisManager::Verbosity verbosity = fpVisMan 145 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 310 146 311 G4String action; 147 G4String action; 312 G4int maxNumberOfKeptEvents; << 313 std::istringstream is (newValue); 148 std::istringstream is (newValue); 314 is >> action >> maxNumberOfKeptEvents; << 149 is >> action; 315 150 316 G4Scene* pScene = fpVisManager->GetCurrentSc 151 G4Scene* pScene = fpVisManager->GetCurrentScene(); 317 if (!pScene) { 152 if (!pScene) { 318 if (verbosity >= G4VisManager::errors) { 153 if (verbosity >= G4VisManager::errors) { 319 G4warn << "ERROR: No current scene. Ple << 154 G4cout << "ERROR: No current scene. Please create one." << G4endl; 320 } 155 } 321 return; 156 return; 322 } 157 } 323 158 324 G4VSceneHandler* pSceneHandler = fpVisManage 159 G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler(); 325 if (!pSceneHandler) { 160 if (!pSceneHandler) { 326 if (verbosity >= G4VisManager::errors) { 161 if (verbosity >= G4VisManager::errors) { 327 G4warn << "ERROR: No current sceneHandle << 162 G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl; 328 } 163 } 329 return; 164 return; 330 } 165 } 331 166 332 if (action == "accumulate") { 167 if (action == "accumulate") { 333 pScene->SetRefreshAtEndOfEvent(false); 168 pScene->SetRefreshAtEndOfEvent(false); 334 pScene->SetMaxNumberOfKeptEvents(maxNumber << 335 } 169 } 336 else if (action == "refresh") { 170 else if (action == "refresh") { 337 if (!pScene->GetRefreshAtEndOfRun()) { << 171 pScene->SetRefreshAtEndOfEvent(true); 338 if (verbosity >= G4VisManager::errors) { << 172 pSceneHandler->SetMarkForClearingTransientStore(true); 339 G4warn << << 340 "ERROR: Cannot refresh events unless runs << 341 "\n Use \"/vis/scene/endOfRun refresh\"." << 342 << G4endl; << 343 } << 344 } else { << 345 pScene->SetRefreshAtEndOfEvent(true); << 346 pScene->SetMaxNumberOfKeptEvents(maxNumb << 347 pSceneHandler->SetMarkForClearingTransie << 348 } << 349 } 173 } 350 else { 174 else { 351 if (verbosity >= G4VisManager::errors) { 175 if (verbosity >= G4VisManager::errors) { 352 G4warn << << 176 G4cout << 353 "ERROR: unrecognised parameter \"" << action 177 "ERROR: unrecognised parameter \"" << action << "\"." 354 << G4endl; 178 << G4endl; 355 } 179 } 356 return; 180 return; 357 } 181 } 358 182 359 // Change of transients behaviour, so... << 360 fpVisManager->ResetTransientsDrawnFlags(); << 361 << 362 // Are there any events currently kept... << 363 size_t nCurrentlyKept = 0; << 364 G4RunManager* runManager = G4RunManagerFacto << 365 if(runManager) << 366 { << 367 const G4Run* currentRun = runManager->GetC << 368 if(currentRun) << 369 { << 370 const std::vector<const G4Event*>* event << 371 if(events) << 372 nCurrentlyKept = events->size(); << 373 } << 374 } << 375 << 376 if (verbosity >= G4VisManager::confirmations 183 if (verbosity >= G4VisManager::confirmations) { 377 G4cout << "End of event action set to "; << 184 G4cout << "End of event action set to \""; 378 if (pScene->GetRefreshAtEndOfEvent()) G4co << 185 if (pScene->GetRefreshAtEndOfEvent()) G4cout << "refresh"; 379 else { << 186 else G4cout << "accumulate"; 380 G4cout << "\"accumulate\"." << 187 G4cout << "\"" << G4endl; 381 "\n Maximum number of events to be kept: " << 382 << maxNumberOfKeptEvents << 383 << " (unlimited if negative)." << 384 "\n This may be changed with, e.g., " << 385 "\"/vis/scene/endOfEventAction accumulate 10 << 386 } << 387 G4cout << G4endl; << 388 } << 389 << 390 if (!pScene->GetRefreshAtEndOfEvent() && << 391 maxNumberOfKeptEvents != 0 && << 392 verbosity >= G4VisManager::warnings) { << 393 G4warn << "WARNING: "; << 394 if (nCurrentlyKept) { << 395 G4warn << << 396 "\n There are currently " << nCurrentlyKept << 397 << " events kept for refreshing and/or << 398 } else { << 399 G4warn << "The vis manager will keep "; << 400 if (maxNumberOfKeptEvents < 0) G4warn << << 401 else G4warn << "up to " << maxNumberOfKe << 402 G4warn << " events."; << 403 if (maxNumberOfKeptEvents > 1 || maxNumb << 404 G4warn << << 405 "\n This may use a lot of memory." << 406 "\n It may be changed with, e.g., " << 407 "\"/vis/scene/endOfEventAction accumulate << 408 } << 409 G4warn << G4endl; << 410 } 188 } 411 } 189 } 412 190 413 ////////////// /vis/scene/endOfRunAction ///// 191 ////////////// /vis/scene/endOfRunAction //////////////////////////// 414 192 415 G4VisCommandSceneEndOfRunAction::G4VisCommandS 193 G4VisCommandSceneEndOfRunAction::G4VisCommandSceneEndOfRunAction () { 416 G4bool omitable; 194 G4bool omitable; 417 fpCommand = new G4UIcmdWithAString ("/vis/sc 195 fpCommand = new G4UIcmdWithAString ("/vis/scene/endOfRunAction", this); 418 fpCommand -> SetGuidance 196 fpCommand -> SetGuidance 419 ("Accumulate or refresh the viewer for eac 197 ("Accumulate or refresh the viewer for each new run."); 420 fpCommand -> SetGuidance 198 fpCommand -> SetGuidance 421 ("\"accumulate\": viewer accumulates hits, 199 ("\"accumulate\": viewer accumulates hits, etc., run by run, or"); 422 fpCommand -> SetGuidance 200 fpCommand -> SetGuidance 423 ("\"refresh\": viewer shows them at end of 201 ("\"refresh\": viewer shows them at end of run or, for direct-screen" 424 "\n viewers, refreshes the screen just b 202 "\n viewers, refreshes the screen just before drawing the first" 425 "\n event of the next run."); 203 "\n event of the next run."); 426 fpCommand -> SetGuidance ("The detector rema 204 fpCommand -> SetGuidance ("The detector remains or is redrawn."); 427 fpCommand -> SetParameterName ("action", omi 205 fpCommand -> SetParameterName ("action", omitable = true); 428 fpCommand -> SetCandidates ("accumulate refr 206 fpCommand -> SetCandidates ("accumulate refresh"); 429 fpCommand -> SetDefaultValue ("refresh"); 207 fpCommand -> SetDefaultValue ("refresh"); 430 } 208 } 431 209 432 G4VisCommandSceneEndOfRunAction::~G4VisCommand 210 G4VisCommandSceneEndOfRunAction::~G4VisCommandSceneEndOfRunAction () { 433 delete fpCommand; 211 delete fpCommand; 434 } 212 } 435 213 436 G4String G4VisCommandSceneEndOfRunAction::GetC 214 G4String G4VisCommandSceneEndOfRunAction::GetCurrentValue(G4UIcommand*) { 437 return ""; 215 return ""; 438 } 216 } 439 217 440 void G4VisCommandSceneEndOfRunAction::SetNewVa 218 void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*, 441 G4String newValue) { 219 G4String newValue) { 442 220 443 G4VisManager::Verbosity verbosity = fpVisMan 221 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 444 222 445 G4String action; 223 G4String action; 446 std::istringstream is (newValue); 224 std::istringstream is (newValue); 447 is >> action; 225 is >> action; 448 226 449 G4Scene* pScene = fpVisManager->GetCurrentSc 227 G4Scene* pScene = fpVisManager->GetCurrentScene(); 450 if (!pScene) { 228 if (!pScene) { 451 if (verbosity >= G4VisManager::errors) { 229 if (verbosity >= G4VisManager::errors) { 452 G4warn << "ERROR: No current scene. Ple << 230 G4cout << "ERROR: No current scene. Please create one." << G4endl; 453 } 231 } 454 return; 232 return; 455 } 233 } 456 234 457 G4VSceneHandler* pSceneHandler = fpVisManage 235 G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler(); 458 if (!pSceneHandler) { 236 if (!pSceneHandler) { 459 if (verbosity >= G4VisManager::errors) { 237 if (verbosity >= G4VisManager::errors) { 460 G4warn << "ERROR: No current sceneHandle << 238 G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl; 461 } 239 } 462 return; 240 return; 463 } 241 } 464 242 465 if (action == "accumulate") { 243 if (action == "accumulate") { 466 if (pScene->GetRefreshAtEndOfEvent()) { 244 if (pScene->GetRefreshAtEndOfEvent()) { 467 if (verbosity >= G4VisManager::errors) { 245 if (verbosity >= G4VisManager::errors) { 468 G4warn << << 246 G4cout << 469 "ERROR: Cannot accumulate runs unless even 247 "ERROR: Cannot accumulate runs unless events accumulate too." 470 "\n Use \"/vis/scene/endOfEventAction acc 248 "\n Use \"/vis/scene/endOfEventAction accumulate\"." 471 << G4endl; 249 << G4endl; 472 } 250 } 473 } 251 } 474 else { 252 else { 475 pScene->SetRefreshAtEndOfRun(false); 253 pScene->SetRefreshAtEndOfRun(false); 476 } 254 } 477 } 255 } 478 else if (action == "refresh") { 256 else if (action == "refresh") { 479 pScene->SetRefreshAtEndOfRun(true); 257 pScene->SetRefreshAtEndOfRun(true); 480 pSceneHandler->SetMarkForClearingTransient 258 pSceneHandler->SetMarkForClearingTransientStore(true); 481 } 259 } 482 else { 260 else { 483 if (verbosity >= G4VisManager::errors) { 261 if (verbosity >= G4VisManager::errors) { 484 G4warn << << 262 G4cout << 485 "ERROR: unrecognised parameter \"" << action 263 "ERROR: unrecognised parameter \"" << action << "\"." 486 << G4endl; 264 << G4endl; 487 } 265 } 488 return; 266 return; 489 } 267 } 490 268 491 // Change of transients behaviour, so... << 492 fpVisManager->ResetTransientsDrawnFlags(); << 493 << 494 if (verbosity >= G4VisManager::confirmations 269 if (verbosity >= G4VisManager::confirmations) { 495 G4cout << "End of run action set to \""; 270 G4cout << "End of run action set to \""; 496 if (pScene->GetRefreshAtEndOfRun()) G4cout 271 if (pScene->GetRefreshAtEndOfRun()) G4cout << "refresh"; 497 else G4cout << "accumulate"; 272 else G4cout << "accumulate"; 498 G4cout << "\"" << G4endl; 273 G4cout << "\"" << G4endl; 499 } 274 } 500 } 275 } 501 276 502 ////////////// /vis/scene/list /////////////// 277 ////////////// /vis/scene/list /////////////////////////////////////// 503 278 504 G4VisCommandSceneList::G4VisCommandSceneList ( 279 G4VisCommandSceneList::G4VisCommandSceneList () { 505 G4bool omitable; 280 G4bool omitable; 506 fpCommand = new G4UIcommand ("/vis/scene/lis 281 fpCommand = new G4UIcommand ("/vis/scene/list", this); 507 fpCommand -> SetGuidance ("Lists scene(s).") 282 fpCommand -> SetGuidance ("Lists scene(s)."); 508 fpCommand -> SetGuidance 283 fpCommand -> SetGuidance 509 ("\"help /vis/verbose\" for definition of 284 ("\"help /vis/verbose\" for definition of verbosity."); 510 G4UIparameter* parameter; 285 G4UIparameter* parameter; 511 parameter = new G4UIparameter ("scene-name", 286 parameter = new G4UIparameter ("scene-name", 's', omitable = true); 512 parameter -> SetDefaultValue ("all"); 287 parameter -> SetDefaultValue ("all"); 513 fpCommand -> SetParameter (parameter); 288 fpCommand -> SetParameter (parameter); 514 parameter = new G4UIparameter ("verbosity", 289 parameter = new G4UIparameter ("verbosity", 's', omitable = true); 515 parameter -> SetDefaultValue ("warnings"); 290 parameter -> SetDefaultValue ("warnings"); 516 fpCommand -> SetParameter (parameter); 291 fpCommand -> SetParameter (parameter); 517 } 292 } 518 293 519 G4VisCommandSceneList::~G4VisCommandSceneList 294 G4VisCommandSceneList::~G4VisCommandSceneList () { 520 delete fpCommand; 295 delete fpCommand; 521 } 296 } 522 297 523 G4String G4VisCommandSceneList::GetCurrentValu 298 G4String G4VisCommandSceneList::GetCurrentValue (G4UIcommand*) { 524 return ""; 299 return ""; 525 } 300 } 526 301 527 void G4VisCommandSceneList::SetNewValue (G4UIc 302 void G4VisCommandSceneList::SetNewValue (G4UIcommand*, G4String newValue) { 528 G4String name, verbosityString; 303 G4String name, verbosityString; 529 std::istringstream is (newValue); 304 std::istringstream is (newValue); 530 is >> name >> verbosityString; 305 is >> name >> verbosityString; 531 G4VisManager::Verbosity verbosity = 306 G4VisManager::Verbosity verbosity = 532 fpVisManager->GetVerbosityValue(verbosityS 307 fpVisManager->GetVerbosityValue(verbosityString); 533 const G4Scene* currentScene = fpVisManager - 308 const G4Scene* currentScene = fpVisManager -> GetCurrentScene (); 534 G4String currentName; 309 G4String currentName; 535 if (currentScene) currentName = currentScene 310 if (currentScene) currentName = currentScene->GetName(); 536 311 537 G4SceneList& sceneList = fpVisManager -> Set 312 G4SceneList& sceneList = fpVisManager -> SetSceneList (); 538 std::size_t iScene, nScenes = sceneList.size << 313 G4int iScene, nScenes = sceneList.size (); 539 G4bool found = false; 314 G4bool found = false; 540 for (iScene = 0; iScene < nScenes; ++iScene) << 315 for (iScene = 0; iScene < nScenes; iScene++) { 541 G4Scene* pScene = sceneList [iScene]; 316 G4Scene* pScene = sceneList [iScene]; 542 const G4String& iName = pScene -> GetName 317 const G4String& iName = pScene -> GetName (); 543 if (name != "all") { 318 if (name != "all") { 544 if (name != iName) continue; 319 if (name != iName) continue; 545 } 320 } 546 found = true; 321 found = true; 547 if (iName == currentName) { 322 if (iName == currentName) { 548 G4cout << " (current)"; 323 G4cout << " (current)"; 549 } 324 } 550 else { 325 else { 551 G4cout << " "; 326 G4cout << " "; 552 } 327 } 553 G4cout << " scene \"" << iName << "\""; 328 G4cout << " scene \"" << iName << "\""; 554 if (verbosity >= G4VisManager::warnings) { << 329 if (verbosity >= G4VisManager::confirmations) { 555 std::size_t i; << 330 G4int i; 556 G4cout << "\n Run-duration models:"; 331 G4cout << "\n Run-duration models:"; 557 std::size_t nRunModels = pScene -> GetRu << 332 G4int nRunModels = pScene -> GetRunDurationModelList ().size (); 558 if (nRunModels == 0) { 333 if (nRunModels == 0) { 559 G4cout << " none."; 334 G4cout << " none."; 560 } 335 } 561 for (i = 0; i < nRunModels; ++i) { << 336 for (i = 0; i < nRunModels; i++) { 562 if (pScene -> GetRunDurationModelList()[i].f << 337 G4VModel* pModel = pScene -> GetRunDurationModelList () [i]; 563 G4cout << "\n Active: "; << 338 G4cout << "\n " << pModel -> GetGlobalDescription (); 564 else G4cout << "\n Inactive: "; << 565 G4VModel* pModel = pScene -> GetRunDurationM << 566 G4cout << pModel -> GetGlobalDescription (); << 567 } 339 } 568 G4cout << "\n End-of-event models:"; 340 G4cout << "\n End-of-event models:"; 569 std::size_t nEOEModels = pScene -> GetEn << 341 G4int nEOEModels = pScene -> GetEndOfEventModelList ().size (); 570 if (nEOEModels == 0) { 342 if (nEOEModels == 0) { 571 G4cout << " none."; 343 G4cout << " none."; 572 } 344 } 573 for (i = 0; i < nEOEModels; ++i) { << 345 for (i = 0; i < nEOEModels; i++) { 574 if (pScene -> GetEndOfEventModelList()[i].fA << 346 G4VModel* pModel = pScene -> GetEndOfEventModelList () [i]; 575 G4cout << "\n Active: "; << 347 G4cout << "\n " << pModel -> GetGlobalDescription (); 576 else G4cout << "\n Inactive: "; << 577 G4VModel* pModel = pScene -> GetEndOfEventMo << 578 G4cout << pModel -> GetGlobalDescription (); << 579 } << 580 G4cout << "\n End-of-run models:"; << 581 std::size_t nEORModels = pScene -> GetEn << 582 if (nEORModels == 0) { << 583 G4cout << " none."; << 584 } << 585 for (i = 0; i < nEORModels; ++i) { << 586 if (pScene -> GetEndOfRunModelList()[i].fAct << 587 G4cout << "\n Active: "; << 588 else G4cout << "\n Inactive: "; << 589 G4VModel* pModel = pScene -> GetEndOfRunMode << 590 G4cout << pModel -> GetGlobalDescription (); << 591 } 348 } 592 } 349 } 593 if (verbosity >= G4VisManager::parameters) 350 if (verbosity >= G4VisManager::parameters) { 594 G4cout << "\n " << *sceneList [iScene]; 351 G4cout << "\n " << *sceneList [iScene]; 595 } 352 } 596 G4cout << G4endl; 353 G4cout << G4endl; 597 } 354 } 598 if (!found) { 355 if (!found) { 599 G4warn << "No scenes found"; << 356 G4cout << "No scenes found"; 600 if (name != "all") { 357 if (name != "all") { 601 G4warn << " of name \"" << name << "\""; << 358 G4cout << " of name \"" << name << "\""; 602 } 359 } 603 G4warn << "." << G4endl; << 360 G4cout << "." << G4endl; 604 } 361 } 605 } 362 } 606 363 607 ////////////// /vis/scene/notifyHandlers ///// 364 ////////////// /vis/scene/notifyHandlers ///////////////////////// 608 365 609 G4VisCommandSceneNotifyHandlers::G4VisCommandS 366 G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers () { 610 G4bool omitable; 367 G4bool omitable; 611 fpCommand = new G4UIcommand ("/vis/scene/not 368 fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this); 612 fpCommand -> SetGuidance 369 fpCommand -> SetGuidance 613 ("Notifies scene handlers and forces re-re 370 ("Notifies scene handlers and forces re-rendering."); 614 fpCommand -> SetGuidance 371 fpCommand -> SetGuidance 615 ("Notifies the handler(s) of the specified 372 ("Notifies the handler(s) of the specified scene and forces a" 616 "\nreconstruction of any graphical databa 373 "\nreconstruction of any graphical databases." 617 "\nClears and refreshes all viewers of cu 374 "\nClears and refreshes all viewers of current scene." 618 "\n The default action \"refresh\" does 375 "\n The default action \"refresh\" does not issue \"update\" (see" 619 "\n /vis/viewer/update)." 376 "\n /vis/viewer/update)." 620 "\nIf \"flush\" is specified, it issues a 377 "\nIf \"flush\" is specified, it issues an \"update\" as well as" 621 "\n \"refresh\" - \"update\" and initiat 378 "\n \"refresh\" - \"update\" and initiates post-processing" 622 "\n for graphics systems which need it." 379 "\n for graphics systems which need it."); 623 fpCommand -> SetGuidance 380 fpCommand -> SetGuidance 624 ("The default for <scene-name> is the curr 381 ("The default for <scene-name> is the current scene name."); 625 fpCommand -> SetGuidance 382 fpCommand -> SetGuidance 626 ("This command does not change current sce 383 ("This command does not change current scene, scene handler or viewer."); 627 G4UIparameter* parameter; 384 G4UIparameter* parameter; 628 parameter = new G4UIparameter ("scene-name", 385 parameter = new G4UIparameter ("scene-name", 's', 629 omitable = true); 386 omitable = true); 630 parameter -> SetCurrentAsDefault(true); 387 parameter -> SetCurrentAsDefault(true); 631 fpCommand -> SetParameter (parameter); 388 fpCommand -> SetParameter (parameter); 632 parameter = new G4UIparameter ("refresh-flus 389 parameter = new G4UIparameter ("refresh-flush", 's', 633 omitable = true); 390 omitable = true); 634 parameter -> SetDefaultValue("refresh"); 391 parameter -> SetDefaultValue("refresh"); 635 parameter -> SetParameterCandidates("r refre 392 parameter -> SetParameterCandidates("r refresh f flush"); 636 fpCommand -> SetParameter (parameter); 393 fpCommand -> SetParameter (parameter); 637 } 394 } 638 395 639 G4VisCommandSceneNotifyHandlers::~G4VisCommand 396 G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers () { 640 delete fpCommand; 397 delete fpCommand; 641 } 398 } 642 399 643 G4String G4VisCommandSceneNotifyHandlers::GetC 400 G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue(G4UIcommand*) { 644 return CurrentSceneName (); 401 return CurrentSceneName (); 645 } 402 } 646 403 647 void G4VisCommandSceneNotifyHandlers::SetNewVa 404 void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*, 648 G4String newValue) { 405 G4String newValue) { 649 406 650 G4VisManager::Verbosity verbosity = fpVisMan 407 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 651 408 652 G4String sceneName, refresh_flush; 409 G4String sceneName, refresh_flush; 653 std::istringstream is (newValue); 410 std::istringstream is (newValue); 654 is >> sceneName >> refresh_flush; 411 is >> sceneName >> refresh_flush; 655 G4bool flush = false; 412 G4bool flush = false; 656 if (refresh_flush[0] == 'f') flush = true; << 413 if (refresh_flush(0) == 'f') flush = true; 657 414 658 const G4SceneList& sceneList = fpVisManager 415 const G4SceneList& sceneList = fpVisManager -> GetSceneList (); 659 G4SceneHandlerList& sceneHandlerList = 416 G4SceneHandlerList& sceneHandlerList = 660 fpVisManager -> SetAvailableSceneHandlers 417 fpVisManager -> SetAvailableSceneHandlers (); 661 418 662 // Check scene name. 419 // Check scene name. 663 const std::size_t nScenes = sceneList.size ( << 420 const G4int nScenes = sceneList.size (); 664 std::size_t iScene; << 421 G4int iScene; 665 for (iScene = 0; iScene < nScenes; ++iScene) << 422 for (iScene = 0; iScene < nScenes; iScene++) { 666 G4Scene* scene = sceneList [iScene]; 423 G4Scene* scene = sceneList [iScene]; 667 if (sceneName == scene -> GetName ()) brea 424 if (sceneName == scene -> GetName ()) break; 668 } 425 } 669 if (iScene >= nScenes ) { 426 if (iScene >= nScenes ) { 670 if (verbosity >= G4VisManager::warnings) { 427 if (verbosity >= G4VisManager::warnings) { 671 G4warn << "WARNING: Scene \"" << sceneNa << 428 G4cout << "WARNING: Scene \"" << sceneName << "\" not found." 672 "\n /vis/scene/list to see scenes." 429 "\n /vis/scene/list to see scenes." 673 << G4endl; 430 << G4endl; 674 } 431 } 675 return; 432 return; 676 } 433 } 677 434 678 // Store current context... 435 // Store current context... 679 G4VSceneHandler* pCurrentSceneHandler = 436 G4VSceneHandler* pCurrentSceneHandler = 680 fpVisManager -> GetCurrentSceneHandler(); 437 fpVisManager -> GetCurrentSceneHandler(); 681 if (!pCurrentSceneHandler) { << 682 if (verbosity >= G4VisManager::warnings) { << 683 G4warn << "WARNING: No current scene han << 684 << G4endl; << 685 } << 686 return; << 687 } << 688 G4VViewer* pCurrentViewer = fpVisManager -> 438 G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer(); 689 if (!pCurrentViewer) { << 690 if (verbosity >= G4VisManager::warnings) { << 691 G4warn << "WARNING: No current viewer." << 692 << G4endl; << 693 } << 694 return; << 695 } << 696 G4Scene* pCurrentScene = fpVisManager -> Get 439 G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene(); 697 if (!pCurrentScene) { << 698 if (verbosity >= G4VisManager::warnings) { << 699 G4warn << "WARNING: No current scene." << 700 << G4endl; << 701 } << 702 return; << 703 } << 704 << 705 G4VisManager::Verbosity currentVerbosity = f 440 G4VisManager::Verbosity currentVerbosity = fpVisManager -> GetVerbosity(); 706 441 707 // Suppress messages during this process (on 442 // Suppress messages during this process (only print errors)... 708 //fpVisManager -> SetVerboseLevel(G4VisManag 443 //fpVisManager -> SetVerboseLevel(G4VisManager::errors); 709 444 710 // For each scene handler, if it contains th 445 // For each scene handler, if it contains the scene, clear and 711 // rebuild the graphical database, then for 446 // rebuild the graphical database, then for each viewer set (make 712 // current), clear, (re)draw, and show. 447 // current), clear, (re)draw, and show. 713 const std::size_t nSceneHandlers = sceneHand << 448 const G4int nSceneHandlers = sceneHandlerList.size (); 714 for (std::size_t iSH = 0; iSH < nSceneHandle << 449 for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) { 715 G4VSceneHandler* aSceneHandler = sceneHand 450 G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH]; 716 G4Scene* aScene = aSceneHandler -> GetScen 451 G4Scene* aScene = aSceneHandler -> GetScene (); 717 if (aScene) { 452 if (aScene) { 718 const G4String& aSceneName = aScene -> G 453 const G4String& aSceneName = aScene -> GetName (); 719 if (sceneName == aSceneName) { 454 if (sceneName == aSceneName) { 720 aScene->CalculateExtent(); // Check and rec << 455 // Clear store and force a rebuild of graphical database... >> 456 //aSceneHandler -> ClearStore (); // Not nec?? Done below >> 457 //with NeedKernelVisit and DrawView. JA. 721 G4ViewerList& viewerList = aSceneHandler -> 458 G4ViewerList& viewerList = aSceneHandler -> SetViewerList (); 722 const std::size_t nViewers = viewerList.size << 459 const G4int nViewers = viewerList.size (); 723 for (std::size_t iV = 0; iV < nViewers; ++iV << 460 for (G4int iV = 0; iV < nViewers; iV++) { 724 G4VViewer* aViewer = viewerList [iV]; 461 G4VViewer* aViewer = viewerList [iV]; 725 // Force rebuild of graphical database, if << 462 aSceneHandler -> SetCurrentViewer (aViewer); >> 463 // Ensure consistency of vis manager... >> 464 fpVisManager -> SetCurrentViewer(aViewer); >> 465 fpVisManager -> SetCurrentSceneHandler(aSceneHandler); >> 466 fpVisManager -> SetCurrentScene(aScene); >> 467 // Re-draw, forcing rebuild of graphics database, if any... 726 aViewer -> NeedKernelVisit(); 468 aViewer -> NeedKernelVisit(); 727 if (aViewer->GetViewParameters().IsAutoRef << 469 aViewer -> SetView (); 728 aSceneHandler -> SetCurrentViewer (aView << 470 aViewer -> ClearView (); 729 // Ensure consistency of vis manager... << 471 aViewer -> DrawView (); 730 fpVisManager -> SetCurrentViewer(aViewer << 472 if (flush) aViewer -> ShowView (); 731 fpVisManager -> SetCurrentSceneHandler(a << 473 if (verbosity >= G4VisManager::confirmations) { 732 fpVisManager -> SetCurrentScene(aScene); << 474 G4cout << "Viewer \"" << aViewer -> GetName () 733 aViewer -> SetView (); << 475 << "\" of scene handler \"" << aSceneHandler -> GetName () 734 aViewer -> ClearView (); << 476 << "\"\n "; 735 aViewer -> DrawView (); << 477 if (flush) G4cout << "flushed"; 736 if (flush) aViewer -> ShowView (); << 478 else G4cout << "refreshed"; 737 if (verbosity >= G4VisManager::confirmat << 479 G4cout << " at request of scene \"" << sceneName 738 G4cout << "Viewer \"" << aViewer -> Ge << 480 << "\"." << G4endl; 739 << "\" of scene handler \"" << aScene << 740 << "\"\n "; << 741 if (flush) G4cout << "flushed"; << 742 else G4cout << "refreshed"; << 743 G4cout << " at request of scene \"" << << 744 << "\"." << G4endl; << 745 } << 746 } else { << 747 if (verbosity >= G4VisManager::confirmat << 748 G4cout << "NOTE: The scene, \"" << 749 << sceneName << 750 << "\", of viewer \"" << 751 << aViewer -> GetName () << 752 << "\"\n of scene handler \"" << 753 << aSceneHandler -> GetName () << 754 << "\" has changed. To see effect," << 755 << "\n \"/vis/viewer/select " << 756 << aViewer -> GetShortName () << 757 << "\" and \"/vis/viewer/rebuild\"." << 758 << G4endl; << 759 } << 760 } 481 } 761 } 482 } 762 } 483 } 763 } 484 } 764 else { 485 else { 765 if (verbosity >= G4VisManager::warnings) 486 if (verbosity >= G4VisManager::warnings) { 766 G4warn << "WARNING: G4VisCommandSceneNotifyH << 487 G4cout << "WARNING: G4VisCommandSceneNotifyHandlers: scene handler \"" 767 << aSceneHandler->GetName() 488 << aSceneHandler->GetName() 768 << "\" has a null scene." 489 << "\" has a null scene." 769 << G4endl; 490 << G4endl; 770 } 491 } 771 } 492 } 772 } 493 } 773 494 774 // Reclaim original context - but set viewer 495 // Reclaim original context - but set viewer first, then scene 775 // handler, because the latter might have be 496 // handler, because the latter might have been created very recently 776 // and, not yet having a viewer, the current 497 // and, not yet having a viewer, the current viewer will, 777 // temporarily, refer to another scene handl 498 // temporarily, refer to another scene handler. SetCurrentViewer 778 // actually resets the scene handler, which 499 // actually resets the scene handler, which is what we don't want, 779 // so we set it again on the next line... 500 // so we set it again on the next line... 780 fpVisManager -> SetCurrentViewer(pCurrentVie 501 fpVisManager -> SetCurrentViewer(pCurrentViewer); 781 fpVisManager -> SetCurrentSceneHandler(pCurr 502 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler); 782 fpVisManager -> SetCurrentScene(pCurrentScen 503 fpVisManager -> SetCurrentScene(pCurrentScene); 783 fpVisManager -> SetVerboseLevel(currentVerbo 504 fpVisManager -> SetVerboseLevel(currentVerbosity); 784 // Take care of special case of scene handle 505 // Take care of special case of scene handler with no viewer yet. 785 if (pCurrentSceneHandler) { 506 if (pCurrentSceneHandler) { 786 G4ViewerList& viewerList = pCurrentSceneHa 507 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList (); 787 const std::size_t nViewers = viewerList.si << 508 const G4int nViewers = viewerList.size (); 788 if (nViewers) { 509 if (nViewers) { 789 pCurrentSceneHandler -> SetCurrentViewer 510 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer); 790 // JA: I don't think we need this. SetVi << 511 if (pCurrentViewer && pCurrentSceneHandler->GetScene()) { 791 // if (pCurrentViewer && pCurrentSceneHa << 512 pCurrentViewer -> SetView (); 792 // pCurrentViewer -> SetView (); << 793 // } << 794 } << 795 } << 796 } << 797 << 798 ////////////// /vis/scene/removeModel //////// << 799 << 800 G4VisCommandSceneRemoveModel::G4VisCommandScen << 801 G4bool omitable; << 802 fpCommand = new G4UIcommand ("/vis/scene/rem << 803 fpCommand -> SetGuidance("Remove model."); << 804 fpCommand -> SetGuidance << 805 ("Attempts to match search string to name of << 806 fpCommand -> SetGuidance << 807 ("Use \"/vis/scene/list\" to see model names << 808 G4UIparameter* parameter; << 809 parameter = new G4UIparameter ("search-strin << 810 fpCommand -> SetParameter (parameter); << 811 } << 812 << 813 G4VisCommandSceneRemoveModel::~G4VisCommandSce << 814 delete fpCommand; << 815 } << 816 << 817 G4String G4VisCommandSceneRemoveModel::GetCurr << 818 return ""; << 819 } << 820 << 821 void G4VisCommandSceneRemoveModel::SetNewValue << 822 G4String newValue) { << 823 << 824 G4VisManager::Verbosity verbosity = fpVisMan << 825 << 826 G4String searchString; << 827 std::istringstream is (newValue); << 828 is >> searchString; << 829 << 830 G4Scene* pScene = fpVisManager->GetCurrentSc << 831 if (!pScene) { << 832 if (verbosity >= G4VisManager::errors) { << 833 G4warn << "ERROR: No current scene. Ple << 834 } << 835 return; << 836 } << 837 << 838 G4VSceneHandler* pSceneHandler = fpVisManage << 839 if (!pSceneHandler) { << 840 if (verbosity >= G4VisManager::errors) { << 841 G4warn << "ERROR: No current sceneHandle << 842 } << 843 return; << 844 } << 845 << 846 G4bool any = false; << 847 << 848 std::vector<G4Scene::Model>& runDurationMode << 849 pScene->SetRunDurationModelList(); << 850 for (size_t i = 0; i < runDurationModelList. << 851 const G4String& modelName = << 852 runDurationModelList[i].fpModel->GetGlobal << 853 if (modelName.find(searchString) != std::s << 854 runDurationModelList.erase(runDurationMo << 855 any = true; << 856 if (verbosity >= G4VisManager::warnings) << 857 G4warn << "Model \"" << modelName << "\" rem << 858 } << 859 break; // Allow only one model at a tim << 860 } << 861 } << 862 << 863 std::vector<G4Scene::Model>& endOfEventModel << 864 pScene->SetEndOfEventModelList(); << 865 for (size_t i = 0; i < endOfEventModelList.s << 866 const G4String& modelName = << 867 endOfEventModelList[i].fpModel->GetGlobalD << 868 if (modelName.find(searchString) != std::s << 869 endOfEventModelList.erase(endOfEventMode << 870 any = true; << 871 if (verbosity >= G4VisManager::warnings) << 872 G4warn << "Model \"" << modelName << "\" rem << 873 } << 874 break; // Allow only one model at a tim << 875 } << 876 } << 877 << 878 std::vector<G4Scene::Model>& endOfRunModelLi << 879 pScene->SetEndOfRunModelList(); << 880 for (size_t i = 0; i < endOfRunModelList.siz << 881 const G4String& modelName = << 882 endOfRunModelList[i].fpModel->GetGlobalDes << 883 if (modelName.find(searchString) != std::s << 884 endOfRunModelList.erase(endOfRunModelLis << 885 any = true; << 886 if (verbosity >= G4VisManager::warnings) << 887 G4warn << "Model \"" << modelName << "\" rem << 888 } 513 } 889 break; // Allow only one model at a tim << 890 } 514 } 891 } 515 } 892 << 893 if (!any) { << 894 if (verbosity >= G4VisManager::warnings) { << 895 G4warn << "WARNING: No match found." << << 896 } << 897 return; << 898 } << 899 << 900 CheckSceneAndNotifyHandlers (pScene); << 901 } 516 } 902 517 903 ////////////// /vis/scene/select ///////////// 518 ////////////// /vis/scene/select /////////////////////////////////////// 904 519 905 G4VisCommandSceneSelect::G4VisCommandSceneSele 520 G4VisCommandSceneSelect::G4VisCommandSceneSelect () { 906 G4bool omitable; 521 G4bool omitable; 907 fpCommand = new G4UIcmdWithAString ("/vis/sc 522 fpCommand = new G4UIcmdWithAString ("/vis/scene/select", this); 908 fpCommand -> SetGuidance ("Selects a scene") 523 fpCommand -> SetGuidance ("Selects a scene"); 909 fpCommand -> SetGuidance << 524 fpCommand -> SetGuidance 910 ("Makes the scene current. \"/vis/scene/lis << 525 ("Makes the scene current. \"/vis/scene/list\" to see" 911 "\n possible scene names."); << 526 "\n possible scene names."); 912 fpCommand -> SetParameterName ("scene-name", 527 fpCommand -> SetParameterName ("scene-name", omitable = false); 913 } 528 } 914 529 915 G4VisCommandSceneSelect::~G4VisCommandSceneSel 530 G4VisCommandSceneSelect::~G4VisCommandSceneSelect () { 916 delete fpCommand; 531 delete fpCommand; 917 } 532 } 918 533 919 G4String G4VisCommandSceneSelect::GetCurrentVa 534 G4String G4VisCommandSceneSelect::GetCurrentValue (G4UIcommand*) { 920 return ""; 535 return ""; 921 } 536 } 922 537 923 void G4VisCommandSceneSelect::SetNewValue (G4U 538 void G4VisCommandSceneSelect::SetNewValue (G4UIcommand*, G4String newValue) { 924 539 925 G4VisManager::Verbosity verbosity = fpVisMan 540 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 926 541 927 G4String& selectName = newValue; 542 G4String& selectName = newValue; 928 G4SceneList& sceneList = fpVisManager -> Set 543 G4SceneList& sceneList = fpVisManager -> SetSceneList (); 929 std::size_t iScene, nScenes = sceneList.size << 544 G4int iScene, nScenes = sceneList.size (); 930 for (iScene = 0; iScene < nScenes; ++iScene) << 545 for (iScene = 0; iScene < nScenes; iScene++) { 931 if (sceneList [iScene] -> GetName () == se 546 if (sceneList [iScene] -> GetName () == selectName) break; 932 } 547 } 933 if (iScene >= nScenes) { 548 if (iScene >= nScenes) { 934 if (verbosity >= G4VisManager::warnings) { 549 if (verbosity >= G4VisManager::warnings) { 935 G4warn << "WARNING: Scene \"" << selectN << 550 G4cout << "WARNING: Scene \"" << selectName 936 << "\" not found - \"/vis/scene/list\" t << 551 << "\" not found - \"/vis/scene/list\" to see possibilities." 937 << G4endl; << 552 << G4endl; 938 } 553 } 939 return; 554 return; 940 } 555 } 941 556 942 if (verbosity >= G4VisManager::confirmations 557 if (verbosity >= G4VisManager::confirmations) { 943 G4cout << "Scene \"" << selectName 558 G4cout << "Scene \"" << selectName 944 << "\" selected." << G4endl; << 559 << "\" selected." << G4endl; 945 } 560 } >> 561 UpdateVisManagerScene (selectName); 946 562 947 CheckSceneAndNotifyHandlers (sceneList [iSce << 948 } 563 } 949 564 950 ////////////// /vis/scene/showExtents //////// << 565 ////////////// /vis/scene/transientsAction //////////////////////////// >> 566 >> 567 G4VisCommandSceneTransientsAction::G4VisCommandSceneTransientsAction () { >> 568 G4bool omitable; >> 569 fpCommand = new G4UIcmdWithAString ("/vis/scene/transientsAction", this); >> 570 fpCommand -> SetGuidance >> 571 ("Rerun events to get transienst (trajectories, etc.), when needed."); >> 572 fpCommand -> SetGuidance >> 573 ("Note: ineffective in absence of instantiated run manager."); >> 574 fpCommand -> SetParameterName ("action", omitable = true); >> 575 fpCommand -> SetCandidates ("rerun none"); >> 576 fpCommand -> SetDefaultValue ("rerun"); 951 577 952 G4VisCommandSceneShowExtents::G4VisCommandScen << 953 fpCommand = new G4UIcmdWithoutParameter ("/v << 954 fpCommand -> SetGuidance ("Prints and draws << 955 } 578 } 956 579 957 G4VisCommandSceneShowExtents::~G4VisCommandSce << 580 G4VisCommandSceneTransientsAction::~G4VisCommandSceneTransientsAction () { 958 delete fpCommand; 581 delete fpCommand; 959 } 582 } 960 583 961 G4String G4VisCommandSceneShowExtents::GetCurr << 584 G4String G4VisCommandSceneTransientsAction::GetCurrentValue(G4UIcommand*) { 962 return ""; 585 return ""; 963 } 586 } 964 587 965 void G4VisCommandSceneShowExtents::SetNewValue << 588 void G4VisCommandSceneTransientsAction::SetNewValue (G4UIcommand*, >> 589 G4String newValue) { 966 590 967 G4VisManager::Verbosity verbosity = fpVisMan 591 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 968 592 969 G4VSceneHandler* pCurrentSceneHandler = << 593 G4String action; 970 fpVisManager -> GetCurrentSceneHandler(); << 594 std::istringstream is (newValue); 971 if (!pCurrentSceneHandler) { << 595 is >> action; 972 if (verbosity >= G4VisManager::warnings) { << 596 973 G4warn << "WARNING: No current scene han << 597 G4Scene* pScene = fpVisManager->GetCurrentScene(); 974 << G4endl; << 598 if (!pScene) { >> 599 if (verbosity >= G4VisManager::errors) { >> 600 G4cout << "ERROR: No current scene. Please create one." << G4endl; 975 } 601 } 976 return; 602 return; 977 } 603 } 978 G4VViewer* pCurrentViewer = fpVisManager -> << 604 979 if (!pCurrentViewer) { << 605 G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler(); 980 if (verbosity >= G4VisManager::warnings) { << 606 if (!pSceneHandler) { 981 G4warn << "WARNING: No current viewer." << 607 if (verbosity >= G4VisManager::errors) { 982 << G4endl; << 608 G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl; 983 } 609 } 984 return; 610 return; 985 } 611 } 986 G4Scene* pCurrentScene = fpVisManager -> Get << 612 987 if (!pCurrentScene) { << 613 if (action == "rerun") { 988 if (verbosity >= G4VisManager::warnings) { << 614 pScene->SetRecomputeTransients(true); 989 G4warn << "WARNING: No current scene." << 615 } 990 << G4endl; << 616 else if (action == "none") { >> 617 pScene->SetRecomputeTransients(false); >> 618 } >> 619 else { >> 620 if (verbosity >= G4VisManager::errors) { >> 621 G4cout << >> 622 "ERROR: unrecognised parameter \"" << action << "\"." >> 623 << G4endl; 991 } 624 } 992 return; 625 return; 993 } 626 } 994 627 995 G4cout << "\n Run-duration models:"; << 628 if (verbosity >= G4VisManager::confirmations) { 996 std::size_t nRunModels = pCurrentScene -> Ge << 629 G4cout << "Transients action set to \""; 997 if (nRunModels == 0) { << 630 if (pScene->GetRecomputeTransients()) G4cout << "rerun"; 998 G4cout << " none."; << 631 else G4cout << "none"; 999 } << 632 G4cout << "\"" << G4endl; 1000 for (std::size_t i = 0; i < nRunModels; ++i << 633 } 1001 if (pCurrentScene -> GetRunDurationModelL << 1002 G4cout << "\n Active: "; << 1003 else G4cout << "\n Inactive: "; << 1004 G4VModel* pModel = pCurrentScene -> GetRu << 1005 const G4VisExtent& transformedExtent = pM << 1006 G4cout << pModel -> GetGlobalDescription << 1007 << "\n" << transformedExtent; << 1008 DrawExtent(transformedExtent); << 1009 } << 1010 G4cout << "\n End-of-event models:"; << 1011 std::size_t nEOEModels = pCurrentScene -> G << 1012 if (nEOEModels == 0) { << 1013 G4cout << " none."; << 1014 } << 1015 for (std::size_t i = 0; i < nEOEModels; ++i << 1016 if (pCurrentScene -> GetEndOfEventModelLi << 1017 G4cout << "\n Active: "; << 1018 else G4cout << "\n Inactive: "; << 1019 G4VModel* pModel = pCurrentScene -> GetEn << 1020 const G4VisExtent& transformedExtent = pM << 1021 G4cout << pModel -> GetGlobalDescription << 1022 << "\n" << transformedExtent; << 1023 DrawExtent(transformedExtent); << 1024 } << 1025 G4cout << "\n End-of-run models:"; << 1026 std::size_t nEORModels = pCurrentScene -> G << 1027 if (nEORModels == 0) { << 1028 G4cout << " none."; << 1029 } << 1030 for (std::size_t i = 0; i < nEORModels; ++i << 1031 if (pCurrentScene -> GetEndOfRunModelList << 1032 G4cout << "\n Active: "; << 1033 else G4cout << "\n Inactive: "; << 1034 G4VModel* pModel = pCurrentScene -> GetEn << 1035 const G4VisExtent& transformedExtent = pM << 1036 G4cout << pModel -> GetGlobalDescription << 1037 << "\n" << transformedExtent; << 1038 DrawExtent(transformedExtent); << 1039 } << 1040 G4cout << "\n Overall extent:\n"; << 1041 DrawExtent(pCurrentScene->GetExtent()); << 1042 G4cout << G4endl; << 1043 } 634 } 1044 635