45 G4bool omitable, currentAsDefault;
47 fpCommand -> SetGuidance (
"Attaches scene to current scene handler.");
48 fpCommand -> SetGuidance
49 (
"If scene-name is omitted, current scene is attached. To see scenes and"
50 "\nscene handlers, use \"/vis/scene/list\" and \"/vis/sceneHandler/list\"");
51 fpCommand -> SetParameterName (
"scene-name",
53 currentAsDefault =
true);
62 return pScene ? pScene -> GetName () :
G4String(
"");
72 if (sceneName.length () == 0) {
75 "WARNING: No scene specified. Maybe there are no scenes available"
76 "\n yet. Please create one." <<
G4endl;
85 "ERROR: Current scene handler not defined. Please select or create one."
93 if (sceneList.empty ()) {
96 "ERROR: No valid scenes available yet. Please create one."
102 G4int iScene, nScenes = sceneList.size ();
103 for (iScene = 0; iScene < nScenes; iScene++) {
104 if (sceneList [iScene] -> GetName () == sceneName)
break;
106 if (iScene < nScenes) {
107 G4Scene* pScene = sceneList [iScene];
108 pSceneHandler -> SetScene (pScene);
112 G4VViewer* pViewer = pSceneHandler -> GetCurrentViewer();
113 if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) {
114 pViewer -> SetView ();
115 pViewer -> ClearView ();
116 pViewer -> DrawView ();
119 G4cout <<
"Scene \"" << sceneName
120 <<
"\" attached to scene handler \""
121 << pSceneHandler -> GetName () <<
122 ".\n (You may have to refresh with \"/vis/viewer/flush\" if view"
123 " is not \"auto-refresh\".)"
129 G4cerr <<
"ERROR: Scene \"" << sceneName
130 <<
"\" not found. Use \"/vis/scene/list\" to see possibilities."
140 fpCommand =
new G4UIcommand (
"/vis/sceneHandler/create",
this);
141 fpCommand -> SetGuidance
142 (
"Creates an scene handler for a specific graphics system.");
143 fpCommand -> SetGuidance
144 (
"Attaches current scene, if any. (You can change attached scenes with"
145 "\n\"/vis/sceneHandler/attach\".) Invents a scene handler name if not"
146 "\nsupplied. This scene handler becomes current.");
149 's', omitable =
false);
153 for (
const auto gs: gslist) {
155 candidates += name +
' ';
156 for (
const auto& nickname: gs -> GetNicknames ()) {
157 if (nickname != name) candidates += nickname +
' ';
160 candidates = candidates.
strip ();
161 parameter -> SetParameterCandidates(candidates);
162 fpCommand -> SetParameter (parameter);
164 (
"scene-handler-name",
's', omitable =
true);
165 parameter -> SetCurrentAsDefault (
true);
166 fpCommand -> SetParameter (parameter);
173 G4String G4VisCommandSceneHandlerCreate::NextName () {
174 std::ostringstream oss;
175 oss <<
"scene-handler-" << fId;
184 if (graphicsSystem) {
185 graphicsSystemName = graphicsSystem -> GetName ();
190 if (gslist.size ()) {
191 graphicsSystemName = gslist [0] -> GetName ();
194 graphicsSystemName =
"none";
198 return graphicsSystemName +
" " + NextName ();
207 std::istringstream is (newValue);
208 is >> graphicsSystem >> newName;
212 G4int nSystems = gsl.size ();
215 G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
216 " no graphics systems available."
217 "\n Did you instantiate any in"
218 " YourVisManager::RegisterGraphicsSystems()?"
225 for (iGS = 0; iGS < nSystems; iGS++) {
226 const auto& gs = gsl[iGS];
231 const auto& nicknames = gs->GetNicknames();
232 for (
size_t i = 0; i < nicknames.size(); ++i) {
233 const auto& nickname = nicknames[i];
249 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
250 "\n invalid graphics system \""
260 while (!gsl[iGS]->IsUISessionCompatible()) {
263 G4String fallbackNickname = gsl[iGS]->GetNickname() +
"_FALLBACK";
264 for (iGS = 0; iGS < nSystems; iGS++) {
265 const auto& nicknames = gsl[iGS]->GetNicknames();
266 for (
size_t i = 0; i < nicknames.size(); ++i) {
267 const auto& nickname = nicknames[i];
277 if (iGS < 0 || iGS >= nSystems) {
280 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
281 " could not find fallback graphics system for \""
295 G4cout <<
"WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
296 "\n Using fallback graphics system: "
297 << pSystem -> GetName ()
299 << pSystem -> GetNickname ()
308 G4cout <<
"Graphics system set to "
309 << pSystem -> GetName ()
311 << pSystem -> GetNickname ()
321 if (newName == nextName) fId++;
325 for (iScene = 0; iScene < list.size (); iScene++) {
327 if (sceneHandler -> GetName () == newName) {
329 G4cerr <<
"ERROR: Scene handler \"" << newName
330 <<
"\" already exists." <<
G4endl;
338 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
340 G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
341 " Curious name mismatch."
343 <<
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
344 <<
"\" is not the new name \""
346 <<
"\".\n Please report to vis coordinator."
353 G4cout <<
"New scene handler \"" << newName <<
"\" created." <<
G4endl;
365 fpCommand =
new G4UIcommand (
"/vis/sceneHandler/list",
this);
366 fpCommand -> SetGuidance (
"Lists scene handler(s).");
367 fpCommand -> SetGuidance
368 (
"\"help /vis/verbose\" for definition of verbosity.");
370 parameter =
new G4UIparameter(
"scene-handler-name",
's', omitable =
true);
371 parameter -> SetDefaultValue (
"all");
372 fpCommand -> SetParameter (parameter);
373 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
374 parameter -> SetDefaultValue (
"warnings");
375 fpCommand -> SetParameter (parameter);
389 std::istringstream is (newValue);
390 is >> name >> verbosityString;
396 if (currentSceneHandler) currentName = currentSceneHandler->
GetName();
400 for (
size_t iSH = 0; iSH < list.size (); iSH++) {
401 const G4String& iName = list [iSH] -> GetName ();
403 if (name != iName)
continue;
406 if (iName == currentName) {
412 G4cout <<
" scene handler \"" << list [iSH] -> GetName () <<
"\""
413 <<
" (" << list [iSH] -> GetGraphicsSystem () -> GetName () <<
")";
415 G4cout <<
"\n " << *(list [iSH]);
420 G4cout <<
"No scene handlers found";
422 G4cout <<
" of name \"" << name <<
"\"";
433 fpCommand -> SetGuidance (
"Selects a scene handler.");
434 fpCommand -> SetGuidance
435 (
"Makes the scene handler current. \"/vis/sceneHandler/list\" to see"
436 "\n possible scene handler names.");
437 fpCommand -> SetParameterName (
"scene-handler-name",
458 for (iSH = 0; iSH < list.size (); iSH++) {
459 if (list [iSH] -> GetName () == selectName)
break;
461 if (iSH < list.size ()) {
462 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
465 G4cout <<
"Scene handler \"" << selectName <<
"\""
466 <<
" already selected." <<
G4endl;
471 G4cout <<
"Scene handler \"" << selectName <<
"\""
472 <<
" being selected." <<
G4endl;
479 G4cerr <<
"ERROR: Scene handler \"" << selectName <<
"\""
480 <<
" not found - \"/vis/sceneHandler/list\" to see possibilities."
~G4VisCommandSceneHandlerAttach()
G4String strip(G4int strip_Type=trailing, char c=' ')
const G4String & GetName() const
static Verbosity GetVerbosityValue(const G4String &)
static G4UImanager * GetUIpointer()
G4String GetCurrentValue(G4UIcommand *command)
~G4VisCommandSceneHandlerCreate()
~G4VisCommandSceneHandlerSelect()
G4GLOB_DLL std::ostream G4cout
G4VisCommandSceneHandlerCreate()
G4VisCommandSceneHandlerList()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneHandlerAttach()
G4VisCommandSceneHandlerSelect()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
static Verbosity GetVerbosity()
G4int compareTo(const char *, caseCompare mode=exact) const
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
~G4VisCommandSceneHandlerList()
G4GLOB_DLL std::ostream G4cerr
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4VisManager * fpVisManager