53 if (pScene) currentSceneName = pScene -> GetName ();
54 return currentSceneName;
63 (
"Activate or de-activate model.");
65 (
"Attempts to match search string to name of model - use unique sub-string.");
67 (
"Use \"/vis/scene/list\" to see model names.");
69 (
"If name == \"all\" (default), all models are activated.");
71 parameter =
new G4UIparameter (
"search-string",
's', omitable =
true);
72 parameter -> SetDefaultValue (
"all");
74 parameter =
new G4UIparameter (
"activate",
'b', omitable =
true);
75 parameter -> SetDefaultValue (
true);
92 G4String searchString, activateString;
93 std::istringstream is (newValue);
94 is >> searchString >> activateString;
100 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
106 if (!pSceneHandler) {
108 G4cerr <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
113 if (searchString ==
"all" && !activate) {
116 "WARNING: You are not allowed to de-activate all models."
117 "\n Command ignored."
125 std::vector<G4Scene::Model>& runDurationModelList =
127 for (
size_t i = 0; i < runDurationModelList.size(); i++) {
129 runDurationModelList[i].fpModel->GetGlobalDescription();
130 if (searchString ==
"all" || modelName.find(searchString)
131 != std::string::npos) {
133 runDurationModelList[i].fActive = activate;
135 G4cout <<
"Model \"" << modelName;
136 if (activate)
G4cout <<
"\" activated.";
137 else G4cout <<
"\" de-activated.";
143 std::vector<G4Scene::Model>& endOfEventModelList =
145 for (
size_t i = 0; i < endOfEventModelList.size(); i++) {
147 endOfEventModelList[i].fpModel->GetGlobalDescription();
148 if (searchString ==
"all" || modelName.find(searchString)
149 != std::string::npos) {
151 endOfEventModelList[i].fActive = activate;
153 G4cout <<
"Model \"" << modelName;
154 if (activate)
G4cout <<
"\" activated.";
155 else G4cout <<
"\" de-activated.";
161 std::vector<G4Scene::Model>& endOfRunModelList =
163 for (
size_t i = 0; i < endOfRunModelList.size(); i++) {
165 endOfRunModelList[i].fpModel->GetGlobalDescription();
166 if (searchString ==
"all" || modelName.find(searchString)
167 != std::string::npos) {
169 endOfRunModelList[i].fActive = activate;
171 G4cout <<
"Model \"" << modelName;
172 if (activate)
G4cout <<
"\" activated.";
173 else G4cout <<
"\" de-activated.";
195 (
"Creates an empty scene.");
197 (
"Invents a name if not supplied. This scene becomes current.");
198 fpCommand -> SetParameterName (
"scene-name", omitable =
true);
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;
257 (
"Accumulate or refresh the viewer for each new event.");
259 (
"\"accumulate\": viewer accumulates hits, etc., event by event, or");
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");
268 parameter =
new G4UIparameter (
"maxNumber",
'i', omitable =
true);
269 parameter -> SetDefaultValue (100);
270 parameter -> SetGuidance
271 (
"Maximum number of events kept. Unlimited if negative.");
289 G4int maxNumberOfKeptEvents;
290 std::istringstream is (newValue);
291 is >>
action >> maxNumberOfKeptEvents;
296 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
302 if (!pSceneHandler) {
304 G4cerr <<
"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\"."
330 "ERROR: unrecognised parameter \"" <<
action <<
"\"."
340 size_t nCurrentlyKept = 0;
347 const std::vector<const G4Event*>* events = currentRun->
GetEventVector();
349 nCurrentlyKept = events->size();
354 G4cout <<
"End of event action set to ";
357 G4cout <<
"\"accumulate\"."
358 "\n Maximum number of events to be kept: "
359 << maxNumberOfKeptEvents
360 <<
" (unlimited if negative)."
361 "\n This may be changed with, e.g., "
362 "\"/vis/scene/endOfEventAction accumulate 1000\".";
368 maxNumberOfKeptEvents != 0 &&
371 if (nCurrentlyKept) {
373 "\n There are currently " << nCurrentlyKept
374 <<
" events kept for refreshing and/or reviewing.";
376 G4cout <<
"The vis manager will keep ";
377 if (maxNumberOfKeptEvents < 0)
G4cout <<
"an unlimited number of";
378 else G4cout <<
"up to " << maxNumberOfKeptEvents;
380 if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
382 "\n This may use a lot of memory."
383 "\n It may be changed with, e.g., "
384 "\"/vis/scene/endOfEventAction accumulate 10\".";
396 (
"Accumulate or refresh the viewer for each new run.");
398 (
"\"accumulate\": viewer accumulates hits, etc., run by run, or");
400 (
"\"refresh\": viewer shows them at end of run or, for direct-screen"
401 "\n viewers, refreshes the screen just before drawing the first"
402 "\n event of the next run.");
403 fpCommand -> SetGuidance (
"The detector remains or is redrawn.");
404 fpCommand -> SetParameterName (
"action", omitable =
true);
405 fpCommand -> SetCandidates (
"accumulate refresh");
406 fpCommand -> SetDefaultValue (
"refresh");
423 std::istringstream is (newValue);
429 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
435 if (!pSceneHandler) {
437 G4cerr <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
442 if (
action ==
"accumulate") {
446 "ERROR: Cannot accumulate runs unless events accumulate too."
447 "\n Use \"/vis/scene/endOfEventAction accumulate\"."
455 else if (
action ==
"refresh") {
462 "ERROR: unrecognised parameter \"" <<
action <<
"\"."
472 G4cout <<
"End of run action set to \"";
474 else G4cout <<
"accumulate";
484 fpCommand -> SetGuidance (
"Lists scene(s).");
486 (
"\"help /vis/verbose\" for definition of verbosity.");
488 parameter =
new G4UIparameter (
"scene-name",
's', omitable =
true);
489 parameter -> SetDefaultValue (
"all");
491 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
492 parameter -> SetDefaultValue (
"warnings");
506 std::istringstream is (newValue);
507 is >>
name >> verbosityString;
512 if (currentScene) currentName = currentScene->
GetName();
515 G4int iScene, nScenes = sceneList.size ();
517 for (iScene = 0; iScene < nScenes; iScene++) {
518 G4Scene* pScene = sceneList [iScene];
519 const G4String& iName = pScene -> GetName ();
521 if (
name != iName)
continue;
524 if (iName == currentName) {
530 G4cout <<
" scene \"" << iName <<
"\"";
533 G4cout <<
"\n Run-duration models:";
534 G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
535 if (nRunModels == 0) {
538 for (i = 0; i < nRunModels; i++) {
539 if (pScene -> GetRunDurationModelList()[i].fActive)
541 else G4cout <<
"\n Inactive: ";
542 G4VModel* pModel = pScene -> GetRunDurationModelList()[i].fpModel;
543 G4cout << pModel -> GetGlobalDescription ();
545 G4cout <<
"\n End-of-event models:";
546 G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
547 if (nEOEModels == 0) {
550 for (i = 0; i < nEOEModels; i++) {
551 if (pScene -> GetEndOfEventModelList()[i].fActive)
553 else G4cout <<
"\n Inactive: ";
554 G4VModel* pModel = pScene -> GetEndOfEventModelList()[i].fpModel;
555 G4cout << pModel -> GetGlobalDescription ();
557 G4cout <<
"\n End-of-run models:";
558 G4int nEORModels = pScene -> GetEndOfRunModelList ().size ();
559 if (nEORModels == 0) {
562 for (i = 0; i < nEORModels; i++) {
563 if (pScene -> GetEndOfRunModelList()[i].fActive)
565 else G4cout <<
"\n Inactive: ";
566 G4VModel* pModel = pScene -> GetEndOfRunModelList()[i].fpModel;
567 G4cout << pModel -> GetGlobalDescription ();
571 G4cout <<
"\n " << *sceneList [iScene];
576 G4cerr <<
"No scenes found";
590 (
"Notifies scene handlers and forces re-rendering.");
592 (
"Notifies the handler(s) of the specified scene and forces a"
593 "\nreconstruction of any graphical databases."
594 "\nClears and refreshes all viewers of current scene."
595 "\n The default action \"refresh\" does not issue \"update\" (see"
596 "\n /vis/viewer/update)."
597 "\nIf \"flush\" is specified, it issues an \"update\" as well as"
598 "\n \"refresh\" - \"update\" and initiates post-processing"
599 "\n for graphics systems which need it.");
601 (
"The default for <scene-name> is the current scene name.");
603 (
"This command does not change current scene, scene handler or viewer.");
607 parameter -> SetCurrentAsDefault(
true);
611 parameter -> SetDefaultValue(
"refresh");
612 parameter -> SetParameterCandidates(
"r refresh f flush");
630 std::istringstream is (newValue);
631 is >> sceneName >> refresh_flush;
633 if (refresh_flush[0] ==
'f') flush =
true;
640 const G4int nScenes = sceneList.size ();
642 for (iScene = 0; iScene < nScenes; iScene++) {
643 G4Scene* scene = sceneList [iScene];
644 if (sceneName == scene -> GetName ())
break;
646 if (iScene >= nScenes ) {
648 G4cout <<
"WARNING: Scene \"" << sceneName <<
"\" not found."
649 "\n /vis/scene/list to see scenes."
658 if (!pCurrentSceneHandler) {
660 G4cout <<
"WARNING: No current scene handler."
666 if (!pCurrentViewer) {
668 G4cout <<
"WARNING: No current viewer."
674 if (!pCurrentScene) {
676 G4cout <<
"WARNING: No current scene."
690 const G4int nSceneHandlers = sceneHandlerList.size ();
691 for (
G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
693 G4Scene* aScene = aSceneHandler -> GetScene ();
695 const G4String& aSceneName = aScene -> GetName ();
696 if (sceneName == aSceneName) {
698 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
699 const G4int nViewers = viewerList.size ();
700 for (
G4int iV = 0; iV < nViewers; iV++) {
703 aViewer -> NeedKernelVisit();
705 aSceneHandler -> SetCurrentViewer (aViewer);
710 aViewer -> SetView ();
711 aViewer -> ClearView ();
712 aViewer -> DrawView ();
713 if (flush) aViewer -> ShowView ();
715 G4cout <<
"Viewer \"" << aViewer -> GetName ()
716 <<
"\" of scene handler \"" << aSceneHandler -> GetName ()
718 if (flush)
G4cout <<
"flushed";
719 else G4cout <<
"refreshed";
720 G4cout <<
" at request of scene \"" << sceneName
725 G4cout <<
"NOTE: The scene, \""
727 <<
"\", of viewer \""
728 << aViewer -> GetName ()
729 <<
"\"\n of scene handler \""
730 << aSceneHandler -> GetName ()
731 <<
"\" has changed. To see effect,"
732 <<
"\n \"/vis/viewer/select "
733 << aViewer -> GetShortName ()
734 <<
"\" and \"/vis/viewer/rebuild\"."
743 G4cout <<
"WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
745 <<
"\" has a null scene."
758 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
762 if (pCurrentSceneHandler) {
763 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
764 const G4int nViewers = viewerList.size ();
766 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
780 fpCommand -> SetGuidance(
"Remove model.");
782 (
"Attempts to match search string to name of model - use unique sub-string.");
784 (
"Use \"/vis/scene/list\" to see model names.");
786 parameter =
new G4UIparameter (
"search-string",
's', omitable =
false);
804 std::istringstream is (newValue);
810 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
816 if (!pSceneHandler) {
818 G4cerr <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
825 std::vector<G4Scene::Model>& runDurationModelList =
827 for (
size_t i = 0; i < runDurationModelList.size(); i++) {
829 runDurationModelList[i].fpModel->GetGlobalDescription();
830 if (modelName.find(searchString) != std::string::npos) {
831 runDurationModelList.erase(runDurationModelList.begin()+i);
834 G4cout <<
"Model \"" << modelName <<
"\" removed." <<
G4endl;
840 std::vector<G4Scene::Model>& endOfEventModelList =
842 for (
size_t i = 0; i < endOfEventModelList.size(); i++) {
844 endOfEventModelList[i].fpModel->GetGlobalDescription();
845 if (modelName.find(searchString) != std::string::npos) {
846 endOfEventModelList.erase(endOfEventModelList.begin()+i);
849 G4cout <<
"Model \"" << modelName <<
"\" removed." <<
G4endl;
855 std::vector<G4Scene::Model>& endOfRunModelList =
857 for (
size_t i = 0; i < endOfRunModelList.size(); i++) {
859 endOfRunModelList[i].fpModel->GetGlobalDescription();
860 if (modelName.find(searchString) != std::string::npos) {
861 endOfRunModelList.erase(endOfRunModelList.begin()+i);
864 G4cout <<
"Model \"" << modelName <<
"\" removed." <<
G4endl;
885 fpCommand -> SetGuidance (
"Selects a scene");
887 (
"Makes the scene current. \"/vis/scene/list\" to see"
888 "\n possible scene names.");
889 fpCommand -> SetParameterName (
"scene-name", omitable =
false);
906 G4int iScene, nScenes = sceneList.size ();
907 for (iScene = 0; iScene < nScenes; iScene++) {
908 if (sceneList [iScene] -> GetName () == selectName)
break;
910 if (iScene >= nScenes) {
912 G4cout <<
"WARNING: Scene \"" << selectName
913 <<
"\" not found - \"/vis/scene/list\" to see possibilities."
920 G4cout <<
"Scene \"" << selectName
921 <<
"\" selected." <<
G4endl;
931 fpCommand -> SetGuidance (
"Prints and draws extents of models in a scene");
948 if (!pCurrentSceneHandler) {
950 G4cout <<
"WARNING: No current scene handler."
956 if (!pCurrentViewer) {
958 G4cout <<
"WARNING: No current viewer."
964 if (!pCurrentScene) {
966 G4cout <<
"WARNING: No current scene."
972 G4cout <<
"\n Run-duration models:";
973 G4int nRunModels = pCurrentScene -> GetRunDurationModelList ().size ();
974 if (nRunModels == 0) {
977 for (
G4int i = 0; i < nRunModels; i++) {
978 if (pCurrentScene -> GetRunDurationModelList()[i].fActive)
980 else G4cout <<
"\n Inactive: ";
981 G4VModel* pModel = pCurrentScene -> GetRunDurationModelList()[i].fpModel;
982 const G4VisExtent& transformedExtent = pModel -> GetExtent();
983 G4cout << pModel -> GetGlobalDescription ()
984 <<
"\n" << transformedExtent;
987 G4cout <<
"\n End-of-event models:";
988 G4int nEOEModels = pCurrentScene -> GetEndOfEventModelList ().size ();
989 if (nEOEModels == 0) {
992 for (
G4int i = 0; i < nEOEModels; i++) {
993 if (pCurrentScene -> GetEndOfEventModelList()[i].fActive)
995 else G4cout <<
"\n Inactive: ";
996 G4VModel* pModel = pCurrentScene -> GetEndOfEventModelList()[i].fpModel;
997 const G4VisExtent& transformedExtent = pModel -> GetExtent();
998 G4cout << pModel -> GetGlobalDescription ()
999 <<
"\n" << transformedExtent;
1002 G4cout <<
"\n End-of-run models:";
1003 G4int nEORModels = pCurrentScene -> GetEndOfRunModelList ().size ();
1004 if (nEORModels == 0) {
1007 for (
G4int i = 0; i < nEORModels; i++) {
1008 if (pCurrentScene -> GetEndOfRunModelList()[i].fActive)
1010 else G4cout <<
"\n Inactive: ";
1011 G4VModel* pModel = pCurrentScene -> GetEndOfRunModelList()[i].fpModel;
1012 const G4VisExtent& transformedExtent = pModel -> GetExtent();
1013 G4cout << pModel -> GetGlobalDescription ()
1014 <<
"\n" << transformedExtent;
1017 G4cout <<
"\n Overall extent:\n";
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
static G4RunManager * GetMasterRunManager()
const G4Run * GetCurrentRun() const
const std::vector< const G4Event * > * GetEventVector() const
std::vector< Model > & SetEndOfRunModelList()
G4bool GetRefreshAtEndOfEvent() const
void SetRefreshAtEndOfEvent(G4bool)
const G4VisExtent & GetExtent() const
const G4String & GetName() const
std::vector< Model > & SetRunDurationModelList()
std::vector< Model > & SetEndOfEventModelList()
void SetRefreshAtEndOfRun(G4bool)
void SetMaxNumberOfKeptEvents(G4int)
G4bool GetRefreshAtEndOfRun() const
static G4bool ConvertToBool(const char *st)
void SetMarkForClearingTransientStore(G4bool)
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
G4String CurrentSceneName()
virtual ~G4VVisCommandScene()
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static G4VisManager * fpVisManager
void DrawExtent(const G4VisExtent &)
G4bool IsAutoRefresh() const
virtual ~G4VisCommandSceneActivateModel()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneActivateModel()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneCreate()
G4VisCommandSceneCreate()
G4UIcmdWithAString * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneEndOfEventAction()
virtual ~G4VisCommandSceneEndOfEventAction()
G4UIcmdWithAString * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneEndOfRunAction()
virtual ~G4VisCommandSceneEndOfRunAction()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneList()
virtual ~G4VisCommandSceneNotifyHandlers()
G4VisCommandSceneNotifyHandlers()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneRemoveModel()
G4VisCommandSceneRemoveModel()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneSelect()
G4VisCommandSceneSelect()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithAString * fpCommand
G4UIcmdWithoutParameter * fpCommand
virtual ~G4VisCommandSceneShowExtents()
G4VisCommandSceneShowExtents()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4Scene * GetCurrentScene() const
G4VSceneHandler * GetCurrentSceneHandler() const
static Verbosity GetVerbosity()
void ResetTransientsDrawnFlags()
static Verbosity GetVerbosityValue(const G4String &)
const char * name(G4int ptype)