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