36 #ifdef G4MULTITHREADED
55 if (pScene) currentSceneName = pScene -> GetName ();
56 return currentSceneName;
65 (
"Activate or de-activate model.");
67 (
"Attempts to match search string to name of model - use unique sub-string.");
69 (
"Use \"/vis/scene/list\" to see model names.");
71 (
"If name == \"all\" (default), all models are activated.");
73 parameter =
new G4UIparameter (
"search-string",
's', omitable =
true);
74 parameter -> SetDefaultValue (
"all");
76 parameter =
new G4UIparameter (
"activate",
'b', omitable =
true);
77 parameter -> SetDefaultValue (
true);
94 G4String searchString, activateString;
95 std::istringstream is (newValue);
96 is >> searchString >> activateString;
102 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
108 if (!pSceneHandler) {
110 G4cerr <<
"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 G4cout <<
"Model \"" << modelName;
138 if (activate)
G4cout <<
"\" activated.";
139 else G4cout <<
"\" 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 G4cout <<
"Model \"" << modelName;
156 if (activate)
G4cout <<
"\" activated.";
157 else G4cout <<
"\" 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 G4cout <<
"Model \"" << modelName;
174 if (activate)
G4cout <<
"\" activated.";
175 else G4cout <<
"\" de-activated.";
188 const G4String& currentSceneName = pScene -> GetName ();
198 (
"Creates an empty scene.");
200 (
"Invents a name if not supplied. This scene becomes current.");
201 fpCommand -> SetParameterName (
"scene-name", omitable =
true);
209 std::ostringstream oss;
210 oss <<
"scene-" <<
fId;
228 if (newName == nextName)
fId++;
231 G4int iScene, nScenes = sceneList.size ();
232 for (iScene = 0; iScene < nScenes; iScene++) {
233 if (sceneList [iScene] -> GetName () == newName)
break;
235 if (iScene < nScenes) {
237 G4cout <<
"WARNING: Scene \"" << newName <<
"\" already exists."
238 <<
"\n New scene not created."
245 sceneList.push_back (pScene);
249 G4cout <<
"New empty scene \"" << newName <<
"\" created." <<
G4endl;
260 (
"Accumulate or refresh the viewer for each new event.");
262 (
"\"accumulate\": viewer accumulates hits, etc., event by event, or");
264 (
"\"refresh\": viewer shows them at end of event or, for direct-screen"
265 "\n viewers, refreshes the screen just before drawing the next event.");
267 parameter =
new G4UIparameter (
"action",
's', omitable =
true);
268 parameter -> SetParameterCandidates (
"accumulate refresh");
269 parameter -> SetDefaultValue (
"refresh");
271 parameter =
new G4UIparameter (
"maxNumber",
'i', omitable =
true);
272 parameter -> SetDefaultValue (100);
273 parameter -> SetGuidance
274 (
"Maximum number of events kept. Unlimited if negative.");
292 G4int maxNumberOfKeptEvents;
293 std::istringstream is (newValue);
294 is >> action >> maxNumberOfKeptEvents;
299 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
305 if (!pSceneHandler) {
307 G4cerr <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
312 if (action ==
"accumulate") {
316 else if (action ==
"refresh") {
320 "ERROR: Cannot refresh events unless runs refresh too."
321 "\n Use \"/vis/scene/endOfRun refresh\"."
333 "ERROR: unrecognised parameter \"" << action <<
"\"."
343 size_t nCurrentlyKept = 0;
345 #ifdef G4MULTITHREADED
352 const std::vector<const G4Event*>* events =
354 if (events) nCurrentlyKept = events->size();
359 G4cout <<
"End of event action set to ";
362 G4cout <<
"\"accumulate\"."
363 "\n Maximum number of events to be kept: "
364 << maxNumberOfKeptEvents
365 <<
" (unlimited if negative)."
366 "\n This may be changed with, e.g., "
367 "\"/vis/scene/endOfEventAction accumulate 1000\".";
373 maxNumberOfKeptEvents != 0 &&
376 if (nCurrentlyKept) {
378 "\n There are currently " << nCurrentlyKept
379 <<
" events kept for refreshing and/or reviewing.";
381 G4cout <<
"The vis manager will keep ";
382 if (maxNumberOfKeptEvents < 0)
G4cout <<
"an unlimited number of";
383 else G4cout <<
"up to " << maxNumberOfKeptEvents;
385 if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
387 "\n This may use a lot of memory."
388 "\n It may be changed with, e.g., "
389 "\"/vis/scene/endOfEventAction accumulate 10\".";
401 (
"Accumulate or refresh the viewer for each new run.");
403 (
"\"accumulate\": viewer accumulates hits, etc., run by run, or");
405 (
"\"refresh\": viewer shows them at end of run or, for direct-screen"
406 "\n viewers, refreshes the screen just before drawing the first"
407 "\n event of the next run.");
408 fpCommand -> SetGuidance (
"The detector remains or is redrawn.");
409 fpCommand -> SetParameterName (
"action", omitable =
true);
410 fpCommand -> SetCandidates (
"accumulate refresh");
411 fpCommand -> SetDefaultValue (
"refresh");
428 std::istringstream is (newValue);
434 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
440 if (!pSceneHandler) {
442 G4cerr <<
"ERROR: No current sceneHandler. Please create one." <<
G4endl;
447 if (action ==
"accumulate") {
451 "ERROR: Cannot accumulate runs unless events accumulate too."
452 "\n Use \"/vis/scene/endOfEventAction accumulate\"."
460 else if (action ==
"refresh") {
467 "ERROR: unrecognised parameter \"" << action <<
"\"."
477 G4cout <<
"End of run action set to \"";
479 else G4cout <<
"accumulate";
489 fpCommand -> SetGuidance (
"Lists scene(s).");
491 (
"\"help /vis/verbose\" for definition of verbosity.");
493 parameter =
new G4UIparameter (
"scene-name",
's', omitable =
true);
494 parameter -> SetDefaultValue (
"all");
496 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
497 parameter -> SetDefaultValue (
"warnings");
511 std::istringstream is (newValue);
512 is >> name >> verbosityString;
517 if (currentScene) currentName = currentScene->
GetName();
520 G4int iScene, nScenes = sceneList.size ();
522 for (iScene = 0; iScene < nScenes; iScene++) {
523 G4Scene* pScene = sceneList [iScene];
524 const G4String& iName = pScene -> GetName ();
526 if (name != iName)
continue;
529 if (iName == currentName) {
535 G4cout <<
" scene \"" << iName <<
"\"";
538 G4cout <<
"\n Run-duration models:";
539 G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
540 if (nRunModels == 0) {
543 for (i = 0; i < nRunModels; i++) {
544 if (pScene -> GetRunDurationModelList()[i].fActive)
546 else G4cout <<
"\n Inactive: ";
547 G4VModel* pModel = pScene -> GetRunDurationModelList()[i].fpModel;
548 G4cout << pModel -> GetGlobalDescription ();
550 G4cout <<
"\n End-of-event models:";
551 G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
552 if (nEOEModels == 0) {
555 for (i = 0; i < nEOEModels; i++) {
556 if (pScene -> GetEndOfEventModelList()[i].fActive)
558 else G4cout <<
"\n Inactive: ";
559 G4VModel* pModel = pScene -> GetEndOfEventModelList()[i].fpModel;
560 G4cout << pModel -> GetGlobalDescription ();
562 G4cout <<
"\n End-of-run models:";
563 G4int nEORModels = pScene -> GetEndOfRunModelList ().size ();
564 if (nEORModels == 0) {
567 for (i = 0; i < nEORModels; i++) {
568 if (pScene -> GetEndOfRunModelList()[i].fActive)
570 else G4cout <<
"\n Inactive: ";
571 G4VModel* pModel = pScene -> GetEndOfRunModelList()[i].fpModel;
572 G4cout << pModel -> GetGlobalDescription ();
576 G4cout <<
"\n " << *sceneList [iScene];
581 G4cout <<
"No scenes found";
583 G4cout <<
" of name \"" << name <<
"\"";
595 (
"Notifies scene handlers and forces re-rendering.");
597 (
"Notifies the handler(s) of the specified scene and forces a"
598 "\nreconstruction of any graphical databases."
599 "\nClears and refreshes all viewers of current scene."
600 "\n The default action \"refresh\" does not issue \"update\" (see"
601 "\n /vis/viewer/update)."
602 "\nIf \"flush\" is specified, it issues an \"update\" as well as"
603 "\n \"refresh\" - \"update\" and initiates post-processing"
604 "\n for graphics systems which need it.");
606 (
"The default for <scene-name> is the current scene name.");
608 (
"This command does not change current scene, scene handler or viewer.");
612 parameter -> SetCurrentAsDefault(
true);
616 parameter -> SetDefaultValue(
"refresh");
617 parameter -> SetParameterCandidates(
"r refresh f flush");
635 std::istringstream is (newValue);
636 is >> sceneName >> refresh_flush;
638 if (refresh_flush(0) ==
'f') flush =
true;
645 const G4int nScenes = sceneList.size ();
647 for (iScene = 0; iScene < nScenes; iScene++) {
648 G4Scene* scene = sceneList [iScene];
649 if (sceneName == scene -> GetName ())
break;
651 if (iScene >= nScenes ) {
653 G4cout <<
"WARNING: Scene \"" << sceneName <<
"\" not found."
654 "\n /vis/scene/list to see scenes."
663 if (!pCurrentSceneHandler) {
665 G4cout <<
"WARNING: No current scene handler."
671 if (!pCurrentViewer) {
673 G4cout <<
"WARNING: No current viewer."
679 if (!pCurrentScene) {
681 G4cout <<
"WARNING: No current scene."
695 const G4int nSceneHandlers = sceneHandlerList.size ();
696 for (
G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
698 G4Scene* aScene = aSceneHandler -> GetScene ();
700 const G4String& aSceneName = aScene -> GetName ();
701 if (sceneName == aSceneName) {
703 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
704 const G4int nViewers = viewerList.size ();
705 for (
G4int iV = 0; iV < nViewers; iV++) {
708 aViewer -> NeedKernelVisit();
710 aSceneHandler -> SetCurrentViewer (aViewer);
715 aViewer -> SetView ();
716 aViewer -> ClearView ();
717 aViewer -> DrawView ();
718 if (flush) aViewer -> ShowView ();
720 G4cout <<
"Viewer \"" << aViewer -> GetName ()
721 <<
"\" of scene handler \"" << aSceneHandler -> GetName ()
723 if (flush)
G4cout <<
"flushed";
724 else G4cout <<
"refreshed";
725 G4cout <<
" at request of scene \"" << sceneName
730 G4cout <<
"NOTE: The scene, \""
732 <<
"\", of viewer \""
733 << aViewer -> GetName ()
734 <<
"\"\n of scene handler \""
735 << aSceneHandler -> GetName ()
736 <<
"\" has changed. To see effect,"
737 <<
"\n \"/vis/viewer/select "
738 << aViewer -> GetShortName ()
739 <<
"\" and \"/vis/viewer/rebuild\"."
748 G4cout <<
"WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
750 <<
"\" has a null scene."
763 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
767 if (pCurrentSceneHandler) {
768 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
769 const G4int nViewers = viewerList.size ();
771 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
772 if (pCurrentViewer && pCurrentSceneHandler->
GetScene()) {
773 pCurrentViewer -> SetView ();
784 fpCommand -> SetGuidance (
"Selects a scene");
786 (
"Makes the scene current. \"/vis/scene/list\" to see"
787 "\n possible scene names.");
788 fpCommand -> SetParameterName (
"scene-name", omitable =
false);
805 G4int iScene, nScenes = sceneList.size ();
806 for (iScene = 0; iScene < nScenes; iScene++) {
807 if (sceneList [iScene] -> GetName () == selectName)
break;
809 if (iScene >= nScenes) {
811 G4cout <<
"WARNING: Scene \"" << selectName
812 <<
"\" not found - \"/vis/scene/list\" to see possibilities."
819 G4cout <<
"Scene \"" << selectName
820 <<
"\" 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)
static G4MTRunManager * GetMasterRunManager()
G4VisCommandSceneNotifyHandlers()
G4bool GetRefreshAtEndOfRun() const
void ResetTransientsDrawnFlags()
G4UIcmdWithAString * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
G4bool IsMultithreadedApplication()
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)
G4GLOB_DLL std::ostream G4cerr
virtual ~G4VisCommandSceneList()
static G4VisManager * fpVisManager