204 {
205
207
209 std::istringstream is (newValue);
210 is >> graphicsSystem >> newName;
211
214 std::size_t nSystems = gsl.size ();
215 if (nSystems <= 0) {
217 ed <<
218 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
219 " no graphics systems available."
220 "\n Did you instantiate any in"
221 " YourVisManager::RegisterGraphicsSystems()?";
223 return;
224 }
225 std::size_t iGS;
227 for (iGS = 0; iGS < nSystems; ++iGS) {
228 const auto& gs = gsl[iGS];
230 found = true;
231 break;
232 } else {
233 const auto& nicknames = gs->GetNicknames();
234 for (std::size_t i = 0; i < nicknames.size(); ++i) {
235 const auto& nickname = nicknames[i];
237 found = true;
238 break;
239 }
240 }
241 if (found) {
242 break;
243 }
244 }
245 }
246 if (!found) {
247
249 ed <<
250 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
251 "\n Invalid graphics system \""
252 << graphicsSystem
253 << "\" requested."
254 << "\n Candidates are:";
257 return;
258 }
259
260
262 G4int loopCounter = 0;
263 while (!gsl[iGS]->IsUISessionCompatible()) {
264 std::size_t iGSBeingTested = iGS;
265
266 fallback = false;
267 G4String fallbackNickname = gsl[iGS]->GetNickname() +
"_FALLBACK";
268 for (iGS = 0; iGS < nSystems; iGS++) {
269 const auto& nicknames = gsl[iGS]->GetNicknames();
270 for (std::size_t i = 0; i < nicknames.size(); ++i) {
271 const auto& nickname = nicknames[i];
273 fallback = true;
274 break;
275 }
276 }
277 if (fallback) {
278 break;
279 }
280 }
281 if (iGS >= nSystems || loopCounter >=3) {
283 ed << "\"" << gsl[iGSBeingTested]->GetNickname()
284 << "\" is not compatible with your chosen session,"
285 " and no fallback system found.";
287 return;
288 }
289
290 ++loopCounter;
291 }
292
293
295
297 G4warn <<
"WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
298 "\n Using fallback graphics system: "
299 << pSystem -> GetName ()
300 << " ("
301 << pSystem -> GetNickname ()
302 << ')'
304 }
305
306
308 if (newName == "") {
309 newName = nextName;
310 }
311 if (newName == nextName) fId++;
312
314 std::size_t iScene;
315 for (iScene = 0; iScene < list.size (); ++iScene) {
317 if (sceneHandler -> GetName () == newName) {
319 ed <<
320 "ERROR: Scene handler \"" << newName
321 << "\" already exists.";
323 return;
324 }
325 }
326
327
331 }
332
333
334
337 G4cout <<
"Graphics system set to "
338 << pSystem -> GetName ()
339 << " ("
340 << pSystem -> GetNickname ()
341 << ')'
343 }
344
345
347 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
349 ed <<
350 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
351 " Curious name mismatch."
352 "\n Current name \""
353 <<
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
354 << "\" is not the new name \""
355 << newName
356 << "\".\n Please report to vis coordinator.";
358 return;
359 }
360
362 G4cout <<
"New scene handler \"" << newName <<
"\" created." <<
G4endl;
363
366 if (errorCode) {
368 ed << "sub-command \"/vis/sceneHandler/attach\" failed.";
370 return;
371 }
372 }
373}
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
static G4UImanager * GetUIpointer()
const G4ViewParameters & GetViewParameters() const
static G4ViewParameters fExistingVP
static G4bool fThereWasAViewer
void PrintAvailableGraphicsSystems(Verbosity, std::ostream &=G4cout) const
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()
G4int icompare(std::string_view lhs, std::string_view rhs)
Case insensitive comparison of two strings.