197 {
198
200
202 std::istringstream is (newValue);
203 is >> graphicsSystem >> newName;
204
207 std::size_t nSystems = gsl.size ();
208 if (nSystems <= 0) {
210 ed <<
211 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
212 " no graphics systems available."
213 "\n Did you instantiate any in"
214 " YourVisManager::RegisterGraphicsSystems()?";
216 return;
217 }
218 std::size_t iGS;
220 for (iGS = 0; iGS < nSystems; ++iGS) {
221 const auto& gs = gsl[iGS];
222 if (G4StrUtil::icompare(graphicsSystem, gs->GetName()) == 0) {
223 found = true;
224 break;
225 } else {
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) {
230 found = true;
231 break;
232 }
233 }
234 if (found) {
235 break;
236 }
237 }
238 }
239 if (!found) {
240
242 ed <<
243 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
244 "\n Invalid graphics system \""
245 << graphicsSystem
246 << "\" requested."
247 << "\n Candidates are:";
250 return;
251 }
252
253
255 G4int loopCounter = 0;
256 while (!gsl[iGS]->IsUISessionCompatible()) {
257 std::size_t iGSBeingTested = iGS;
258
259 fallback = false;
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) {
266 fallback = true;
267 break;
268 }
269 }
270 if (fallback) {
271 break;
272 }
273 }
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.";
280 return;
281 }
282
283 ++loopCounter;
284 }
285
286
288
290 G4warn <<
"WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
291 "\n Using fallback graphics system: "
292 << pSystem -> GetName ()
293 << " ("
294 << pSystem -> GetNickname ()
295 << ')'
297 }
298
299
301 if (newName == "") {
302 newName = nextName;
303 }
304 if (newName == nextName) fId++;
305
307 std::size_t iScene;
308 for (iScene = 0; iScene < list.size (); ++iScene) {
310 if (sceneHandler -> GetName () == newName) {
312 ed <<
313 "ERROR: Scene handler \"" << newName
314 << "\" already exists.";
316 return;
317 }
318 }
319
320
326 }
327
328
329
332 G4cout <<
"Graphics system set to "
333 << pSystem -> GetName ()
334 << " ("
335 << pSystem -> GetNickname ()
336 << ')'
338 }
339
340
342 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
344 ed <<
345 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
346 " Curious name mismatch."
347 "\n Current name \""
348 <<
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
349 << "\" is not the new name \""
350 << newName
351 << "\".\n Please report to vis coordinator.";
353 return;
354 }
355
357 G4cout <<
"New scene handler \"" << newName <<
"\" created." <<
G4endl;
358
361 if (errorCode) {
363 ed << "sub-command \"/vis/sceneHandler/attach\" failed.";
365 return;
366 }
367 }
368}
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
static G4UImanager * GetUIpointer()
static G4ViewParameters fExistingVP
static G4SceneTreeItem fExistingSceneTree
static G4bool fThereWasAViewer
void PrintAvailableGraphicsSystems(Verbosity, std::ostream &=G4cout) const
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()