35 #ifdef G4MULTITHREADED
55 if (pScene) currentSceneName = pScene -> GetName ();
56 return currentSceneName;
65 (
"Activate or de-activate model.");
67 (
"Attempts to match search string to name of model - use unique sub-string.");
69 (
"Use \"/vis/scene/list\" to see model names.");
71 (
"If name == \"all\" (default), all models are activated.");
73 parameter =
new G4UIparameter (
"search-string",
's', omitable =
true);
74 parameter -> SetDefaultValue (
"all");
76 parameter =
new G4UIparameter (
"activate",
'b', omitable =
true);
77 parameter -> SetDefaultValue (
true);
94 G4String searchString, activateString;
95 std::istringstream is (newValue);
96 is >> searchString >> activateString;
102 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
108 if (!pSceneHandler) {
110 G4cerr <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
115 if (searchString ==
"all" && !activate) {
118 "WARNING: You are not allowed to de-activate all models."
119 "\n Command ignored."
127 std::vector<G4Scene::Model>& runDurationModelList =
129 for (
size_t i = 0; i < runDurationModelList.size(); i++) {
131 runDurationModelList[i].fpModel->GetGlobalDescription();
132 if (searchString ==
"all" || modelName.find(searchString)
133 != std::string::npos) {
135 runDurationModelList[i].fActive = activate;
137 G4cout <<
"Model \"" << modelName;
138 if (activate)
G4cout <<
"\" activated.";
139 else G4cout <<
"\" de-activated.";
145 std::vector<G4Scene::Model>& endOfEventModelList =
147 for (
size_t i = 0; i < endOfEventModelList.size(); i++) {
149 endOfEventModelList[i].fpModel->GetGlobalDescription();
150 if (searchString ==
"all" || modelName.find(searchString)
151 != std::string::npos) {
153 endOfEventModelList[i].fActive = activate;
155 G4cout <<
"Model \"" << modelName;
156 if (activate)
G4cout <<
"\" activated.";
157 else G4cout <<
"\" de-activated.";
163 std::vector<G4Scene::Model>& endOfRunModelList =
165 for (
size_t i = 0; i < endOfRunModelList.size(); i++) {
167 endOfRunModelList[i].fpModel->GetGlobalDescription();
168 if (searchString ==
"all" || modelName.find(searchString)
169 != std::string::npos) {
171 endOfRunModelList[i].fActive = activate;
173 G4cout <<
"Model \"" << modelName;
174 if (activate)
G4cout <<
"\" activated.";
175 else G4cout <<
"\" de-activated.";
197 (
"Creates an empty scene.");
199 (
"Invents a name if not supplied. This scene becomes current.");
200 fpCommand -> SetParameterName (
"scene-name", omitable =
true);
208 std::ostringstream oss;
209 oss <<
"scene-" <<
fId;
227 if (newName == nextName)
fId++;
230 G4int iScene, nScenes = sceneList.size ();
231 for (iScene = 0; iScene < nScenes; iScene++) {
232 if (sceneList [iScene] -> GetName () == newName)
break;
234 if (iScene < nScenes) {
236 G4cout <<
"WARNING: Scene \"" << newName <<
"\" already exists."
237 <<
"\n New scene not created."
244 sceneList.push_back (pScene);
248 G4cout <<
"New empty scene \"" << newName <<
"\" created." <<
G4endl;
259 (
"Accumulate or refresh the viewer for each new event.");
261 (
"\"accumulate\": viewer accumulates hits, etc., event by event, or");
263 (
"\"refresh\": viewer shows them at end of event or, for direct-screen"
264 "\n viewers, refreshes the screen just before drawing the next event.");
266 parameter =
new G4UIparameter (
"action",
's', omitable =
true);
267 parameter -> SetParameterCandidates (
"accumulate refresh");
268 parameter -> SetDefaultValue (
"refresh");
270 parameter =
new G4UIparameter (
"maxNumber",
'i', omitable =
true);
271 parameter -> SetDefaultValue (100);
272 parameter -> SetGuidance
273 (
"Maximum number of events kept. Unlimited if negative.");
291 G4int maxNumberOfKeptEvents;
292 std::istringstream is (newValue);
293 is >> action >> maxNumberOfKeptEvents;
298 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
304 if (!pSceneHandler) {
306 G4cerr <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
311 if (action ==
"accumulate") {
315 else if (action ==
"refresh") {
319 "ERROR: Cannot refresh events unless runs refresh too."
320 "\n Use \"/vis/scene/endOfRun refresh\"."
332 "ERROR: unrecognised parameter \"" << action <<
"\"."
342 size_t nCurrentlyKept = 0;
344 #ifdef G4MULTITHREADED
351 const std::vector<const G4Event*>* events =
353 if (events) nCurrentlyKept = events->size();
358 G4cout <<
"End of event action set to ";
361 G4cout <<
"\"accumulate\"."
362 "\n Maximum number of events to be kept: "
363 << maxNumberOfKeptEvents
364 <<
" (unlimited if negative)."
365 "\n This may be changed with, e.g., "
366 "\"/vis/scene/endOfEventAction accumulate 1000\".";
372 maxNumberOfKeptEvents != 0 &&
375 if (nCurrentlyKept) {
377 "\n There are currently " << nCurrentlyKept
378 <<
" events kept for refreshing and/or reviewing.";
380 G4cout <<
"The vis manager will keep ";
381 if (maxNumberOfKeptEvents < 0)
G4cout <<
"an unlimited number of";
382 else G4cout <<
"up to " << maxNumberOfKeptEvents;
384 if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
386 "\n This may use a lot of memory."
387 "\n It may be changed with, e.g., "
388 "\"/vis/scene/endOfEventAction accumulate 10\".";
400 (
"Accumulate or refresh the viewer for each new run.");
402 (
"\"accumulate\": viewer accumulates hits, etc., run by run, or");
404 (
"\"refresh\": viewer shows them at end of run or, for direct-screen"
405 "\n viewers, refreshes the screen just before drawing the first"
406 "\n event of the next run.");
407 fpCommand -> SetGuidance (
"The detector remains or is redrawn.");
408 fpCommand -> SetParameterName (
"action", omitable =
true);
409 fpCommand -> SetCandidates (
"accumulate refresh");
410 fpCommand -> SetDefaultValue (
"refresh");
427 std::istringstream is (newValue);
433 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
439 if (!pSceneHandler) {
441 G4cerr <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
446 if (action ==
"accumulate") {
450 "ERROR: Cannot accumulate runs unless events accumulate too."
451 "\n Use \"/vis/scene/endOfEventAction accumulate\"."
459 else if (action ==
"refresh") {
466 "ERROR: unrecognised parameter \"" << action <<
"\"."
476 G4cout <<
"End of run action set to \"";
478 else G4cout <<
"accumulate";
488 fpCommand -> SetGuidance (
"Lists scene(s).");
490 (
"\"help /vis/verbose\" for definition of verbosity.");
492 parameter =
new G4UIparameter (
"scene-name",
's', omitable =
true);
493 parameter -> SetDefaultValue (
"all");
495 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
496 parameter -> SetDefaultValue (
"warnings");
510 std::istringstream is (newValue);
511 is >> name >> verbosityString;
516 if (currentScene) currentName = currentScene->
GetName();
519 G4int iScene, nScenes = sceneList.size ();
521 for (iScene = 0; iScene < nScenes; iScene++) {
522 G4Scene* pScene = sceneList [iScene];
523 const G4String& iName = pScene -> GetName ();
525 if (name != iName)
continue;
528 if (iName == currentName) {
534 G4cout <<
" scene \"" << iName <<
"\"";
537 G4cout <<
"\n Run-duration models:";
538 G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
539 if (nRunModels == 0) {
542 for (i = 0; i < nRunModels; i++) {
543 if (pScene -> GetRunDurationModelList()[i].fActive)
545 else G4cout <<
"\n Inactive: ";
546 G4VModel* pModel = pScene -> GetRunDurationModelList()[i].fpModel;
547 G4cout << pModel -> GetGlobalDescription ();
549 G4cout <<
"\n End-of-event models:";
550 G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
551 if (nEOEModels == 0) {
554 for (i = 0; i < nEOEModels; i++) {
555 if (pScene -> GetEndOfEventModelList()[i].fActive)
557 else G4cout <<
"\n Inactive: ";
558 G4VModel* pModel = pScene -> GetEndOfEventModelList()[i].fpModel;
559 G4cout << pModel -> GetGlobalDescription ();
561 G4cout <<
"\n End-of-run models:";
562 G4int nEORModels = pScene -> GetEndOfRunModelList ().size ();
563 if (nEORModels == 0) {
566 for (i = 0; i < nEORModels; i++) {
567 if (pScene -> GetEndOfRunModelList()[i].fActive)
569 else G4cout <<
"\n Inactive: ";
570 G4VModel* pModel = pScene -> GetEndOfRunModelList()[i].fpModel;
571 G4cout << pModel -> GetGlobalDescription ();
575 G4cout <<
"\n " << *sceneList [iScene];
580 G4cout <<
"No scenes found";
582 G4cout <<
" of name \"" << name <<
"\"";
594 (
"Notifies scene handlers and forces re-rendering.");
596 (
"Notifies the handler(s) of the specified scene and forces a"
597 "\nreconstruction of any graphical databases."
598 "\nClears and refreshes all viewers of current scene."
599 "\n The default action \"refresh\" does not issue \"update\" (see"
600 "\n /vis/viewer/update)."
601 "\nIf \"flush\" is specified, it issues an \"update\" as well as"
602 "\n \"refresh\" - \"update\" and initiates post-processing"
603 "\n for graphics systems which need it.");
605 (
"The default for <scene-name> is the current scene name.");
607 (
"This command does not change current scene, scene handler or viewer.");
611 parameter -> SetCurrentAsDefault(
true);
615 parameter -> SetDefaultValue(
"refresh");
616 parameter -> SetParameterCandidates(
"r refresh f flush");
634 std::istringstream is (newValue);
635 is >> sceneName >> refresh_flush;
637 if (refresh_flush(0) ==
'f') flush =
true;
644 const G4int nScenes = sceneList.size ();
646 for (iScene = 0; iScene < nScenes; iScene++) {
647 G4Scene* scene = sceneList [iScene];
648 if (sceneName == scene -> GetName ())
break;
650 if (iScene >= nScenes ) {
652 G4cout <<
"WARNING: Scene \"" << sceneName <<
"\" not found."
653 "\n /vis/scene/list to see scenes."
662 if (!pCurrentSceneHandler) {
664 G4cout <<
"WARNING: No current scene handler."
670 if (!pCurrentViewer) {
672 G4cout <<
"WARNING: No current viewer."
678 if (!pCurrentScene) {
680 G4cout <<
"WARNING: No current scene."
694 const G4int nSceneHandlers = sceneHandlerList.size ();
695 for (
G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
697 G4Scene* aScene = aSceneHandler -> GetScene ();
699 const G4String& aSceneName = aScene -> GetName ();
700 if (sceneName == aSceneName) {
702 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
703 const G4int nViewers = viewerList.size ();
704 for (
G4int iV = 0; iV < nViewers; iV++) {
707 aViewer -> NeedKernelVisit();
709 aSceneHandler -> SetCurrentViewer (aViewer);
714 aViewer -> SetView ();
715 aViewer -> ClearView ();
716 aViewer -> DrawView ();
717 if (flush) aViewer -> ShowView ();
719 G4cout <<
"Viewer \"" << aViewer -> GetName ()
720 <<
"\" of scene handler \"" << aSceneHandler -> GetName ()
722 if (flush)
G4cout <<
"flushed";
723 else G4cout <<
"refreshed";
724 G4cout <<
" at request of scene \"" << sceneName
729 G4cout <<
"NOTE: The scene, \""
731 <<
"\", of viewer \""
732 << aViewer -> GetName ()
733 <<
"\"\n of scene handler \""
734 << aSceneHandler -> GetName ()
735 <<
"\" has changed. To see effect,"
736 <<
"\n \"/vis/viewer/select "
737 << aViewer -> GetShortName ()
738 <<
"\" and \"/vis/viewer/rebuild\"."
747 G4cout <<
"WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
749 <<
"\" has a null scene."
762 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
766 if (pCurrentSceneHandler) {
767 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
768 const G4int nViewers = viewerList.size ();
770 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
771 if (pCurrentViewer && pCurrentSceneHandler->
GetScene()) {
772 pCurrentViewer -> SetView ();
783 fpCommand -> SetGuidance (
"Selects a scene");
785 (
"Makes the scene current. \"/vis/scene/list\" to see"
786 "\n possible scene names.");
787 fpCommand -> SetParameterName (
"scene-name", omitable =
false);
804 G4int iScene, nScenes = sceneList.size ();
805 for (iScene = 0; iScene < nScenes; iScene++) {
806 if (sceneList [iScene] -> GetName () == selectName)
break;
808 if (iScene >= nScenes) {
810 G4cout <<
"WARNING: Scene \"" << selectName
811 <<
"\" not found - \"/vis/scene/list\" to see possibilities."
818 G4cout <<
"Scene \"" << selectName
819 <<
"\" selected." <<
G4endl;
829 fpCommand -> SetGuidance (
"Prints and draws extents of models in a scene");
846 if (!pCurrentSceneHandler) {
848 G4cout <<
"WARNING: No current scene handler."
854 if (!pCurrentViewer) {
856 G4cout <<
"WARNING: No current viewer."
862 if (!pCurrentScene) {
864 G4cout <<
"WARNING: No current scene."
870 G4cout <<
"\n Run-duration models:";
871 G4int nRunModels = pCurrentScene -> GetRunDurationModelList ().size ();
872 if (nRunModels == 0) {
875 for (
G4int i = 0; i < nRunModels; i++) {
876 if (pCurrentScene -> GetRunDurationModelList()[i].fActive)
878 else G4cout <<
"\n Inactive: ";
879 G4VModel* pModel = pCurrentScene -> GetRunDurationModelList()[i].fpModel;
880 const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
881 G4cout << pModel -> GetGlobalDescription ()
882 <<
"\n" << transformedExtent;
885 G4cout <<
"\n End-of-event models:";
886 G4int nEOEModels = pCurrentScene -> GetEndOfEventModelList ().size ();
887 if (nEOEModels == 0) {
890 for (
G4int i = 0; i < nEOEModels; i++) {
891 if (pCurrentScene -> GetEndOfEventModelList()[i].fActive)
893 else G4cout <<
"\n Inactive: ";
894 G4VModel* pModel = pCurrentScene -> GetEndOfEventModelList()[i].fpModel;
895 const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
896 G4cout << pModel -> GetGlobalDescription ()
897 <<
"\n" << transformedExtent;
900 G4cout <<
"\n End-of-run models:";
901 G4int nEORModels = pCurrentScene -> GetEndOfRunModelList ().size ();
902 if (nEORModels == 0) {
905 for (
G4int i = 0; i < nEORModels; i++) {
906 if (pCurrentScene -> GetEndOfRunModelList()[i].fActive)
908 else G4cout <<
"\n Inactive: ";
909 G4VModel* pModel = pCurrentScene -> GetEndOfRunModelList()[i].fpModel;
910 const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
911 G4cout << pModel -> GetGlobalDescription ()
912 <<
"\n" << transformedExtent;
915 G4cout <<
"Overall extent:\n";