53 if (pScene) currentSceneName = pScene -> GetName ();
54 return currentSceneName;
61 fpCommand =
new G4UIcommand (
"/vis/scene/activateModel",
this);
62 fpCommand -> SetGuidance
63 (
"Activate or de-activate model.");
64 fpCommand -> SetGuidance
65 (
"Attempts to match search string to name of model - use unique sub-string.");
66 fpCommand -> SetGuidance
67 (
"Use \"/vis/scene/list\" to see model names.");
68 fpCommand -> SetGuidance
69 (
"If name == \"all\" (default), all models are activated.");
71 parameter =
new G4UIparameter (
"search-string",
's', omitable =
true);
72 parameter -> SetDefaultValue (
"all");
73 fpCommand -> SetParameter (parameter);
74 parameter =
new G4UIparameter (
"activate",
'b', omitable =
true);
75 parameter -> SetDefaultValue (
true);
76 fpCommand -> SetParameter (parameter);
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.";
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);
205G4String 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 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\".";
395 fpCommand -> SetGuidance
396 (
"Accumulate or refresh the viewer for each new run.");
397 fpCommand -> SetGuidance
398 (
"\"accumulate\": viewer accumulates hits, etc., run by run, or");
399 fpCommand -> SetGuidance
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";
483 fpCommand =
new G4UIcommand (
"/vis/scene/list",
this);
484 fpCommand -> SetGuidance (
"Lists scene(s).");
485 fpCommand -> SetGuidance
486 (
"\"help /vis/verbose\" for definition of verbosity.");
488 parameter =
new G4UIparameter (
"scene-name",
's', omitable =
true);
489 parameter -> SetDefaultValue (
"all");
490 fpCommand -> SetParameter (parameter);
491 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
492 parameter -> SetDefaultValue (
"warnings");
493 fpCommand -> SetParameter (parameter);
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 G4cout <<
"No scenes found";
578 G4cout <<
" of name \"" << name <<
"\"";
588 fpCommand =
new G4UIcommand (
"/vis/scene/notifyHandlers",
this);
589 fpCommand -> SetGuidance
590 (
"Notifies scene handlers and forces re-rendering.");
591 fpCommand -> SetGuidance
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.");
600 fpCommand -> SetGuidance
601 (
"The default for <scene-name> is the current scene name.");
602 fpCommand -> SetGuidance
603 (
"This command does not change current scene, scene handler or viewer.");
607 parameter -> SetCurrentAsDefault(
true);
608 fpCommand -> SetParameter (parameter);
611 parameter -> SetDefaultValue(
"refresh");
612 parameter -> SetParameterCandidates(
"r refresh f flush");
613 fpCommand -> SetParameter (parameter);
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 (
"Selects a scene");
781 fpCommand -> SetGuidance
782 (
"Makes the scene current. \"/vis/scene/list\" to see"
783 "\n possible scene names.");
784 fpCommand -> SetParameterName (
"scene-name", omitable =
false);
801 G4int iScene, nScenes = sceneList.size ();
802 for (iScene = 0; iScene < nScenes; iScene++) {
803 if (sceneList [iScene] -> GetName () == selectName)
break;
805 if (iScene >= nScenes) {
807 G4cout <<
"WARNING: Scene \"" << selectName
808 <<
"\" not found - \"/vis/scene/list\" to see possibilities."
815 G4cout <<
"Scene \"" << selectName
816 <<
"\" selected." <<
G4endl;
826 fpCommand -> SetGuidance (
"Prints and draws extents of models in a scene");
843 if (!pCurrentSceneHandler) {
845 G4cout <<
"WARNING: No current scene handler."
851 if (!pCurrentViewer) {
853 G4cout <<
"WARNING: No current viewer."
859 if (!pCurrentScene) {
861 G4cout <<
"WARNING: No current scene."
867 G4cout <<
"\n Run-duration models:";
868 G4int nRunModels = pCurrentScene -> GetRunDurationModelList ().size ();
869 if (nRunModels == 0) {
872 for (
G4int i = 0; i < nRunModels; i++) {
873 if (pCurrentScene -> GetRunDurationModelList()[i].fActive)
875 else G4cout <<
"\n Inactive: ";
876 G4VModel* pModel = pCurrentScene -> GetRunDurationModelList()[i].fpModel;
877 const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
878 G4cout << pModel -> GetGlobalDescription ()
879 <<
"\n" << transformedExtent;
882 G4cout <<
"\n End-of-event models:";
883 G4int nEOEModels = pCurrentScene -> GetEndOfEventModelList ().size ();
884 if (nEOEModels == 0) {
887 for (
G4int i = 0; i < nEOEModels; i++) {
888 if (pCurrentScene -> GetEndOfEventModelList()[i].fActive)
890 else G4cout <<
"\n Inactive: ";
891 G4VModel* pModel = pCurrentScene -> GetEndOfEventModelList()[i].fpModel;
892 const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
893 G4cout << pModel -> GetGlobalDescription ()
894 <<
"\n" << transformedExtent;
897 G4cout <<
"\n End-of-run models:";
898 G4int nEORModels = pCurrentScene -> GetEndOfRunModelList ().size ();
899 if (nEORModels == 0) {
902 for (
G4int i = 0; i < nEORModels; i++) {
903 if (pCurrentScene -> GetEndOfRunModelList()[i].fActive)
905 else G4cout <<
"\n Inactive: ";
906 G4VModel* pModel = pCurrentScene -> GetEndOfRunModelList()[i].fpModel;
907 const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
908 G4cout << pModel -> GetGlobalDescription ()
909 <<
"\n" << transformedExtent;
912 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()
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)
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 &)