Geant4  10.01.p03
G4VisCommandsScene.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VisCommandsScene.cc 87360 2014-12-01 16:07:16Z gcosmo $
28 
29 // /vis/scene commands - John Allison 9th August 1998
30 
31 #include "G4VisCommandsScene.hh"
32 
33 #include "G4VisManager.hh"
35 #include "G4RunManager.hh"
36 #ifdef G4MULTITHREADED
37 #include "G4MTRunManager.hh"
38 #endif
39 #include "G4Run.hh"
40 #include "G4PhysicalVolumeModel.hh"
41 #include "G4ApplicationState.hh"
42 #include "G4UImanager.hh"
43 #include "G4UIcommand.hh"
44 #include "G4UIcmdWithAString.hh"
45 #include "G4ios.hh"
46 #include <sstream>
47 
49 
51 
53  const G4Scene* pScene = fpVisManager -> GetCurrentScene ();
54  G4String currentSceneName = "none";
55  if (pScene) currentSceneName = pScene -> GetName ();
56  return currentSceneName;
57 }
58 
60 
62  G4bool omitable;
63  fpCommand = new G4UIcommand ("/vis/scene/activateModel", this);
64  fpCommand -> SetGuidance
65  ("Activate or de-activate model.");
66  fpCommand -> SetGuidance
67  ("Attempts to match search string to name of model - use unique sub-string.");
68  fpCommand -> SetGuidance
69  ("Use \"/vis/scene/list\" to see model names.");
70  fpCommand -> SetGuidance
71  ("If name == \"all\" (default), all models are activated.");
72  G4UIparameter* parameter;
73  parameter = new G4UIparameter ("search-string", 's', omitable = true);
74  parameter -> SetDefaultValue ("all");
75  fpCommand -> SetParameter (parameter);
76  parameter = new G4UIparameter ("activate", 'b', omitable = true);
77  parameter -> SetDefaultValue (true);
78  fpCommand -> SetParameter (parameter);
79 }
80 
82  delete fpCommand;
83 }
84 
86  return "";
87 }
88 
90  G4String newValue) {
91 
93 
94  G4String searchString, activateString;
95  std::istringstream is (newValue);
96  is >> searchString >> activateString;
97  G4bool activate = G4UIcommand::ConvertToBool(activateString);
98 
100  if (!pScene) {
101  if (verbosity >= G4VisManager::errors) {
102  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
103  }
104  return;
105  }
106 
108  if (!pSceneHandler) {
109  if (verbosity >= G4VisManager::errors) {
110  G4cerr << "ERROR: No current sceneHandler. Please create one." << G4endl;
111  }
112  return;
113  }
114 
115  if (searchString == "all" && !activate) {
116  if (verbosity >= G4VisManager::warnings) {
117  G4cout <<
118  "WARNING: You are not allowed to de-activate all models."
119  "\n Command ignored."
120  << G4endl;
121  }
122  return;
123  }
124 
125  G4bool any = false;
126 
127  std::vector<G4Scene::Model>& runDurationModelList =
128  pScene->SetRunDurationModelList();
129  for (size_t i = 0; i < runDurationModelList.size(); i++) {
130  const G4String& modelName =
131  runDurationModelList[i].fpModel->GetGlobalDescription();
132  if (searchString == "all" || modelName.find(searchString)
133  != std::string::npos) {
134  any = true;
135  runDurationModelList[i].fActive = activate;
136  if (verbosity >= G4VisManager::warnings) {
137  G4cout << "Model \"" << modelName;
138  if (activate) G4cout << "\" activated.";
139  else G4cout << "\" de-activated.";
140  G4cout << G4endl;
141  }
142  }
143  }
144 
145  std::vector<G4Scene::Model>& endOfEventModelList =
146  pScene->SetEndOfEventModelList();
147  for (size_t i = 0; i < endOfEventModelList.size(); i++) {
148  const G4String& modelName =
149  endOfEventModelList[i].fpModel->GetGlobalDescription();
150  if (searchString == "all" || modelName.find(searchString)
151  != std::string::npos) {
152  any = true;
153  endOfEventModelList[i].fActive = activate;
154  if (verbosity >= G4VisManager::warnings) {
155  G4cout << "Model \"" << modelName;
156  if (activate) G4cout << "\" activated.";
157  else G4cout << "\" de-activated.";
158  G4cout << G4endl;
159  }
160  }
161  }
162 
163  std::vector<G4Scene::Model>& endOfRunModelList =
164  pScene->SetEndOfRunModelList();
165  for (size_t i = 0; i < endOfRunModelList.size(); i++) {
166  const G4String& modelName =
167  endOfRunModelList[i].fpModel->GetGlobalDescription();
168  if (searchString == "all" || modelName.find(searchString)
169  != std::string::npos) {
170  any = true;
171  endOfRunModelList[i].fActive = activate;
172  if (verbosity >= G4VisManager::warnings) {
173  G4cout << "Model \"" << modelName;
174  if (activate) G4cout << "\" activated.";
175  else G4cout << "\" de-activated.";
176  G4cout << G4endl;
177  }
178  }
179  }
180 
181  if (!any) {
182  if (verbosity >= G4VisManager::warnings) {
183  G4cout << "WARNING: No match found." << G4endl;
184  }
185  return;
186  }
187 
188  const G4String& currentSceneName = pScene -> GetName ();
189  UpdateVisManagerScene (currentSceneName);
190 }
191 
193 
195  G4bool omitable;
196  fpCommand = new G4UIcmdWithAString ("/vis/scene/create", this);
197  fpCommand -> SetGuidance
198  ("Creates an empty scene.");
199  fpCommand -> SetGuidance
200  ("Invents a name if not supplied. This scene becomes current.");
201  fpCommand -> SetParameterName ("scene-name", omitable = true);
202 }
203 
205  delete fpCommand;
206 }
207 
209  std::ostringstream oss;
210  oss << "scene-" << fId;
211  return oss.str();
212 }
213 
215  return "";
216 }
217 
219 
221 
222  G4String& newName = newValue;
223  G4String nextName = NextName ();
224 
225  if (newName == "") {
226  newName = nextName;
227  }
228  if (newName == nextName) fId++;
229 
230  G4SceneList& sceneList = fpVisManager -> SetSceneList ();
231  G4int iScene, nScenes = sceneList.size ();
232  for (iScene = 0; iScene < nScenes; iScene++) {
233  if (sceneList [iScene] -> GetName () == newName) break;
234  }
235  if (iScene < nScenes) {
236  if (verbosity >= G4VisManager::warnings) {
237  G4cout << "WARNING: Scene \"" << newName << "\" already exists."
238  << "\n New scene not created."
239  << G4endl;
240  }
241  } else {
242 
243  // Add empty scene data object to list...
244  G4Scene* pScene = new G4Scene (newName);
245  sceneList.push_back (pScene);
246  fpVisManager -> SetCurrentScene (pScene);
247 
248  if (verbosity >= G4VisManager::confirmations) {
249  G4cout << "New empty scene \"" << newName << "\" created." << G4endl;
250  }
251  }
252 }
253 
255 
257  G4bool omitable;
258  fpCommand = new G4UIcommand ("/vis/scene/endOfEventAction", this);
259  fpCommand -> SetGuidance
260  ("Accumulate or refresh the viewer for each new event.");
261  fpCommand -> SetGuidance
262  ("\"accumulate\": viewer accumulates hits, etc., event by event, or");
263  fpCommand -> SetGuidance
264  ("\"refresh\": viewer shows them at end of event or, for direct-screen"
265  "\n viewers, refreshes the screen just before drawing the next event.");
266  G4UIparameter* parameter;
267  parameter = new G4UIparameter ("action", 's', omitable = true);
268  parameter -> SetParameterCandidates ("accumulate refresh");
269  parameter -> SetDefaultValue ("refresh");
270  fpCommand -> SetParameter (parameter);
271  parameter = new G4UIparameter ("maxNumber", 'i', omitable = true);
272  parameter -> SetDefaultValue (100);
273  parameter -> SetGuidance
274  ("Maximum number of events kept. Unlimited if negative.");
275  fpCommand -> SetParameter (parameter);
276 }
277 
279  delete fpCommand;
280 }
281 
283  return "";
284 }
285 
287  G4String newValue) {
288 
290 
291  G4String action;
292  G4int maxNumberOfKeptEvents;
293  std::istringstream is (newValue);
294  is >> action >> maxNumberOfKeptEvents;
295 
296  G4Scene* pScene = fpVisManager->GetCurrentScene();
297  if (!pScene) {
298  if (verbosity >= G4VisManager::errors) {
299  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
300  }
301  return;
302  }
303 
305  if (!pSceneHandler) {
306  if (verbosity >= G4VisManager::errors) {
307  G4cerr << "ERROR: No current sceneHandler. Please create one." << G4endl;
308  }
309  return;
310  }
311 
312  if (action == "accumulate") {
313  pScene->SetRefreshAtEndOfEvent(false);
314  pScene->SetMaxNumberOfKeptEvents(maxNumberOfKeptEvents);
315  }
316  else if (action == "refresh") {
317  if (!pScene->GetRefreshAtEndOfRun()) {
318  if (verbosity >= G4VisManager::errors) {
319  G4cerr <<
320  "ERROR: Cannot refresh events unless runs refresh too."
321  "\n Use \"/vis/scene/endOfRun refresh\"."
322  << G4endl;
323  }
324  } else {
325  pScene->SetRefreshAtEndOfEvent(true);
326  pScene->SetMaxNumberOfKeptEvents(maxNumberOfKeptEvents);
327  pSceneHandler->SetMarkForClearingTransientStore(true);
328  }
329  }
330  else {
331  if (verbosity >= G4VisManager::errors) {
332  G4cerr <<
333  "ERROR: unrecognised parameter \"" << action << "\"."
334  << G4endl;
335  }
336  return;
337  }
338 
339  // Change of transients behaviour, so...
341 
342  // Are there any events currently kept...
343  size_t nCurrentlyKept = 0;
345 #ifdef G4MULTITHREADED
347  { runManager = G4MTRunManager::GetMasterRunManager(); }
348 #endif
349  if (runManager) {
350  const G4Run* currentRun = runManager->GetCurrentRun();
351  if (currentRun) {
352  const std::vector<const G4Event*>* events =
353  currentRun->GetEventVector();
354  if (events) nCurrentlyKept = events->size();
355  }
356  }
357 
358  if (verbosity >= G4VisManager::confirmations) {
359  G4cout << "End of event action set to ";
360  if (pScene->GetRefreshAtEndOfEvent()) G4cout << "\"refresh\".";
361  else {
362  G4cout << "\"accumulate\"."
363  "\n Maximum number of events to be kept: "
364  << maxNumberOfKeptEvents
365  << " (unlimited if negative)."
366  "\n This may be changed with, e.g., "
367  "\"/vis/scene/endOfEventAction accumulate 1000\".";
368  }
369  G4cout << G4endl;
370  }
371 
372  if (!pScene->GetRefreshAtEndOfEvent() &&
373  maxNumberOfKeptEvents != 0 &&
374  verbosity >= G4VisManager::warnings) {
375  G4cout << "WARNING: ";
376  if (nCurrentlyKept) {
377  G4cout <<
378  "\n There are currently " << nCurrentlyKept
379  << " events kept for refreshing and/or reviewing.";
380  } else {
381  G4cout << "The vis manager will keep ";
382  if (maxNumberOfKeptEvents < 0) G4cout << "an unlimited number of";
383  else G4cout << "up to " << maxNumberOfKeptEvents;
384  G4cout << " events.";
385  if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
386  G4cout <<
387  "\n This may use a lot of memory."
388  "\n It may be changed with, e.g., "
389  "\"/vis/scene/endOfEventAction accumulate 10\".";
390  }
391  G4cout << G4endl;
392  }
393 }
394 
396 
398  G4bool omitable;
399  fpCommand = new G4UIcmdWithAString ("/vis/scene/endOfRunAction", this);
400  fpCommand -> SetGuidance
401  ("Accumulate or refresh the viewer for each new run.");
402  fpCommand -> SetGuidance
403  ("\"accumulate\": viewer accumulates hits, etc., run by run, or");
404  fpCommand -> SetGuidance
405  ("\"refresh\": viewer shows them at end of run or, for direct-screen"
406  "\n viewers, refreshes the screen just before drawing the first"
407  "\n event of the next run.");
408  fpCommand -> SetGuidance ("The detector remains or is redrawn.");
409  fpCommand -> SetParameterName ("action", omitable = true);
410  fpCommand -> SetCandidates ("accumulate refresh");
411  fpCommand -> SetDefaultValue ("refresh");
412 }
413 
415  delete fpCommand;
416 }
417 
419  return "";
420 }
421 
423  G4String newValue) {
424 
426 
427  G4String action;
428  std::istringstream is (newValue);
429  is >> action;
430 
431  G4Scene* pScene = fpVisManager->GetCurrentScene();
432  if (!pScene) {
433  if (verbosity >= G4VisManager::errors) {
434  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
435  }
436  return;
437  }
438 
440  if (!pSceneHandler) {
441  if (verbosity >= G4VisManager::errors) {
442  G4cerr << "ERROR: No current sceneHandler. Please create one." << G4endl;
443  }
444  return;
445  }
446 
447  if (action == "accumulate") {
448  if (pScene->GetRefreshAtEndOfEvent()) {
449  if (verbosity >= G4VisManager::errors) {
450  G4cerr <<
451  "ERROR: Cannot accumulate runs unless events accumulate too."
452  "\n Use \"/vis/scene/endOfEventAction accumulate\"."
453  << G4endl;
454  }
455  }
456  else {
457  pScene->SetRefreshAtEndOfRun(false);
458  }
459  }
460  else if (action == "refresh") {
461  pScene->SetRefreshAtEndOfRun(true);
462  pSceneHandler->SetMarkForClearingTransientStore(true);
463  }
464  else {
465  if (verbosity >= G4VisManager::errors) {
466  G4cerr <<
467  "ERROR: unrecognised parameter \"" << action << "\"."
468  << G4endl;
469  }
470  return;
471  }
472 
473  // Change of transients behaviour, so...
475 
476  if (verbosity >= G4VisManager::confirmations) {
477  G4cout << "End of run action set to \"";
478  if (pScene->GetRefreshAtEndOfRun()) G4cout << "refresh";
479  else G4cout << "accumulate";
480  G4cout << "\"" << G4endl;
481  }
482 }
483 
485 
487  G4bool omitable;
488  fpCommand = new G4UIcommand ("/vis/scene/list", this);
489  fpCommand -> SetGuidance ("Lists scene(s).");
490  fpCommand -> SetGuidance
491  ("\"help /vis/verbose\" for definition of verbosity.");
492  G4UIparameter* parameter;
493  parameter = new G4UIparameter ("scene-name", 's', omitable = true);
494  parameter -> SetDefaultValue ("all");
495  fpCommand -> SetParameter (parameter);
496  parameter = new G4UIparameter ("verbosity", 's', omitable = true);
497  parameter -> SetDefaultValue ("warnings");
498  fpCommand -> SetParameter (parameter);
499 }
500 
502  delete fpCommand;
503 }
504 
506  return "";
507 }
508 
510  G4String name, verbosityString;
511  std::istringstream is (newValue);
512  is >> name >> verbosityString;
513  G4VisManager::Verbosity verbosity =
514  fpVisManager->GetVerbosityValue(verbosityString);
515  const G4Scene* currentScene = fpVisManager -> GetCurrentScene ();
516  G4String currentName;
517  if (currentScene) currentName = currentScene->GetName();
518 
519  G4SceneList& sceneList = fpVisManager -> SetSceneList ();
520  G4int iScene, nScenes = sceneList.size ();
521  G4bool found = false;
522  for (iScene = 0; iScene < nScenes; iScene++) {
523  G4Scene* pScene = sceneList [iScene];
524  const G4String& iName = pScene -> GetName ();
525  if (name != "all") {
526  if (name != iName) continue;
527  }
528  found = true;
529  if (iName == currentName) {
530  G4cout << " (current)";
531  }
532  else {
533  G4cout << " ";
534  }
535  G4cout << " scene \"" << iName << "\"";
536  if (verbosity >= G4VisManager::warnings) {
537  G4int i;
538  G4cout << "\n Run-duration models:";
539  G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
540  if (nRunModels == 0) {
541  G4cout << " none.";
542  }
543  for (i = 0; i < nRunModels; i++) {
544  if (pScene -> GetRunDurationModelList()[i].fActive)
545  G4cout << "\n Active: ";
546  else G4cout << "\n Inactive: ";
547  G4VModel* pModel = pScene -> GetRunDurationModelList()[i].fpModel;
548  G4cout << pModel -> GetGlobalDescription ();
549  }
550  G4cout << "\n End-of-event models:";
551  G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
552  if (nEOEModels == 0) {
553  G4cout << " none.";
554  }
555  for (i = 0; i < nEOEModels; i++) {
556  if (pScene -> GetEndOfEventModelList()[i].fActive)
557  G4cout << "\n Active: ";
558  else G4cout << "\n Inactive: ";
559  G4VModel* pModel = pScene -> GetEndOfEventModelList()[i].fpModel;
560  G4cout << pModel -> GetGlobalDescription ();
561  }
562  G4cout << "\n End-of-run models:";
563  G4int nEORModels = pScene -> GetEndOfRunModelList ().size ();
564  if (nEORModels == 0) {
565  G4cout << " none.";
566  }
567  for (i = 0; i < nEORModels; i++) {
568  if (pScene -> GetEndOfRunModelList()[i].fActive)
569  G4cout << "\n Active: ";
570  else G4cout << "\n Inactive: ";
571  G4VModel* pModel = pScene -> GetEndOfRunModelList()[i].fpModel;
572  G4cout << pModel -> GetGlobalDescription ();
573  }
574  }
575  if (verbosity >= G4VisManager::parameters) {
576  G4cout << "\n " << *sceneList [iScene];
577  }
578  G4cout << G4endl;
579  }
580  if (!found) {
581  G4cout << "No scenes found";
582  if (name != "all") {
583  G4cout << " of name \"" << name << "\"";
584  }
585  G4cout << "." << G4endl;
586  }
587 }
588 
590 
592  G4bool omitable;
593  fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this);
594  fpCommand -> SetGuidance
595  ("Notifies scene handlers and forces re-rendering.");
596  fpCommand -> SetGuidance
597  ("Notifies the handler(s) of the specified scene and forces a"
598  "\nreconstruction of any graphical databases."
599  "\nClears and refreshes all viewers of current scene."
600  "\n The default action \"refresh\" does not issue \"update\" (see"
601  "\n /vis/viewer/update)."
602  "\nIf \"flush\" is specified, it issues an \"update\" as well as"
603  "\n \"refresh\" - \"update\" and initiates post-processing"
604  "\n for graphics systems which need it.");
605  fpCommand -> SetGuidance
606  ("The default for <scene-name> is the current scene name.");
607  fpCommand -> SetGuidance
608  ("This command does not change current scene, scene handler or viewer.");
609  G4UIparameter* parameter;
610  parameter = new G4UIparameter ("scene-name", 's',
611  omitable = true);
612  parameter -> SetCurrentAsDefault(true);
613  fpCommand -> SetParameter (parameter);
614  parameter = new G4UIparameter ("refresh-flush", 's',
615  omitable = true);
616  parameter -> SetDefaultValue("refresh");
617  parameter -> SetParameterCandidates("r refresh f flush");
618  fpCommand -> SetParameter (parameter);
619 }
620 
622  delete fpCommand;
623 }
624 
626  return CurrentSceneName ();
627 }
628 
630  G4String newValue) {
631 
633 
634  G4String sceneName, refresh_flush;
635  std::istringstream is (newValue);
636  is >> sceneName >> refresh_flush;
637  G4bool flush = false;
638  if (refresh_flush(0) == 'f') flush = true;
639 
640  const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
641  G4SceneHandlerList& sceneHandlerList =
642  fpVisManager -> SetAvailableSceneHandlers ();
643 
644  // Check scene name.
645  const G4int nScenes = sceneList.size ();
646  G4int iScene;
647  for (iScene = 0; iScene < nScenes; iScene++) {
648  G4Scene* scene = sceneList [iScene];
649  if (sceneName == scene -> GetName ()) break;
650  }
651  if (iScene >= nScenes ) {
652  if (verbosity >= G4VisManager::warnings) {
653  G4cout << "WARNING: Scene \"" << sceneName << "\" not found."
654  "\n /vis/scene/list to see scenes."
655  << G4endl;
656  }
657  return;
658  }
659 
660  // Store current context...
661  G4VSceneHandler* pCurrentSceneHandler =
662  fpVisManager -> GetCurrentSceneHandler();
663  if (!pCurrentSceneHandler) {
664  if (verbosity >= G4VisManager::warnings) {
665  G4cout << "WARNING: No current scene handler."
666  << G4endl;
667  }
668  return;
669  }
670  G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
671  if (!pCurrentViewer) {
672  if (verbosity >= G4VisManager::warnings) {
673  G4cout << "WARNING: No current viewer."
674  << G4endl;
675  }
676  return;
677  }
678  G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene();
679  if (!pCurrentScene) {
680  if (verbosity >= G4VisManager::warnings) {
681  G4cout << "WARNING: No current scene."
682  << G4endl;
683  }
684  return;
685  }
686 
687  G4VisManager::Verbosity currentVerbosity = fpVisManager -> GetVerbosity();
688 
689  // Suppress messages during this process (only print errors)...
690  //fpVisManager -> SetVerboseLevel(G4VisManager::errors);
691 
692  // For each scene handler, if it contains the scene, clear and
693  // rebuild the graphical database, then for each viewer set (make
694  // current), clear, (re)draw, and show.
695  const G4int nSceneHandlers = sceneHandlerList.size ();
696  for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
697  G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH];
698  G4Scene* aScene = aSceneHandler -> GetScene ();
699  if (aScene) {
700  const G4String& aSceneName = aScene -> GetName ();
701  if (sceneName == aSceneName) {
702  aScene->CalculateExtent(); // Check and recalculate extent
703  G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
704  const G4int nViewers = viewerList.size ();
705  for (G4int iV = 0; iV < nViewers; iV++) {
706  G4VViewer* aViewer = viewerList [iV];
707  // Force rebuild of graphical database, if any.
708  aViewer -> NeedKernelVisit();
709  if (aViewer->GetViewParameters().IsAutoRefresh()) {
710  aSceneHandler -> SetCurrentViewer (aViewer);
711  // Ensure consistency of vis manager...
712  fpVisManager -> SetCurrentViewer(aViewer);
713  fpVisManager -> SetCurrentSceneHandler(aSceneHandler);
714  fpVisManager -> SetCurrentScene(aScene);
715  aViewer -> SetView ();
716  aViewer -> ClearView ();
717  aViewer -> DrawView ();
718  if (flush) aViewer -> ShowView ();
719  if (verbosity >= G4VisManager::confirmations) {
720  G4cout << "Viewer \"" << aViewer -> GetName ()
721  << "\" of scene handler \"" << aSceneHandler -> GetName ()
722  << "\"\n ";
723  if (flush) G4cout << "flushed";
724  else G4cout << "refreshed";
725  G4cout << " at request of scene \"" << sceneName
726  << "\"." << G4endl;
727  }
728  } else {
729  if (verbosity >= G4VisManager::confirmations) {
730  G4cout << "NOTE: The scene, \""
731  << sceneName
732  << "\", of viewer \""
733  << aViewer -> GetName ()
734  << "\"\n of scene handler \""
735  << aSceneHandler -> GetName ()
736  << "\" has changed. To see effect,"
737  << "\n \"/vis/viewer/select "
738  << aViewer -> GetShortName ()
739  << "\" and \"/vis/viewer/rebuild\"."
740  << G4endl;
741  }
742  }
743  }
744  }
745  }
746  else {
747  if (verbosity >= G4VisManager::warnings) {
748  G4cout << "WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
749  << aSceneHandler->GetName()
750  << "\" has a null scene."
751  << G4endl;
752  }
753  }
754  }
755 
756  // Reclaim original context - but set viewer first, then scene
757  // handler, because the latter might have been created very recently
758  // and, not yet having a viewer, the current viewer will,
759  // temporarily, refer to another scene handler. SetCurrentViewer
760  // actually resets the scene handler, which is what we don't want,
761  // so we set it again on the next line...
762  fpVisManager -> SetCurrentViewer(pCurrentViewer);
763  fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
764  fpVisManager -> SetCurrentScene(pCurrentScene);
765  fpVisManager -> SetVerboseLevel(currentVerbosity);
766  // Take care of special case of scene handler with no viewer yet.
767  if (pCurrentSceneHandler) {
768  G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
769  const G4int nViewers = viewerList.size ();
770  if (nViewers) {
771  pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
772  if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
773  pCurrentViewer -> SetView ();
774  }
775  }
776  }
777 }
778 
780 
782  G4bool omitable;
783  fpCommand = new G4UIcmdWithAString ("/vis/scene/select", this);
784  fpCommand -> SetGuidance ("Selects a scene");
785  fpCommand -> SetGuidance
786  ("Makes the scene current. \"/vis/scene/list\" to see"
787  "\n possible scene names.");
788  fpCommand -> SetParameterName ("scene-name", omitable = false);
789 }
790 
792  delete fpCommand;
793 }
794 
796  return "";
797 }
798 
800 
802 
803  G4String& selectName = newValue;
804  G4SceneList& sceneList = fpVisManager -> SetSceneList ();
805  G4int iScene, nScenes = sceneList.size ();
806  for (iScene = 0; iScene < nScenes; iScene++) {
807  if (sceneList [iScene] -> GetName () == selectName) break;
808  }
809  if (iScene >= nScenes) {
810  if (verbosity >= G4VisManager::warnings) {
811  G4cout << "WARNING: Scene \"" << selectName
812  << "\" not found - \"/vis/scene/list\" to see possibilities."
813  << G4endl;
814  }
815  return;
816  }
817 
818  if (verbosity >= G4VisManager::confirmations) {
819  G4cout << "Scene \"" << selectName
820  << "\" selected." << G4endl;
821  }
822  UpdateVisManagerScene (selectName);
823 }
G4String GetCurrentValue(G4UIcommand *command)
void UpdateVisManagerScene(const G4String &sceneName="")
G4String name
Definition: TRTMaterials.hh:40
G4String GetCurrentValue(G4UIcommand *command)
const G4ViewParameters & GetViewParameters() const
const G4String & GetName() const
const std::vector< const G4Event * > * GetEventVector() const
Definition: G4Run.hh:115
G4String GetCurrentValue(G4UIcommand *command)
std::vector< Model > & SetEndOfRunModelList()
G4bool GetRefreshAtEndOfEvent() const
G4UIcmdWithAString * fpCommand
const G4String & GetName() const
int G4int
Definition: G4Types.hh:78
static Verbosity GetVerbosityValue(const G4String &)
const G4Run * GetCurrentRun() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4GLOB_DLL std::ostream G4cout
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:425
void SetNewValue(G4UIcommand *command, G4String newValue)
bool G4bool
Definition: G4Types.hh:79
G4String GetCurrentValue(G4UIcommand *command)
void SetMaxNumberOfKeptEvents(G4int)
static G4MTRunManager * GetMasterRunManager()
G4bool GetRefreshAtEndOfRun() const
void ResetTransientsDrawnFlags()
G4UIcmdWithAString * fpCommand
Definition: G4Run.hh:46
void CalculateExtent()
Definition: G4Scene.cc:72
void SetNewValue(G4UIcommand *command, G4String newValue)
G4bool IsMultithreadedApplication()
Definition: G4Threading.cc:134
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4Scene * GetScene() const
G4String GetCurrentValue(G4UIcommand *command)
std::vector< Model > & SetRunDurationModelList()
std::vector< Model > & SetEndOfEventModelList()
G4VSceneHandler * GetCurrentSceneHandler() const
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetRefreshAtEndOfRun(G4bool)
void SetMarkForClearingTransientStore(G4bool)
G4bool IsAutoRefresh() const
G4Scene * GetCurrentScene() const
void SetRefreshAtEndOfEvent(G4bool)
G4GLOB_DLL std::ostream G4cerr
static G4VisManager * fpVisManager