44 G4bool omitable, currentAsDefault;
46 fpCommand -> SetGuidance (
"Attaches scene to current scene handler.");
48 (
"If scene-name is omitted, current scene is attached. To see scenes and"
49 "\nscene handlers, use \"/vis/scene/list\" and \"/vis/sceneHandler/list\"");
50 fpCommand -> SetParameterName (
"scene-name",
52 currentAsDefault =
true);
61 return pScene ? pScene -> GetName () :
G4String(
"");
71 if (sceneName.length () == 0) {
74 "WARNING: No scene specified. Maybe there are no scenes available"
75 "\n yet. Please create one." <<
G4endl;
84 "ERROR: Current scene handler not defined. Please select or create one."
92 if (sceneList.empty ()) {
95 "ERROR: No valid scenes available yet. Please create one."
101 G4int iScene, nScenes = sceneList.size ();
102 for (iScene = 0; iScene < nScenes; iScene++) {
103 if (sceneList [iScene] -> GetName () == sceneName)
break;
105 if (iScene < nScenes) {
106 G4Scene* pScene = sceneList [iScene];
107 pSceneHandler -> SetScene (pScene);
111 G4VViewer* pViewer = pSceneHandler -> GetCurrentViewer();
112 if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) {
113 pViewer -> SetView ();
114 pViewer -> ClearView ();
115 pViewer -> DrawView ();
118 G4cout <<
"Scene \"" << sceneName
119 <<
"\" attached to scene handler \""
120 << pSceneHandler -> GetName () <<
121 ".\n (You may have to refresh with \"/vis/viewer/flush\" if view"
122 " is not \"auto-refresh\".)"
128 G4cerr <<
"ERROR: Scene \"" << sceneName
129 <<
"\" not found. Use \"/vis/scene/list\" to see possibilities."
141 (
"Creates an scene handler for a specific graphics system.");
143 (
"Attaches current scene, if any. (You can change attached scenes with"
144 "\n\"/vis/sceneHandler/attach\".) Invents a scene handler name if not"
145 "\nsupplied. This scene handler becomes current.");
148 's', omitable =
false);
152 for (
const auto gs: gslist) {
154 candidates += name +
' ';
155 for (
const auto& nickname: gs -> GetNicknames ()) {
156 if (nickname != name) candidates += nickname +
' ';
159 candidates = candidates.
strip ();
160 parameter -> SetParameterCandidates(candidates);
163 (
"scene-handler-name",
's', omitable =
true);
164 parameter -> SetCurrentAsDefault (
true);
173 std::ostringstream oss;
174 oss <<
"scene-handler-" <<
fId;
183 if (graphicsSystem) {
184 graphicsSystemName = graphicsSystem -> GetName ();
189 if (gslist.size ()) {
190 graphicsSystemName = gslist [0] -> GetName ();
193 graphicsSystemName =
"none";
197 return graphicsSystemName +
" " +
NextName ();
206 std::istringstream is (newValue);
207 is >> graphicsSystem >> newName;
211 G4int nSystems = gsl.size ();
214 G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
215 " no graphics systems available."
216 "\n Did you instantiate any in"
217 " YourVisManager::RegisterGraphicsSystems()?"
224 for (iGS = 0; iGS < nSystems; iGS++) {
225 const auto& gs = gsl[iGS];
230 const auto& nicknames = gs->GetNicknames();
231 for (
size_t i = 0; i < nicknames.size(); ++i) {
232 const auto& nickname = nicknames[i];
248 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
249 "\n invalid graphics system \""
259 while (!gsl[iGS]->IsUISessionCompatible()) {
262 G4String fallbackNickname = gsl[iGS]->GetNickname() +
"_FALLBACK";
263 for (iGS = 0; iGS < nSystems; iGS++) {
264 const auto& nicknames = gsl[iGS]->GetNicknames();
265 for (
size_t i = 0; i < nicknames.size(); ++i) {
266 const auto& nickname = nicknames[i];
276 if (iGS < 0 || iGS >= nSystems) {
279 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
280 " could not find fallback graphics system for \""
294 G4cout <<
"WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
295 "\n Using fallback graphics system: "
296 << pSystem -> GetName ()
298 << pSystem -> GetNickname ()
307 G4cout <<
"Graphics system set to "
308 << pSystem -> GetName ()
310 << pSystem -> GetNickname ()
320 if (newName == nextName)
fId++;
324 for (iScene = 0; iScene < list.size (); iScene++) {
326 if (sceneHandler -> GetName () == newName) {
328 G4cerr <<
"ERROR: Scene handler \"" << newName
329 <<
"\" already exists." <<
G4endl;
337 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
339 G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
340 " Curious name mismatch."
342 <<
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
343 <<
"\" is not the new name \""
345 <<
"\".\n Please report to vis coordinator."
352 G4cout <<
"New scene handler \"" << newName <<
"\" created." <<
G4endl;
365 fpCommand -> SetGuidance (
"Lists scene handler(s).");
367 (
"\"help /vis/verbose\" for definition of verbosity.");
369 parameter =
new G4UIparameter(
"scene-handler-name",
's', omitable =
true);
370 parameter -> SetDefaultValue (
"all");
372 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
373 parameter -> SetDefaultValue (
"warnings");
388 std::istringstream is (newValue);
389 is >> name >> verbosityString;
395 if (currentSceneHandler) currentName = currentSceneHandler->
GetName();
399 for (
size_t iSH = 0; iSH < list.size (); iSH++) {
400 const G4String& iName = list [iSH] -> GetName ();
402 if (name != iName)
continue;
405 if (iName == currentName) {
411 G4cout <<
" scene handler \"" << list [iSH] -> GetName () <<
"\""
412 <<
" (" << list [iSH] -> GetGraphicsSystem () -> GetName () <<
")";
414 G4cout <<
"\n " << *(list [iSH]);
419 G4cout <<
"No scene handlers found";
421 G4cout <<
" of name \"" << name <<
"\"";
432 fpCommand -> SetGuidance (
"Selects a scene handler.");
434 (
"Makes the scene handler current. \"/vis/sceneHandler/list\" to see"
435 "\n possible scene handler names.");
436 fpCommand -> SetParameterName (
"scene-handler-name",
457 for (iSH = 0; iSH < list.size (); iSH++) {
458 if (list [iSH] -> GetName () == selectName)
break;
460 if (iSH < list.size ()) {
461 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
464 G4cout <<
"Scene handler \"" << selectName <<
"\""
465 <<
" already selected." <<
G4endl;
470 G4cout <<
"Scene handler \"" << selectName <<
"\""
471 <<
" being selected." <<
G4endl;
478 G4cerr <<
"ERROR: Scene handler \"" << selectName <<
"\""
479 <<
" not found - \"/vis/sceneHandler/list\" to see possibilities."