52 if (pScene) currentSceneName = pScene -> GetName ();
53 return currentSceneName;
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.");
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);
91 G4String searchString, activateString;
92 std::istringstream is (newValue);
93 is >> searchString >> activateString;
99 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
105 if (!pSceneHandler) {
107 G4cout <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
112 if (searchString ==
"all" && !activate) {
115 "WARNING: You are not allowed to de-activate all models."
116 "\n Command ignored."
124 std::vector<G4Scene::Model>& runDurationModelList =
126 for (
size_t i = 0; i < runDurationModelList.size(); i++) {
128 runDurationModelList[i].fpModel->GetGlobalDescription();
129 if (searchString ==
"all" || modelName.find(searchString)
130 != std::string::npos) {
132 runDurationModelList[i].fActive = activate;
134 G4cout <<
"Model \"" << modelName;
135 if (activate)
G4cout <<
"\" activated.";
136 else G4cout <<
"\" de-activated.";
142 std::vector<G4Scene::Model>& endOfEventModelList =
144 for (
size_t i = 0; i < endOfEventModelList.size(); i++) {
146 endOfEventModelList[i].fpModel->GetGlobalDescription();
147 if (searchString ==
"all" || modelName.find(searchString)
148 != std::string::npos) {
150 endOfEventModelList[i].fActive = activate;
152 G4cout <<
"Model \"" << modelName;
153 if (activate)
G4cout <<
"\" activated.";
154 else G4cout <<
"\" de-activated.";
160 std::vector<G4Scene::Model>& endOfRunModelList =
162 for (
size_t i = 0; i < endOfRunModelList.size(); i++) {
164 endOfRunModelList[i].fpModel->GetGlobalDescription();
165 if (searchString ==
"all" || modelName.find(searchString)
166 != std::string::npos) {
168 endOfRunModelList[i].fActive = activate;
170 G4cout <<
"Model \"" << modelName;
171 if (activate)
G4cout <<
"\" activated.";
172 else G4cout <<
"\" de-activated.";
185 const G4String& currentSceneName = pScene -> GetName ();
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);
205 G4String G4VisCommandSceneCreate::NextName () {
206 std::ostringstream oss;
207 oss <<
"scene-" << fId;
225 if (newName == nextName) fId++;
228 G4int iScene, nScenes = sceneList.size ();
229 for (iScene = 0; iScene < nScenes; iScene++) {
230 if (sceneList [iScene] -> GetName () == newName)
break;
232 if (iScene < nScenes) {
234 G4cout <<
"WARNING: Scene \"" << newName <<
"\" already exists."
235 <<
"\n New scene not created."
242 sceneList.push_back (pScene);
246 G4cout <<
"New empty scene \"" << newName <<
"\" created." <<
G4endl;
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.");
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);
289 G4int maxNumberOfKeptEvents;
290 std::istringstream is (newValue);
291 is >> action >> maxNumberOfKeptEvents;
296 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
302 if (!pSceneHandler) {
304 G4cout <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
309 if (action ==
"accumulate") {
313 else if (action ==
"refresh") {
317 "ERROR: Cannot refresh events unless runs refresh too."
318 "\n Use \"/vis/scene/endOfRun refresh\"."
329 "ERROR: unrecognised parameter \"" << action <<
"\"."
339 size_t nCurrentlyKept = 0;
344 const std::vector<const G4Event*>* events =
346 if (events) nCurrentlyKept = events->size();
351 G4cout <<
"End of event action set to ";
354 G4cout <<
"\"accumulate\"."
355 "\n Maximum number of events to be kept: "
356 << maxNumberOfKeptEvents
357 <<
" (unlimited if negative)."
358 "\n This may be changed with, e.g., "
359 "\"/vis/scene/endOfEventAction accumulate 1000\".";
365 maxNumberOfKeptEvents != 0 &&
368 if (nCurrentlyKept) {
370 "\n There are currently " << nCurrentlyKept
371 <<
" events kept for refreshing and/or reviewing.";
373 G4cout <<
"The vis manager will keep ";
374 if (maxNumberOfKeptEvents < 0)
G4cout <<
"an unlimited number of";
375 else G4cout <<
"up to " << maxNumberOfKeptEvents;
377 if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
379 "\n This may use a lot of memory."
380 "\n It may be changed with, e.g., "
381 "\"/vis/scene/endOfEventAction accumulate 10\".";
392 fpCommand -> SetGuidance
393 (
"Accumulate or refresh the viewer for each new run.");
394 fpCommand -> SetGuidance
395 (
"\"accumulate\": viewer accumulates hits, etc., run by run, or");
396 fpCommand -> SetGuidance
397 (
"\"refresh\": viewer shows them at end of run or, for direct-screen"
398 "\n viewers, refreshes the screen just before drawing the first"
399 "\n event of the next run.");
400 fpCommand -> SetGuidance (
"The detector remains or is redrawn.");
401 fpCommand -> SetParameterName (
"action", omitable =
true);
402 fpCommand -> SetCandidates (
"accumulate refresh");
403 fpCommand -> SetDefaultValue (
"refresh");
420 std::istringstream is (newValue);
426 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
432 if (!pSceneHandler) {
434 G4cout <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
439 if (action ==
"accumulate") {
443 "ERROR: Cannot accumulate runs unless events accumulate too."
444 "\n Use \"/vis/scene/endOfEventAction accumulate\"."
452 else if (action ==
"refresh") {
459 "ERROR: unrecognised parameter \"" << action <<
"\"."
469 G4cout <<
"End of run action set to \"";
471 else G4cout <<
"accumulate";
480 fpCommand =
new G4UIcommand (
"/vis/scene/list",
this);
481 fpCommand -> SetGuidance (
"Lists scene(s).");
482 fpCommand -> SetGuidance
483 (
"\"help /vis/verbose\" for definition of verbosity.");
485 parameter =
new G4UIparameter (
"scene-name",
's', omitable =
true);
486 parameter -> SetDefaultValue (
"all");
487 fpCommand -> SetParameter (parameter);
488 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
489 parameter -> SetDefaultValue (
"warnings");
490 fpCommand -> SetParameter (parameter);
503 std::istringstream is (newValue);
504 is >> name >> verbosityString;
509 if (currentScene) currentName = currentScene->
GetName();
512 G4int iScene, nScenes = sceneList.size ();
514 for (iScene = 0; iScene < nScenes; iScene++) {
515 G4Scene* pScene = sceneList [iScene];
516 const G4String& iName = pScene -> GetName ();
518 if (name != iName)
continue;
521 if (iName == currentName) {
527 G4cout <<
" scene \"" << iName <<
"\"";
530 G4cout <<
"\n Run-duration models:";
531 G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
532 if (nRunModels == 0) {
535 for (i = 0; i < nRunModels; i++) {
536 if (pScene -> GetRunDurationModelList()[i].fActive)
538 else G4cout <<
"\n Inactive: ";
539 G4VModel* pModel = pScene -> GetRunDurationModelList()[i].fpModel;
540 G4cout << pModel -> GetGlobalDescription ();
542 G4cout <<
"\n End-of-event models:";
543 G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
544 if (nEOEModels == 0) {
547 for (i = 0; i < nEOEModels; i++) {
548 if (pScene -> GetEndOfEventModelList()[i].fActive)
550 else G4cout <<
"\n Inactive: ";
551 G4VModel* pModel = pScene -> GetEndOfEventModelList()[i].fpModel;
552 G4cout << pModel -> GetGlobalDescription ();
554 G4cout <<
"\n End-of-run models:";
555 G4int nEORModels = pScene -> GetEndOfRunModelList ().size ();
556 if (nEORModels == 0) {
559 for (i = 0; i < nEORModels; i++) {
560 if (pScene -> GetEndOfRunModelList()[i].fActive)
562 else G4cout <<
"\n Inactive: ";
563 G4VModel* pModel = pScene -> GetEndOfRunModelList()[i].fpModel;
564 G4cout << pModel -> GetGlobalDescription ();
568 G4cout <<
"\n " << *sceneList [iScene];
573 G4cout <<
"No scenes found";
575 G4cout <<
" of name \"" << name <<
"\"";
585 fpCommand =
new G4UIcommand (
"/vis/scene/notifyHandlers",
this);
586 fpCommand -> SetGuidance
587 (
"Notifies scene handlers and forces re-rendering.");
588 fpCommand -> SetGuidance
589 (
"Notifies the handler(s) of the specified scene and forces a"
590 "\nreconstruction of any graphical databases."
591 "\nClears and refreshes all viewers of current scene."
592 "\n The default action \"refresh\" does not issue \"update\" (see"
593 "\n /vis/viewer/update)."
594 "\nIf \"flush\" is specified, it issues an \"update\" as well as"
595 "\n \"refresh\" - \"update\" and initiates post-processing"
596 "\n for graphics systems which need it.");
597 fpCommand -> SetGuidance
598 (
"The default for <scene-name> is the current scene name.");
599 fpCommand -> SetGuidance
600 (
"This command does not change current scene, scene handler or viewer.");
604 parameter -> SetCurrentAsDefault(
true);
605 fpCommand -> SetParameter (parameter);
608 parameter -> SetDefaultValue(
"refresh");
609 parameter -> SetParameterCandidates(
"r refresh f flush");
610 fpCommand -> SetParameter (parameter);
627 std::istringstream is (newValue);
628 is >> sceneName >> refresh_flush;
630 if (refresh_flush(0) ==
'f') flush =
true;
637 const G4int nScenes = sceneList.size ();
639 for (iScene = 0; iScene < nScenes; iScene++) {
640 G4Scene* scene = sceneList [iScene];
641 if (sceneName == scene -> GetName ())
break;
643 if (iScene >= nScenes ) {
645 G4cout <<
"WARNING: Scene \"" << sceneName <<
"\" not found."
646 "\n /vis/scene/list to see scenes."
655 if (!pCurrentSceneHandler) {
657 G4cout <<
"WARNING: No current scene handler."
663 if (!pCurrentViewer) {
665 G4cout <<
"WARNING: No current viewer."
671 if (!pCurrentScene) {
673 G4cout <<
"WARNING: No current scene."
687 const G4int nSceneHandlers = sceneHandlerList.size ();
688 for (
G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
690 G4Scene* aScene = aSceneHandler -> GetScene ();
692 const G4String& aSceneName = aScene -> GetName ();
693 if (sceneName == aSceneName) {
695 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
696 const G4int nViewers = viewerList.size ();
697 for (
G4int iV = 0; iV < nViewers; iV++) {
700 aViewer -> NeedKernelVisit();
702 aSceneHandler -> SetCurrentViewer (aViewer);
707 aViewer -> SetView ();
708 aViewer -> ClearView ();
709 aViewer -> DrawView ();
710 if (flush) aViewer -> ShowView ();
712 G4cout <<
"Viewer \"" << aViewer -> GetName ()
713 <<
"\" of scene handler \"" << aSceneHandler -> GetName ()
715 if (flush)
G4cout <<
"flushed";
716 else G4cout <<
"refreshed";
717 G4cout <<
" at request of scene \"" << sceneName
722 G4cout <<
"NOTE: The scene, \""
724 <<
"\", of viewer \""
725 << aViewer -> GetName ()
726 <<
"\"\n of scene handler \""
727 << aSceneHandler -> GetName ()
728 <<
"\" has changed. To see effect,"
729 <<
"\n \"/vis/viewer/select "
730 << aViewer -> GetShortName ()
731 <<
"\" and \"/vis/viewer/rebuild\"."
740 G4cout <<
"WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
742 <<
"\" has a null scene."
755 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
759 if (pCurrentSceneHandler) {
760 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
761 const G4int nViewers = viewerList.size ();
763 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
764 if (pCurrentViewer && pCurrentSceneHandler->
GetScene()) {
765 pCurrentViewer -> SetView ();
776 fpCommand -> SetGuidance (
"Selects a scene");
777 fpCommand -> SetGuidance
778 (
"Makes the scene current. \"/vis/scene/list\" to see"
779 "\n possible scene names.");
780 fpCommand -> SetParameterName (
"scene-name", omitable =
false);
797 G4int iScene, nScenes = sceneList.size ();
798 for (iScene = 0; iScene < nScenes; iScene++) {
799 if (sceneList [iScene] -> GetName () == selectName)
break;
801 if (iScene >= nScenes) {
803 G4cout <<
"WARNING: Scene \"" << selectName
804 <<
"\" not found - \"/vis/scene/list\" to see possibilities."
811 G4cout <<
"Scene \"" << selectName
812 <<
"\" selected." <<
G4endl;