52 if (pScene) currentSceneName = pScene -> GetName ();
53 return currentSceneName;
62 (
"Activate or de-activate model.");
64 (
"Attempts to match search string to name of model - use unique sub-string.");
66 (
"Use \"/vis/scene/list\" to see model names.");
68 (
"If name == \"all\" (default), all models are activated.");
70 parameter =
new G4UIparameter (
"search-string",
's', omitable =
true);
71 parameter -> SetDefaultValue (
"all");
73 parameter =
new G4UIparameter (
"activate",
'b', omitable =
true);
74 parameter -> SetDefaultValue (
true);
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 ();
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 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\"."
330 "ERROR: unrecognised parameter \"" << action <<
"\"."
340 size_t nCurrentlyKept = 0;
345 const std::vector<const G4Event*>* events =
347 if (events) nCurrentlyKept = events->size();
352 G4cout <<
"End of event action set to ";
355 G4cout <<
"\"accumulate\"."
356 "\n Maximum number of events to be kept: "
357 << maxNumberOfKeptEvents
358 <<
" (unlimited if negative)."
359 "\n This may be changed with, e.g., "
360 "\"/vis/scene/endOfEventAction accumulate 1000\".";
366 maxNumberOfKeptEvents != 0 &&
369 if (nCurrentlyKept) {
371 "\n There are currently " << nCurrentlyKept
372 <<
" events kept for refreshing and/or reviewing.";
374 G4cout <<
"The vis manager will keep ";
375 if (maxNumberOfKeptEvents < 0)
G4cout <<
"an unlimited number of";
376 else G4cout <<
"up to " << maxNumberOfKeptEvents;
378 if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
380 "\n This may use a lot of memory."
381 "\n It may be changed with, e.g., "
382 "\"/vis/scene/endOfEventAction accumulate 10\".";
394 (
"Accumulate or refresh the viewer for each new run.");
396 (
"\"accumulate\": viewer accumulates hits, etc., run by run, or");
398 (
"\"refresh\": viewer shows them at end of run or, for direct-screen"
399 "\n viewers, refreshes the screen just before drawing the first"
400 "\n event of the next run.");
401 fpCommand -> SetGuidance (
"The detector remains or is redrawn.");
402 fpCommand -> SetParameterName (
"action", omitable =
true);
403 fpCommand -> SetCandidates (
"accumulate refresh");
404 fpCommand -> SetDefaultValue (
"refresh");
421 std::istringstream is (newValue);
427 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
433 if (!pSceneHandler) {
435 G4cout <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
440 if (action ==
"accumulate") {
444 "ERROR: Cannot accumulate runs unless events accumulate too."
445 "\n Use \"/vis/scene/endOfEventAction accumulate\"."
453 else if (action ==
"refresh") {
460 "ERROR: unrecognised parameter \"" << action <<
"\"."
470 G4cout <<
"End of run action set to \"";
472 else G4cout <<
"accumulate";
482 fpCommand -> SetGuidance (
"Lists scene(s).");
484 (
"\"help /vis/verbose\" for definition of verbosity.");
486 parameter =
new G4UIparameter (
"scene-name",
's', omitable =
true);
487 parameter -> SetDefaultValue (
"all");
489 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
490 parameter -> SetDefaultValue (
"warnings");
504 std::istringstream is (newValue);
505 is >> name >> verbosityString;
510 if (currentScene) currentName = currentScene->
GetName();
513 G4int iScene, nScenes = sceneList.size ();
515 for (iScene = 0; iScene < nScenes; iScene++) {
516 G4Scene* pScene = sceneList [iScene];
517 const G4String& iName = pScene -> GetName ();
519 if (name != iName)
continue;
522 if (iName == currentName) {
528 G4cout <<
" scene \"" << iName <<
"\"";
531 G4cout <<
"\n Run-duration models:";
532 G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
533 if (nRunModels == 0) {
536 for (i = 0; i < nRunModels; i++) {
537 if (pScene -> GetRunDurationModelList()[i].fActive)
539 else G4cout <<
"\n Inactive: ";
540 G4VModel* pModel = pScene -> GetRunDurationModelList()[i].fpModel;
541 G4cout << pModel -> GetGlobalDescription ();
543 G4cout <<
"\n End-of-event models:";
544 G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
545 if (nEOEModels == 0) {
548 for (i = 0; i < nEOEModels; i++) {
549 if (pScene -> GetEndOfEventModelList()[i].fActive)
551 else G4cout <<
"\n Inactive: ";
552 G4VModel* pModel = pScene -> GetEndOfEventModelList()[i].fpModel;
553 G4cout << pModel -> GetGlobalDescription ();
555 G4cout <<
"\n End-of-run models:";
556 G4int nEORModels = pScene -> GetEndOfRunModelList ().size ();
557 if (nEORModels == 0) {
560 for (i = 0; i < nEORModels; i++) {
561 if (pScene -> GetEndOfRunModelList()[i].fActive)
563 else G4cout <<
"\n Inactive: ";
564 G4VModel* pModel = pScene -> GetEndOfRunModelList()[i].fpModel;
565 G4cout << pModel -> GetGlobalDescription ();
569 G4cout <<
"\n " << *sceneList [iScene];
574 G4cout <<
"No scenes found";
576 G4cout <<
" of name \"" << name <<
"\"";
588 (
"Notifies scene handlers and forces re-rendering.");
590 (
"Notifies the handler(s) of the specified scene and forces a"
591 "\nreconstruction of any graphical databases."
592 "\nClears and refreshes all viewers of current scene."
593 "\n The default action \"refresh\" does not issue \"update\" (see"
594 "\n /vis/viewer/update)."
595 "\nIf \"flush\" is specified, it issues an \"update\" as well as"
596 "\n \"refresh\" - \"update\" and initiates post-processing"
597 "\n for graphics systems which need it.");
599 (
"The default for <scene-name> is the current scene name.");
601 (
"This command does not change current scene, scene handler or viewer.");
605 parameter -> SetCurrentAsDefault(
true);
609 parameter -> SetDefaultValue(
"refresh");
610 parameter -> SetParameterCandidates(
"r refresh f flush");
628 std::istringstream is (newValue);
629 is >> sceneName >> refresh_flush;
631 if (refresh_flush(0) ==
'f') flush =
true;
638 const G4int nScenes = sceneList.size ();
640 for (iScene = 0; iScene < nScenes; iScene++) {
641 G4Scene* scene = sceneList [iScene];
642 if (sceneName == scene -> GetName ())
break;
644 if (iScene >= nScenes ) {
646 G4cout <<
"WARNING: Scene \"" << sceneName <<
"\" not found."
647 "\n /vis/scene/list to see scenes."
656 if (!pCurrentSceneHandler) {
658 G4cout <<
"WARNING: No current scene handler."
664 if (!pCurrentViewer) {
666 G4cout <<
"WARNING: No current viewer."
672 if (!pCurrentScene) {
674 G4cout <<
"WARNING: No current scene."
688 const G4int nSceneHandlers = sceneHandlerList.size ();
689 for (
G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
691 G4Scene* aScene = aSceneHandler -> GetScene ();
693 const G4String& aSceneName = aScene -> GetName ();
694 if (sceneName == aSceneName) {
696 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
697 const G4int nViewers = viewerList.size ();
698 for (
G4int iV = 0; iV < nViewers; iV++) {
701 aViewer -> NeedKernelVisit();
703 aSceneHandler -> SetCurrentViewer (aViewer);
708 aViewer -> SetView ();
709 aViewer -> ClearView ();
710 aViewer -> DrawView ();
711 if (flush) aViewer -> ShowView ();
713 G4cout <<
"Viewer \"" << aViewer -> GetName ()
714 <<
"\" of scene handler \"" << aSceneHandler -> GetName ()
716 if (flush)
G4cout <<
"flushed";
717 else G4cout <<
"refreshed";
718 G4cout <<
" at request of scene \"" << sceneName
723 G4cout <<
"NOTE: The scene, \""
725 <<
"\", of viewer \""
726 << aViewer -> GetName ()
727 <<
"\"\n of scene handler \""
728 << aSceneHandler -> GetName ()
729 <<
"\" has changed. To see effect,"
730 <<
"\n \"/vis/viewer/select "
731 << aViewer -> GetShortName ()
732 <<
"\" and \"/vis/viewer/rebuild\"."
741 G4cout <<
"WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
743 <<
"\" has a null scene."
756 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
760 if (pCurrentSceneHandler) {
761 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
762 const G4int nViewers = viewerList.size ();
764 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
765 if (pCurrentViewer && pCurrentSceneHandler->
GetScene()) {
766 pCurrentViewer -> SetView ();
777 fpCommand -> SetGuidance (
"Selects a scene");
779 (
"Makes the scene current. \"/vis/scene/list\" to see"
780 "\n possible scene names.");
781 fpCommand -> SetParameterName (
"scene-name", omitable =
false);
798 G4int iScene, nScenes = sceneList.size ();
799 for (iScene = 0; iScene < nScenes; iScene++) {
800 if (sceneList [iScene] -> GetName () == selectName)
break;
802 if (iScene >= nScenes) {
804 G4cout <<
"WARNING: Scene \"" << selectName
805 <<
"\" not found - \"/vis/scene/list\" to see possibilities."
812 G4cout <<
"Scene \"" << selectName
813 <<
"\" selected." <<
G4endl;
virtual ~G4VisCommandSceneEndOfRunAction()
virtual ~G4VisCommandSceneEndOfEventAction()
G4VisCommandSceneCreate()
G4String GetCurrentValue(G4UIcommand *command)
void UpdateVisManagerScene(const G4String &sceneName="")
G4String GetCurrentValue(G4UIcommand *command)
G4String CurrentSceneName()
const G4ViewParameters & GetViewParameters() const
const G4String & GetName() const
const std::vector< const G4Event * > * GetEventVector() const
G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithAString * fpCommand
std::vector< Model > & SetEndOfRunModelList()
G4bool GetRefreshAtEndOfEvent() const
virtual ~G4VisCommandSceneActivateModel()
G4UIcmdWithAString * fpCommand
const G4String & GetName() const
static Verbosity GetVerbosityValue(const G4String &)
const G4Run * GetCurrentRun() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneActivateModel()
G4GLOB_DLL std::ostream G4cout
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4bool ConvertToBool(const char *st)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VVisCommandScene()
G4String GetCurrentValue(G4UIcommand *command)
void SetMaxNumberOfKeptEvents(G4int)
G4VisCommandSceneNotifyHandlers()
G4bool GetRefreshAtEndOfRun() const
void ResetTransientsDrawnFlags()
G4UIcmdWithAString * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4RunManager * GetRunManager()
G4Scene * GetScene() const
G4String GetCurrentValue(G4UIcommand *command)
std::vector< Model > & SetRunDurationModelList()
std::vector< Model > & SetEndOfEventModelList()
G4VSceneHandler * GetCurrentSceneHandler() const
virtual ~G4VisCommandSceneSelect()
static Verbosity GetVerbosity()
G4VisCommandSceneEndOfEventAction()
G4VisCommandSceneSelect()
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneCreate()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneEndOfRunAction()
virtual ~G4VisCommandSceneNotifyHandlers()
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetRefreshAtEndOfRun(G4bool)
void SetMarkForClearingTransientStore(G4bool)
G4bool IsAutoRefresh() const
G4Scene * GetCurrentScene() const
void SetRefreshAtEndOfEvent(G4bool)
virtual ~G4VisCommandSceneList()
static G4VisManager * fpVisManager