55 if (pScene) currentSceneName = pScene -> GetName ();
56 return currentSceneName;
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.");
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);
94 G4String searchString, activateString;
95 std::istringstream is (newValue);
96 is >> searchString >> activateString;
102 G4warn <<
"ERROR: No current scene. Please create one." <<
G4endl;
108 if (!pSceneHandler) {
110 G4warn <<
"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 G4warn <<
"Model \"" << modelName;
138 if (activate)
G4warn <<
"\" activated.";
139 else G4warn <<
"\" 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 G4warn <<
"Model \"" << modelName;
156 if (activate)
G4warn <<
"\" activated.";
157 else G4warn <<
"\" 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 G4warn <<
"Model \"" << modelName;
174 if (activate)
G4warn <<
"\" activated.";
175 else G4warn <<
"\" de-activated.";
196 fpCommand -> SetGuidance
197 (
"Creates an empty scene.");
198 fpCommand -> SetGuidance
199 (
"Invents a name if not supplied. This scene becomes current.");
200 fpCommand -> SetParameterName (
"scene-name", omitable =
true);
207G4String G4VisCommandSceneCreate::NextName () {
208 std::ostringstream oss;
209 oss <<
"scene-" << fId;
227 if (newName == nextName) fId++;
230 std::size_t iScene, nScenes = sceneList.size ();
231 for (iScene = 0; iScene < nScenes; ++iScene) {
232 if (sceneList [iScene] -> GetName () == newName)
break;
234 if (iScene < nScenes) {
236 G4warn <<
"WARNING: Scene \"" << newName <<
"\" already exists."
237 <<
"\n New scene not created."
244 sceneList.push_back (pScene);
248 G4cout <<
"New empty scene \"" << newName <<
"\" created." <<
G4endl;
257 fpCommand =
new G4UIcommand (
"/vis/scene/endOfEventAction",
this);
258 fpCommand -> SetGuidance
259 (
"Accumulate or refresh the viewer for each new event.");
260 fpCommand -> SetGuidance
261 (
"\"accumulate\": viewer accumulates hits, etc., event by event, or");
262 fpCommand -> SetGuidance
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");
269 fpCommand -> SetParameter (parameter);
270 parameter =
new G4UIparameter (
"maxNumber",
'i', omitable =
true);
271 parameter -> SetDefaultValue (100);
272 parameter -> SetGuidance
273 (
"Maximum number of events kept. Unlimited if negative.");
274 fpCommand -> SetParameter (parameter);
291 G4int maxNumberOfKeptEvents;
292 std::istringstream is (newValue);
293 is >> action >> maxNumberOfKeptEvents;
298 G4warn <<
"ERROR: No current scene. Please create one." <<
G4endl;
304 if (!pSceneHandler) {
306 G4warn <<
"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;
349 const std::vector<const G4Event*>* events = currentRun->
GetEventVector();
351 nCurrentlyKept = events->size();
356 G4cout <<
"End of event action set to ";
359 G4cout <<
"\"accumulate\"."
360 "\n Maximum number of events to be kept: "
361 << maxNumberOfKeptEvents
362 <<
" (unlimited if negative)."
363 "\n This may be changed with, e.g., "
364 "\"/vis/scene/endOfEventAction accumulate 1000\".";
370 maxNumberOfKeptEvents != 0 &&
373 if (nCurrentlyKept) {
375 "\n There are currently " << nCurrentlyKept
376 <<
" events kept for refreshing and/or reviewing.";
378 G4warn <<
"The vis manager will keep ";
379 if (maxNumberOfKeptEvents < 0)
G4warn <<
"an unlimited number of";
380 else G4warn <<
"up to " << maxNumberOfKeptEvents;
382 if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
384 "\n This may use a lot of memory."
385 "\n It may be changed with, e.g., "
386 "\"/vis/scene/endOfEventAction accumulate 10\".";
397 fpCommand -> SetGuidance
398 (
"Accumulate or refresh the viewer for each new run.");
399 fpCommand -> SetGuidance
400 (
"\"accumulate\": viewer accumulates hits, etc., run by run, or");
401 fpCommand -> SetGuidance
402 (
"\"refresh\": viewer shows them at end of run or, for direct-screen"
403 "\n viewers, refreshes the screen just before drawing the first"
404 "\n event of the next run.");
405 fpCommand -> SetGuidance (
"The detector remains or is redrawn.");
406 fpCommand -> SetParameterName (
"action", omitable =
true);
407 fpCommand -> SetCandidates (
"accumulate refresh");
408 fpCommand -> SetDefaultValue (
"refresh");
425 std::istringstream is (newValue);
431 G4warn <<
"ERROR: No current scene. Please create one." <<
G4endl;
437 if (!pSceneHandler) {
439 G4warn <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
444 if (action ==
"accumulate") {
448 "ERROR: Cannot accumulate runs unless events accumulate too."
449 "\n Use \"/vis/scene/endOfEventAction accumulate\"."
457 else if (action ==
"refresh") {
464 "ERROR: unrecognised parameter \"" << action <<
"\"."
474 G4cout <<
"End of run action set to \"";
476 else G4cout <<
"accumulate";
485 fpCommand =
new G4UIcommand (
"/vis/scene/list",
this);
486 fpCommand -> SetGuidance (
"Lists scene(s).");
487 fpCommand -> SetGuidance
488 (
"\"help /vis/verbose\" for definition of verbosity.");
490 parameter =
new G4UIparameter (
"scene-name",
's', omitable =
true);
491 parameter -> SetDefaultValue (
"all");
492 fpCommand -> SetParameter (parameter);
493 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
494 parameter -> SetDefaultValue (
"warnings");
495 fpCommand -> SetParameter (parameter);
508 std::istringstream is (newValue);
509 is >> name >> verbosityString;
514 if (currentScene) currentName = currentScene->
GetName();
517 std::size_t iScene, nScenes = sceneList.size ();
519 for (iScene = 0; iScene < nScenes; ++iScene) {
520 G4Scene* pScene = sceneList [iScene];
521 const G4String& iName = pScene -> GetName ();
523 if (name != iName)
continue;
526 if (iName == currentName) {
532 G4cout <<
" scene \"" << iName <<
"\"";
535 G4cout <<
"\n Run-duration models:";
536 std::size_t nRunModels = pScene -> GetRunDurationModelList ().size ();
537 if (nRunModels == 0) {
540 for (i = 0; i < nRunModels; ++i) {
541 if (pScene -> GetRunDurationModelList()[i].fActive)
543 else G4cout <<
"\n Inactive: ";
544 G4VModel* pModel = pScene -> GetRunDurationModelList()[i].fpModel;
545 G4cout << pModel -> GetGlobalDescription ();
547 G4cout <<
"\n End-of-event models:";
548 std::size_t nEOEModels = pScene -> GetEndOfEventModelList ().size ();
549 if (nEOEModels == 0) {
552 for (i = 0; i < nEOEModels; ++i) {
553 if (pScene -> GetEndOfEventModelList()[i].fActive)
555 else G4cout <<
"\n Inactive: ";
556 G4VModel* pModel = pScene -> GetEndOfEventModelList()[i].fpModel;
557 G4cout << pModel -> GetGlobalDescription ();
559 G4cout <<
"\n End-of-run models:";
560 std::size_t nEORModels = pScene -> GetEndOfRunModelList ().size ();
561 if (nEORModels == 0) {
564 for (i = 0; i < nEORModels; ++i) {
565 if (pScene -> GetEndOfRunModelList()[i].fActive)
567 else G4cout <<
"\n Inactive: ";
568 G4VModel* pModel = pScene -> GetEndOfRunModelList()[i].fpModel;
569 G4cout << pModel -> GetGlobalDescription ();
573 G4cout <<
"\n " << *sceneList [iScene];
578 G4warn <<
"No scenes found";
580 G4warn <<
" of name \"" << name <<
"\"";
590 fpCommand =
new G4UIcommand (
"/vis/scene/notifyHandlers",
this);
591 fpCommand -> SetGuidance
592 (
"Notifies scene handlers and forces re-rendering.");
593 fpCommand -> SetGuidance
594 (
"Notifies the handler(s) of the specified scene and forces a"
595 "\nreconstruction of any graphical databases."
596 "\nClears and refreshes all viewers of current scene."
597 "\n The default action \"refresh\" does not issue \"update\" (see"
598 "\n /vis/viewer/update)."
599 "\nIf \"flush\" is specified, it issues an \"update\" as well as"
600 "\n \"refresh\" - \"update\" and initiates post-processing"
601 "\n for graphics systems which need it.");
602 fpCommand -> SetGuidance
603 (
"The default for <scene-name> is the current scene name.");
604 fpCommand -> SetGuidance
605 (
"This command does not change current scene, scene handler or viewer.");
609 parameter -> SetCurrentAsDefault(
true);
610 fpCommand -> SetParameter (parameter);
613 parameter -> SetDefaultValue(
"refresh");
614 parameter -> SetParameterCandidates(
"r refresh f flush");
615 fpCommand -> SetParameter (parameter);
632 std::istringstream is (newValue);
633 is >> sceneName >> refresh_flush;
635 if (refresh_flush[0] ==
'f') flush =
true;
642 const std::size_t nScenes = sceneList.size ();
644 for (iScene = 0; iScene < nScenes; ++iScene) {
645 G4Scene* scene = sceneList [iScene];
646 if (sceneName == scene -> GetName ())
break;
648 if (iScene >= nScenes ) {
650 G4warn <<
"WARNING: Scene \"" << sceneName <<
"\" not found."
651 "\n /vis/scene/list to see scenes."
660 if (!pCurrentSceneHandler) {
662 G4warn <<
"WARNING: No current scene handler."
668 if (!pCurrentViewer) {
670 G4warn <<
"WARNING: No current viewer."
676 if (!pCurrentScene) {
678 G4warn <<
"WARNING: No current scene."
692 const std::size_t nSceneHandlers = sceneHandlerList.size ();
693 for (std::size_t iSH = 0; iSH < nSceneHandlers; ++iSH) {
695 G4Scene* aScene = aSceneHandler -> GetScene ();
697 const G4String& aSceneName = aScene -> GetName ();
698 if (sceneName == aSceneName) {
700 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
701 const std::size_t nViewers = viewerList.size ();
702 for (std::size_t iV = 0; iV < nViewers; ++iV) {
705 aViewer -> NeedKernelVisit();
707 aSceneHandler -> SetCurrentViewer (aViewer);
712 aViewer -> SetView ();
713 aViewer -> ClearView ();
714 aViewer -> DrawView ();
715 if (flush) aViewer -> ShowView ();
717 G4cout <<
"Viewer \"" << aViewer -> GetName ()
718 <<
"\" of scene handler \"" << aSceneHandler -> GetName ()
720 if (flush)
G4cout <<
"flushed";
721 else G4cout <<
"refreshed";
722 G4cout <<
" at request of scene \"" << sceneName
727 G4cout <<
"NOTE: The scene, \""
729 <<
"\", of viewer \""
730 << aViewer -> GetName ()
731 <<
"\"\n of scene handler \""
732 << aSceneHandler -> GetName ()
733 <<
"\" has changed. To see effect,"
734 <<
"\n \"/vis/viewer/select "
735 << aViewer -> GetShortName ()
736 <<
"\" and \"/vis/viewer/rebuild\"."
745 G4warn <<
"WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
747 <<
"\" has a null scene."
760 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
764 if (pCurrentSceneHandler) {
765 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
766 const std::size_t nViewers = viewerList.size ();
768 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
781 fpCommand =
new G4UIcommand (
"/vis/scene/removeModel",
this);
782 fpCommand -> SetGuidance(
"Remove model.");
783 fpCommand -> SetGuidance
784 (
"Attempts to match search string to name of model - use unique sub-string.");
785 fpCommand -> SetGuidance
786 (
"Use \"/vis/scene/list\" to see model names.");
788 parameter =
new G4UIparameter (
"search-string",
's', omitable =
false);
789 fpCommand -> SetParameter (parameter);
806 std::istringstream is (newValue);
812 G4warn <<
"ERROR: No current scene. Please create one." <<
G4endl;
818 if (!pSceneHandler) {
820 G4warn <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
827 std::vector<G4Scene::Model>& runDurationModelList =
829 for (
size_t i = 0; i < runDurationModelList.size(); i++) {
831 runDurationModelList[i].fpModel->GetGlobalDescription();
832 if (modelName.find(searchString) != std::string::npos) {
833 runDurationModelList.erase(runDurationModelList.begin()+i);
836 G4warn <<
"Model \"" << modelName <<
"\" removed." <<
G4endl;
842 std::vector<G4Scene::Model>& endOfEventModelList =
844 for (
size_t i = 0; i < endOfEventModelList.size(); i++) {
846 endOfEventModelList[i].fpModel->GetGlobalDescription();
847 if (modelName.find(searchString) != std::string::npos) {
848 endOfEventModelList.erase(endOfEventModelList.begin()+i);
851 G4warn <<
"Model \"" << modelName <<
"\" removed." <<
G4endl;
857 std::vector<G4Scene::Model>& endOfRunModelList =
859 for (
size_t i = 0; i < endOfRunModelList.size(); i++) {
861 endOfRunModelList[i].fpModel->GetGlobalDescription();
862 if (modelName.find(searchString) != std::string::npos) {
863 endOfRunModelList.erase(endOfRunModelList.begin()+i);
866 G4warn <<
"Model \"" << modelName <<
"\" removed." <<
G4endl;
887 fpCommand -> SetGuidance (
"Selects a scene");
888 fpCommand -> SetGuidance
889 (
"Makes the scene current. \"/vis/scene/list\" to see"
890 "\n possible scene names.");
891 fpCommand -> SetParameterName (
"scene-name", omitable =
false);
908 std::size_t iScene, nScenes = sceneList.size ();
909 for (iScene = 0; iScene < nScenes; ++iScene) {
910 if (sceneList [iScene] -> GetName () == selectName)
break;
912 if (iScene >= nScenes) {
914 G4warn <<
"WARNING: Scene \"" << selectName
915 <<
"\" not found - \"/vis/scene/list\" to see possibilities."
922 G4cout <<
"Scene \"" << selectName
923 <<
"\" selected." <<
G4endl;
933 fpCommand -> SetGuidance (
"Prints and draws extents of models in a scene");
950 if (!pCurrentSceneHandler) {
952 G4warn <<
"WARNING: No current scene handler."
958 if (!pCurrentViewer) {
960 G4warn <<
"WARNING: No current viewer."
966 if (!pCurrentScene) {
968 G4warn <<
"WARNING: No current scene."
974 G4cout <<
"\n Run-duration models:";
975 std::size_t nRunModels = pCurrentScene -> GetRunDurationModelList ().size ();
976 if (nRunModels == 0) {
979 for (std::size_t i = 0; i < nRunModels; ++i) {
980 if (pCurrentScene -> GetRunDurationModelList()[i].fActive)
982 else G4cout <<
"\n Inactive: ";
983 G4VModel* pModel = pCurrentScene -> GetRunDurationModelList()[i].fpModel;
984 const G4VisExtent& transformedExtent = pModel -> GetExtent();
985 G4cout << pModel -> GetGlobalDescription ()
986 <<
"\n" << transformedExtent;
989 G4cout <<
"\n End-of-event models:";
990 std::size_t nEOEModels = pCurrentScene -> GetEndOfEventModelList ().size ();
991 if (nEOEModels == 0) {
994 for (std::size_t i = 0; i < nEOEModels; ++i) {
995 if (pCurrentScene -> GetEndOfEventModelList()[i].fActive)
997 else G4cout <<
"\n Inactive: ";
998 G4VModel* pModel = pCurrentScene -> GetEndOfEventModelList()[i].fpModel;
999 const G4VisExtent& transformedExtent = pModel -> GetExtent();
1000 G4cout << pModel -> GetGlobalDescription ()
1001 <<
"\n" << transformedExtent;
1004 G4cout <<
"\n End-of-run models:";
1005 std::size_t nEORModels = pCurrentScene -> GetEndOfRunModelList ().size ();
1006 if (nEORModels == 0) {
1009 for (std::size_t i = 0; i < nEORModels; ++i) {
1010 if (pCurrentScene -> GetEndOfRunModelList()[i].fActive)
1012 else G4cout <<
"\n Inactive: ";
1013 G4VModel* pModel = pCurrentScene -> GetEndOfRunModelList()[i].fpModel;
1014 const G4VisExtent& transformedExtent = pModel -> GetExtent();
1015 G4cout << pModel -> GetGlobalDescription ()
1016 <<
"\n" << transformedExtent;
1019 G4cout <<
"\n Overall extent:\n";
G4GLOB_DLL std::ostream G4cout
static G4RunManager * GetMasterRunManager()
const G4Run * GetCurrentRun() 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()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneEndOfEventAction()
virtual ~G4VisCommandSceneEndOfEventAction()
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)
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 &)