73 if (sceneName.length () == 0) {
76 "WARNING: No scene specified. Maybe there are no scenes available"
77 "\n yet. Please create one." <<
G4endl;
86 "ERROR: Current scene handler not defined. Please select or create one."
94 if (sceneList.empty ()) {
97 "ERROR: No valid scenes available yet. Please create one."
103 std::size_t iScene, nScenes = sceneList.size ();
104 for (iScene = 0; iScene < nScenes; ++iScene) {
105 if (sceneList [iScene] -> GetName () == sceneName)
break;
107 if (iScene < nScenes) {
108 G4Scene* pScene = sceneList [iScene];
109 pSceneHandler -> SetScene (pScene);
113 G4VViewer* pViewer = pSceneHandler -> GetCurrentViewer();
114 if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) {
115 pViewer -> SetView ();
116 pViewer -> ClearView ();
117 pViewer -> DrawView ();
120 G4cout <<
"Scene \"" << sceneName
121 <<
"\" attached to scene handler \""
122 << pSceneHandler -> GetName () <<
123 ".\n (You may have to refresh with \"/vis/viewer/flush\" if view"
124 " is not \"auto-refresh\".)"
130 G4warn <<
"ERROR: Scene \"" << sceneName
131 <<
"\" not found. Use \"/vis/scene/list\" to see possibilities."
141 fpCommand =
new G4UIcommand (
"/vis/sceneHandler/create",
this);
142 fpCommand -> SetGuidance
143 (
"Creates an scene handler for a specific graphics system.");
144 fpCommand -> SetGuidance
145 (
"Attaches current scene, if any. (You can change attached scenes with"
146 "\n\"/vis/sceneHandler/attach\".) Invents a scene handler name if not"
147 "\nsupplied. This scene handler becomes current.");
149 parameter =
new G4UIparameter (
"graphics-system-name",
's', omitable =
true);
150 parameter -> SetCurrentAsDefault(
true);
154 for (
const auto gs: gslist) {
155 const G4String& name = gs -> GetName ();
156 candidates += name +
' ';
157 for (
const auto& nickname: gs -> GetNicknames ()) {
158 if (G4StrUtil::contains(nickname,
"FALLBACK"))
continue;
159 if (nickname != name) candidates += nickname +
' ';
162 G4StrUtil::strip(candidates);
163 parameter -> SetParameterCandidates(candidates);
164 fpCommand -> SetParameter (parameter);
166 (
"scene-handler-name",
's', omitable =
true);
167 parameter -> SetCurrentAsDefault (
true);
168 fpCommand -> SetParameter (parameter);
202 std::istringstream is (newValue);
203 is >> graphicsSystem >> newName;
207 std::size_t nSystems = gsl.size ();
211 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
212 " no graphics systems available."
213 "\n Did you instantiate any in"
214 " YourVisManager::RegisterGraphicsSystems()?";
220 for (iGS = 0; iGS < nSystems; ++iGS) {
221 const auto& gs = gsl[iGS];
222 if (G4StrUtil::icompare(graphicsSystem, gs->GetName()) == 0) {
226 const auto& nicknames = gs->GetNicknames();
227 for (std::size_t i = 0; i < nicknames.size(); ++i) {
228 const auto& nickname = nicknames[i];
229 if (G4StrUtil::icompare(graphicsSystem, nickname) == 0) {
243 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
244 "\n Invalid graphics system \""
247 <<
"\n Candidates are:";
255 G4int loopCounter = 0;
256 while (!gsl[iGS]->IsUISessionCompatible()) {
257 std::size_t iGSBeingTested = iGS;
260 G4String fallbackNickname = gsl[iGS]->GetNickname() +
"_FALLBACK";
261 for (iGS = 0; iGS < nSystems; iGS++) {
262 const auto& nicknames = gsl[iGS]->GetNicknames();
263 for (std::size_t i = 0; i < nicknames.size(); ++i) {
264 const auto& nickname = nicknames[i];
265 if (G4StrUtil::icompare(fallbackNickname, nickname) == 0) {
274 if (iGS >= nSystems || loopCounter >=3) {
276 ed <<
"\"" << gsl[iGSBeingTested]->GetNickname()
277 <<
"\" is not compatible with your chosen session,"
278 " and no fallback system found.";
290 G4warn <<
"WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
291 "\n Using fallback graphics system: "
292 << pSystem -> GetName ()
294 << pSystem -> GetNickname ()
304 if (newName == nextName) fId++;
308 for (iScene = 0; iScene < list.size (); ++iScene) {
310 if (sceneHandler -> GetName () == newName) {
313 "ERROR: Scene handler \"" << newName
314 <<
"\" already exists.";
332 G4cout <<
"Graphics system set to "
333 << pSystem -> GetName ()
335 << pSystem -> GetNickname ()
342 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
345 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
346 " Curious name mismatch."
348 <<
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
349 <<
"\" is not the new name \""
351 <<
"\".\n Please report to vis coordinator.";
357 G4cout <<
"New scene handler \"" << newName <<
"\" created." <<
G4endl;
363 ed <<
"sub-command \"/vis/sceneHandler/attach\" failed.";
398 std::istringstream is (newValue);
399 is >> name >> verbosityString;
405 if (currentSceneHandler) currentName = currentSceneHandler->
GetName();
409 for (std::size_t iSH = 0; iSH < list.size (); ++iSH) {
410 const G4String& iName = list [iSH] -> GetName ();
412 if (name != iName)
continue;
415 if (iName == currentName) {
421 G4cout <<
" scene handler \"" << list [iSH] -> GetName () <<
"\""
422 <<
" (" << list [iSH] -> GetGraphicsSystem () -> GetName () <<
")";
424 G4cout <<
"\n " << *(list [iSH]);
429 G4cout <<
"No scene handlers found";
431 G4cout <<
" of name \"" << name <<
"\"";