Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/management/src/G4VisCommandsSceneHandler.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/management/src/G4VisCommandsSceneHandler.cc (Version 11.3.0) and /visualization/management/src/G4VisCommandsSceneHandler.cc (Version 10.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4VisCommandsSceneHandler.cc 99418 2016-09-21 09:18:42Z gcosmo $
 27                                                    28 
 28 // /vis/sceneHandler commands - John Allison       29 // /vis/sceneHandler commands - John Allison  10th October 1998
 29                                                    30 
 30 #include "G4VisCommandsSceneHandler.hh"            31 #include "G4VisCommandsSceneHandler.hh"
 31                                                    32 
 32 #include "G4VisManager.hh"                         33 #include "G4VisManager.hh"
 33 #include "G4GraphicsSystemList.hh"                 34 #include "G4GraphicsSystemList.hh"
 34 #include "G4VisCommandsScene.hh"                   35 #include "G4VisCommandsScene.hh"
 35 #include "G4UImanager.hh"                          36 #include "G4UImanager.hh"
 36 #include "G4UIcommand.hh"                          37 #include "G4UIcommand.hh"
 37 #include "G4UIcmdWithAString.hh"                   38 #include "G4UIcmdWithAString.hh"
 38 #include "G4ios.hh"                                39 #include "G4ios.hh"
 39 #include <sstream>                                 40 #include <sstream>
 40                                                    41 
 41 #define G4warn G4cout                          << 
 42                                                << 
 43 ////////////// /vis/sceneHandler/attach //////     42 ////////////// /vis/sceneHandler/attach ///////////////////////////////////////
 44                                                    43 
 45 G4VisCommandSceneHandlerAttach::G4VisCommandSc     44 G4VisCommandSceneHandlerAttach::G4VisCommandSceneHandlerAttach () {
 46   G4bool omitable, currentAsDefault;               45   G4bool omitable, currentAsDefault;
 47   fpCommand = new G4UIcmdWithAString ("/vis/sc     46   fpCommand = new G4UIcmdWithAString ("/vis/sceneHandler/attach", this);
 48   fpCommand -> SetGuidance ("Attaches scene to     47   fpCommand -> SetGuidance ("Attaches scene to current scene handler.");
 49   fpCommand -> SetGuidance                         48   fpCommand -> SetGuidance
 50     ("If scene-name is omitted, current scene      49     ("If scene-name is omitted, current scene is attached.  To see scenes and"
 51   "\nscene handlers, use \"/vis/scene/list\" a     50   "\nscene handlers, use \"/vis/scene/list\" and \"/vis/sceneHandler/list\"");
 52   fpCommand -> SetParameterName ("scene-name",     51   fpCommand -> SetParameterName ("scene-name",
 53          omitable = true,                          52          omitable = true,
 54          currentAsDefault = true);                 53          currentAsDefault = true);
 55 }                                                  54 }
 56                                                    55 
 57 G4VisCommandSceneHandlerAttach::~G4VisCommandS     56 G4VisCommandSceneHandlerAttach::~G4VisCommandSceneHandlerAttach () {
 58   delete fpCommand;                                57   delete fpCommand;
 59 }                                                  58 }
 60                                                    59 
 61 G4String G4VisCommandSceneHandlerAttach::GetCu     60 G4String G4VisCommandSceneHandlerAttach::GetCurrentValue (G4UIcommand*) {
 62   G4Scene* pScene = fpVisManager -> GetCurrent     61   G4Scene* pScene = fpVisManager -> GetCurrentScene ();
 63   return pScene ? pScene -> GetName () : G4Str     62   return pScene ? pScene -> GetName () : G4String("");
 64 }                                                  63 }
 65                                                    64 
 66 void G4VisCommandSceneHandlerAttach::SetNewVal     65 void G4VisCommandSceneHandlerAttach::SetNewValue (G4UIcommand*,
 67               G4String newValue) {                 66               G4String newValue) {
 68                                                    67 
 69   G4VisManager::Verbosity verbosity = fpVisMan     68   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
 70                                                    69 
 71   G4String& sceneName = newValue;                  70   G4String& sceneName = newValue;
 72                                                    71 
 73   if (sceneName.length () == 0) {                  72   if (sceneName.length () == 0) {
 74     if (verbosity >= G4VisManager::warnings) {     73     if (verbosity >= G4VisManager::warnings) {
 75       G4cout <<                                    74       G4cout <<
 76   "WARNING: No scene specified.  Maybe there a     75   "WARNING: No scene specified.  Maybe there are no scenes available"
 77   "\n  yet.  Please create one." << G4endl;        76   "\n  yet.  Please create one." << G4endl;
 78     }                                              77     }
 79     return;                                        78     return;
 80   }                                                79   }
 81                                                    80 
 82   G4VSceneHandler* pSceneHandler = fpVisManage     81   G4VSceneHandler* pSceneHandler = fpVisManager -> GetCurrentSceneHandler ();
 83   if (!pSceneHandler) {                            82   if (!pSceneHandler) {
 84     if (verbosity >= G4VisManager::errors) {       83     if (verbosity >= G4VisManager::errors) {
 85       G4warn <<                                <<  84       G4cerr <<
 86       "ERROR: Current scene handler not define     85       "ERROR: Current scene handler not defined.  Please select or create one."
 87        << G4endl;                                  86        << G4endl;
 88     }                                              87     }
 89     return;                                        88     return;
 90   }                                                89   }
 91                                                    90 
 92   G4SceneList& sceneList = fpVisManager -> Set     91   G4SceneList& sceneList = fpVisManager -> SetSceneList ();
 93                                                    92 
 94   if (sceneList.empty ()) {                        93   if (sceneList.empty ()) {
 95     if (verbosity >= G4VisManager::errors) {       94     if (verbosity >= G4VisManager::errors) {
 96       G4warn <<                                <<  95       G4cerr <<
 97       "ERROR: No valid scenes available yet.       96       "ERROR: No valid scenes available yet.  Please create one."
 98        << G4endl;                                  97        << G4endl;
 99     }                                              98     }
100     return;                                        99     return;
101   }                                               100   }
102                                                   101 
103   std::size_t iScene, nScenes = sceneList.size << 102   G4int iScene, nScenes = sceneList.size ();
104   for (iScene = 0; iScene < nScenes; ++iScene) << 103   for (iScene = 0; iScene < nScenes; iScene++) {
105     if (sceneList [iScene] -> GetName () == sc    104     if (sceneList [iScene] -> GetName () == sceneName) break;
106   }                                               105   }
107   if (iScene < nScenes) {                         106   if (iScene < nScenes) {
108     G4Scene* pScene = sceneList [iScene];         107     G4Scene* pScene = sceneList [iScene];
109     pSceneHandler -> SetScene (pScene);           108     pSceneHandler -> SetScene (pScene);
110     // Make sure scene is current...              109     // Make sure scene is current...
111     fpVisManager -> SetCurrentScene (pScene);     110     fpVisManager -> SetCurrentScene (pScene);
112     // Refresh viewer, if any (only if auto-re    111     // Refresh viewer, if any (only if auto-refresh)...
113     G4VViewer* pViewer = pSceneHandler -> GetC    112     G4VViewer* pViewer = pSceneHandler -> GetCurrentViewer();
114     if (pViewer && pViewer -> GetViewParameter    113     if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) {
115       pViewer -> SetView ();                      114       pViewer -> SetView ();
116       pViewer -> ClearView ();                    115       pViewer -> ClearView ();
117       pViewer -> DrawView ();                     116       pViewer -> DrawView ();
118     }                                             117     }
119     if (verbosity >= G4VisManager::confirmatio    118     if (verbosity >= G4VisManager::confirmations) {
120       G4cout << "Scene \"" << sceneName           119       G4cout << "Scene \"" << sceneName
121        << "\" attached to scene handler \""       120        << "\" attached to scene handler \""
122        << pSceneHandler -> GetName () <<          121        << pSceneHandler -> GetName () <<
123   ".\n  (You may have to refresh with \"/vis/v    122   ".\n  (You may have to refresh with \"/vis/viewer/flush\" if view"
124   " is not \"auto-refresh\".)"                    123   " is not \"auto-refresh\".)"
125        << G4endl;                                 124        << G4endl;
126     }                                             125     }
127   }                                               126   }
128   else {                                          127   else {
129     if (verbosity >= G4VisManager::errors) {      128     if (verbosity >= G4VisManager::errors) {
130       G4warn << "ERROR: Scene \"" << sceneName << 129       G4cerr << "ERROR: Scene \"" << sceneName
131        << "\" not found.  Use \"/vis/scene/lis    130        << "\" not found.  Use \"/vis/scene/list\" to see possibilities."
132        << G4endl;                                 131        << G4endl;
133     }                                             132     }
134   }                                               133   }
135 }                                                 134 }
136                                                   135 
137 ////////////// /vis/sceneHandler/create //////    136 ////////////// /vis/sceneHandler/create ///////////////////////////////////////
138                                                   137 
139 G4VisCommandSceneHandlerCreate::G4VisCommandSc    138 G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate (): fId (0) {
140   G4bool omitable;                                139   G4bool omitable;
141   fpCommand = new G4UIcommand ("/vis/sceneHand    140   fpCommand = new G4UIcommand ("/vis/sceneHandler/create", this);
142   fpCommand -> SetGuidance                        141   fpCommand -> SetGuidance
143     ("Creates an scene handler for a specific     142     ("Creates an scene handler for a specific graphics system.");
144   fpCommand -> SetGuidance                        143   fpCommand -> SetGuidance
145     ("Attaches current scene, if any.  (You ca    144     ("Attaches current scene, if any.  (You can change attached scenes with"
146      "\n\"/vis/sceneHandler/attach\".)  Invent    145      "\n\"/vis/sceneHandler/attach\".)  Invents a scene handler name if not"
147      "\nsupplied.  This scene handler becomes     146      "\nsupplied.  This scene handler becomes current.");
148   G4UIparameter* parameter;                       147   G4UIparameter* parameter;
149   parameter = new G4UIparameter ("graphics-sys << 148   parameter = new G4UIparameter ("graphics-system-name",
150   parameter -> SetCurrentAsDefault(true);      << 149          's', omitable = false);
151   const G4GraphicsSystemList& gslist =            150   const G4GraphicsSystemList& gslist =
152   fpVisManager -> GetAvailableGraphicsSystems  << 151     fpVisManager -> GetAvailableGraphicsSystems ();
153   G4String candidates = "NO_UI_SESSION ";  //  << 152   G4String candidates;
154   for (const auto gs: gslist) {                   153   for (const auto gs: gslist) {
155     const G4String& name = gs -> GetName ();      154     const G4String& name = gs -> GetName ();
156     candidates += name + ' ';                     155     candidates += name + ' ';
157     for (const auto& nickname: gs -> GetNickna    156     for (const auto& nickname: gs -> GetNicknames ()) {
158       if (G4StrUtil::contains(nickname, "FALLB << 
159       if (nickname != name) candidates += nick    157       if (nickname != name) candidates += nickname + ' ';
160     }                                             158     }
161   }                                               159   }
162   G4StrUtil::strip(candidates);                << 160   candidates = candidates.strip ();
163   parameter -> SetParameterCandidates(candidat    161   parameter -> SetParameterCandidates(candidates);
164   fpCommand -> SetParameter (parameter);          162   fpCommand -> SetParameter (parameter);
165   parameter = new G4UIparameter                   163   parameter = new G4UIparameter
166     ("scene-handler-name", 's', omitable = tru    164     ("scene-handler-name", 's', omitable = true);
167   parameter -> SetCurrentAsDefault (true);        165   parameter -> SetCurrentAsDefault (true);
168   fpCommand -> SetParameter (parameter);          166   fpCommand -> SetParameter (parameter);
169 }                                                 167 }
170                                                   168 
171 G4VisCommandSceneHandlerCreate::~G4VisCommandS    169 G4VisCommandSceneHandlerCreate::~G4VisCommandSceneHandlerCreate () {
172   delete fpCommand;                               170   delete fpCommand;
173 }                                                 171 }
174                                                   172 
175 G4String G4VisCommandSceneHandlerCreate::NextN    173 G4String G4VisCommandSceneHandlerCreate::NextName () {
176   std::ostringstream oss;                         174   std::ostringstream oss;
177   oss << "scene-handler-" << fId;                 175   oss << "scene-handler-" << fId;
178   return oss.str();                               176   return oss.str();
179 }                                                 177 }
180                                                   178 
181 G4String G4VisCommandSceneHandlerCreate::GetCu    179 G4String G4VisCommandSceneHandlerCreate::GetCurrentValue(G4UIcommand*) {
182                                                   180 
183   G4String graphicsSystemName;                    181   G4String graphicsSystemName;
184   const G4VGraphicsSystem* graphicsSystem =       182   const G4VGraphicsSystem* graphicsSystem =
185     fpVisManager -> GetCurrentGraphicsSystem (    183     fpVisManager -> GetCurrentGraphicsSystem ();
186   if (graphicsSystem) {                           184   if (graphicsSystem) {
187     graphicsSystemName = graphicsSystem -> Get    185     graphicsSystemName = graphicsSystem -> GetName ();
188   }                                               186   }
189   else {                                          187   else {
190     graphicsSystemName = fpVisManager->GetDefa << 188     const G4GraphicsSystemList& gslist =
                                                   >> 189       fpVisManager -> GetAvailableGraphicsSystems ();
                                                   >> 190     if (gslist.size ()) {
                                                   >> 191       graphicsSystemName = gslist [0] -> GetName ();
                                                   >> 192     }
                                                   >> 193     else {
                                                   >> 194       graphicsSystemName = "none";
                                                   >> 195     }
191   }                                               196   }
192                                                   197 
193   return graphicsSystemName + " " + NextName (    198   return graphicsSystemName + " " + NextName ();
194 }                                                 199 }
195                                                   200 
196 void G4VisCommandSceneHandlerCreate::SetNewVal << 201 void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
197               G4String newValue) {                202               G4String newValue) {
198                                                   203 
199   G4VisManager::Verbosity verbosity = fpVisMan    204   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
200                                                   205 
201   G4String graphicsSystem, newName;               206   G4String graphicsSystem, newName;
202   std::istringstream is (newValue);               207   std::istringstream is (newValue);
203   is >> graphicsSystem >> newName;                208   is >> graphicsSystem >> newName;
204                                                   209 
205   const G4GraphicsSystemList& gsl =               210   const G4GraphicsSystemList& gsl =
206     fpVisManager -> GetAvailableGraphicsSystem    211     fpVisManager -> GetAvailableGraphicsSystems ();
207   std::size_t nSystems = gsl.size ();          << 212   G4int nSystems = gsl.size ();
208   if (nSystems <= 0) {                            213   if (nSystems <= 0) {
209     G4ExceptionDescription ed;                 << 214     if (verbosity >= G4VisManager::errors) {
210     ed <<                                      << 215       G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
211     "ERROR: G4VisCommandSceneHandlerCreate::Se << 216   " no graphics systems available."
212     " no graphics systems available."          << 217   "\n  Did you instantiate any in"
213     "\n  Did you instantiate any in"           << 218   " YourVisManager::RegisterGraphicsSystems()?"
214     " YourVisManager::RegisterGraphicsSystems( << 219        << G4endl;
215     command->CommandFailed(ed);                << 220     }
216     return;                                       221     return;
217   }                                               222   }
218   std::size_t iGS;  // Selector index.         << 223   G4int iGS;  // Selector index.
219   G4bool found = false;                           224   G4bool found = false;
220   for (iGS = 0; iGS < nSystems; ++iGS) {       << 225   for (iGS = 0; iGS < nSystems; iGS++) {
221     const auto& gs = gsl[iGS];                    226     const auto& gs = gsl[iGS];
222     if (G4StrUtil::icompare(graphicsSystem, gs << 227     if (graphicsSystem.compareTo(gs->GetName(), G4String::ignoreCase) == 0) {
223       found = true;                               228       found = true;
224       break;  // Match found                      229       break;  // Match found
225     } else {                                      230     } else {
226       const auto& nicknames = gs->GetNicknames    231       const auto& nicknames = gs->GetNicknames();
227       for (std::size_t i = 0; i < nicknames.si << 232       for (size_t i = 0; i < nicknames.size(); ++i) {
228         const auto& nickname = nicknames[i];      233         const auto& nickname = nicknames[i];
229         if (G4StrUtil::icompare(graphicsSystem << 234         if (graphicsSystem.compareTo (nickname, G4String::ignoreCase) == 0) {
230           found = true;                           235           found = true;
231           break;  // Match found                  236           break;  // Match found
232         }                                         237         }
233       }                                           238       }
234       if (found) {                                239       if (found) {
235         break;  // Match found                    240         break;  // Match found
236       }                                           241       }
237     }                                             242     }
238   }                                               243   }
239   if (!found) {                                   244   if (!found) {
240     if (graphicsSystem == "NO_UI_SESSION") {   << 245     // Invalid command line argument or none.
241       G4Exception                              << 246     // This shouldn't happen!!!!!!
242       ("G4VisCommandSceneHandlerCreate::SetNew << 247     if (verbosity >= G4VisManager::errors) {
243        "This looks like an attempt to use run- << 248       G4cerr <<
244        "\nYou have issued \"/vis/open\" or \"/ << 249       "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
245        "\na parameter for the vis driver. This << 250       "\n  invalid graphics system \""
246        "\na UI session, and only if it is inst << 251       << graphicsSystem
247        "\n\"/vis/open\" command. So:"          << 252       << "\" requested."
248        "\na) It is not allowed in batch mode.  << 253       << G4endl;
249        "\n   some graphics with a file-writing << 
250        "\n   request a specific driver on the  << 
251        "\n   \"/vis/open TSG_OFFSCREEN\". See, << 
252        "\nb) If you want to exploit this featu << 
253        "\n   the instantiation of the UI sessi << 
254        "\n   practice in order to capture outp << 
255       return;                                  << 
256     }                                             254     }
257     // Shouldn't happen, since graphicsSystem  << 
258     G4ExceptionDescription ed;                 << 
259     ed <<                                      << 
260     "ERROR: G4VisCommandSceneHandlerCreate::Se << 
261     "\n  Invalid graphics system \""           << 
262     << graphicsSystem                          << 
263     << "\" requested."                         << 
264     << "\n  Candidates are:";                  << 
265     fpVisManager->PrintAvailableGraphicsSystem << 
266     command->CommandFailed(ed);                << 
267     return;                                       255     return;
268   }                                               256   }
269                                                   257 
270   // Check UI session compatibility.              258   // Check UI session compatibility.
271   G4bool fallback = false;                        259   G4bool fallback = false;
272   G4int loopCounter = 0;                       << 
273   while (!gsl[iGS]->IsUISessionCompatible()) {    260   while (!gsl[iGS]->IsUISessionCompatible()) {
274     std::size_t iGSBeingTested = iGS;          << 
275     // Not compatible, search for a fallback      261     // Not compatible, search for a fallback
276     fallback = false;                             262     fallback = false;
277     G4String fallbackNickname = gsl[iGS]->GetN    263     G4String fallbackNickname = gsl[iGS]->GetNickname() + "_FALLBACK";
278     for (iGS = 0; iGS < nSystems; iGS++) {        264     for (iGS = 0; iGS < nSystems; iGS++) {
279       const auto& nicknames = gsl[iGS]->GetNic    265       const auto& nicknames = gsl[iGS]->GetNicknames();
280       for (std::size_t i = 0; i < nicknames.si << 266       for (size_t i = 0; i < nicknames.size(); ++i) {
281         const auto& nickname = nicknames[i];      267         const auto& nickname = nicknames[i];
282         if (G4StrUtil::icompare(fallbackNickna << 268         if (fallbackNickname.compareTo (nickname, G4String::ignoreCase) == 0) {
283           fallback = true;                        269           fallback = true;
284           break;  // Match found                  270           break;  // Match found
285         }                                         271         }
286       }                                           272       }
287       if (fallback) {                             273       if (fallback) {
288         break;  // Match found                    274         break;  // Match found
289       }                                           275       }
290     }                                             276     }
291     if (iGS >= nSystems || loopCounter >=3) {  << 277     if (iGS < 0 || iGS >= nSystems) {
292       G4ExceptionDescription ed;               << 278       if (verbosity >= G4VisManager::errors) {
293       ed << "\"" << gsl[iGSBeingTested]->GetNi << 279         G4cerr <<
294       << "\" is not compatible with the sessio << 280         "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
295       "\nand no fallback system found. Make su << 281         " could not find fallback graphics system for \""
296       "\ninstantiated _before_ you create a gr << 282         << graphicsSystem
297       G4Exception("G4VisCommandSceneHandlerCre << 283         << "\"."
298                   "visman1002", JustWarning, e << 284         << G4endl;
                                                   >> 285       }
299       return;                                     286       return;
300     }                                             287     }
301     //  A fallback system found...but go back     288     //  A fallback system found...but go back and check this too.
302     ++loopCounter;                             << 
303   }                                               289   }
304                                                   290 
305   // A graphics system has been found             291   // A graphics system has been found
306   G4VGraphicsSystem* pSystem = gsl [iGS];         292   G4VGraphicsSystem* pSystem = gsl [iGS];
307                                                   293 
308   if (fallback && verbosity >= G4VisManager::w    294   if (fallback && verbosity >= G4VisManager::warnings) {
309     G4warn << "WARNING: G4VisCommandSceneHandl << 295     G4cout << "WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
310     "\n  Using fallback graphics system: "        296     "\n  Using fallback graphics system: "
311     << pSystem -> GetName ()                      297     << pSystem -> GetName ()
312     << " ("                                       298     << " ("
313     << pSystem -> GetNickname ()                  299     << pSystem -> GetNickname ()
314     << ')'                                        300     << ')'
315     << G4endl;                                    301     << G4endl;
316   }                                               302   }
317                                                   303 
                                                   >> 304   // Set current graphics system in preparation for
                                                   >> 305   // creating scene handler.
                                                   >> 306   fpVisManager -> SetCurrentGraphicsSystem (pSystem);
                                                   >> 307   if (verbosity >= G4VisManager::confirmations) {
                                                   >> 308     G4cout << "Graphics system set to "
                                                   >> 309     << pSystem -> GetName ()
                                                   >> 310     << " ("
                                                   >> 311     << pSystem -> GetNickname ()
                                                   >> 312     << ')'
                                                   >> 313     << G4endl;
                                                   >> 314   }
                                                   >> 315 
318   // Now deal with name of scene handler.         316   // Now deal with name of scene handler.
319   G4String nextName = NextName ();                317   G4String nextName = NextName ();
320   if (newName == "") {                            318   if (newName == "") {
321     newName = nextName;                           319     newName = nextName;
322   }                                               320   }
323   if (newName == nextName) fId++;                 321   if (newName == nextName) fId++;
324                                                   322 
325   const G4SceneHandlerList& list = fpVisManage    323   const G4SceneHandlerList& list = fpVisManager -> GetAvailableSceneHandlers ();
326   std::size_t iScene;                          << 324   size_t iScene;
327   for (iScene = 0; iScene < list.size (); ++iS << 325   for (iScene = 0; iScene < list.size (); iScene++) {
328     G4VSceneHandler* sceneHandler = list [iSce    326     G4VSceneHandler* sceneHandler = list [iScene];
329     if (sceneHandler -> GetName () == newName)    327     if (sceneHandler -> GetName () == newName) {
330       G4ExceptionDescription ed;               << 328       if (verbosity >= G4VisManager::errors) {
331       ed <<                                    << 329   G4cerr << "ERROR: Scene handler \"" << newName
332       "ERROR: Scene handler \"" << newName     << 330          << "\" already exists." << G4endl;
333       << "\" already exists.";                 << 331       }
334       command->CommandFailed(ed);              << 
335       return;                                     332       return;
336     }                                             333     }
337   }                                               334   }
338                                                   335 
339   // If there is an existing viewer, store its << 
340   if (fpVisManager->GetCurrentViewer()) {      << 
341     fThereWasAViewer = true;                   << 
342     auto viewer = fpVisManager->GetCurrentView << 
343     fExistingVP = viewer->GetViewParameters(); << 
344     fExistingSceneTree = viewer->AccessSceneTr << 
345   }                                            << 
346                                                << 
347   // Set current graphics system in preparatio << 
348   // creating scene handler.                   << 
349   fpVisManager -> SetCurrentGraphicsSystem (pS << 
350   if (verbosity >= G4VisManager::confirmations << 
351     G4cout << "Graphics system set to "        << 
352     << pSystem -> GetName ()                   << 
353     << " ("                                    << 
354     << pSystem -> GetNickname ()               << 
355     << ')'                                     << 
356     << G4endl;                                 << 
357   }                                            << 
358                                                << 
359   //Create scene handler.                         336   //Create scene handler.
360   fpVisManager -> CreateSceneHandler (newName)    337   fpVisManager -> CreateSceneHandler (newName);
361   if (fpVisManager -> GetCurrentSceneHandler (    338   if (fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
362     G4ExceptionDescription ed;                 << 339     if (verbosity >= G4VisManager::errors) {
363     ed <<                                      << 340       G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
364     "ERROR: G4VisCommandSceneHandlerCreate::Se << 341   " Curious name mismatch."
365     " Curious name mismatch."                  << 342   "\n Current name \""
366     "\n Current name \""                       << 343        << fpVisManager -> GetCurrentSceneHandler () -> GetName ()
367     << fpVisManager -> GetCurrentSceneHandler  << 344        << "\" is not the new name \""
368     << "\" is not the new name \""             << 345        << newName
369     << newName                                 << 346        << "\".\n  Please report to vis coordinator."
370     << "\".\n  Please report to vis coordinato << 347        << G4endl;
371     command->CommandFailed(ed);                << 348     }
372     return;                                       349     return;
373   }                                               350   }
374                                                   351 
375   if (verbosity >= G4VisManager::confirmations << 352   if (verbosity >= G4VisManager::confirmations) {
376     G4cout << "New scene handler \"" << newNam    353     G4cout << "New scene handler \"" << newName << "\" created." << G4endl;
377                                                << 
378   if (fpVisManager -> GetCurrentScene ()) {    << 
379     auto errorCode = G4UImanager::GetUIpointer << 
380     if (errorCode) {                           << 
381       G4ExceptionDescription ed;               << 
382       ed << "sub-command \"/vis/sceneHandler/a << 
383       command->CommandFailed(errorCode,ed);    << 
384       return;                                  << 
385     }                                          << 
386   }                                               354   }
                                                   >> 355 
                                                   >> 356   // Attach scene.
                                                   >> 357   if (fpVisManager -> GetCurrentScene ())
                                                   >> 358     G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/sceneHandler/attach");
387 }                                                 359 }
388                                                   360 
389 ////////////// /vis/sceneHandler/list ////////    361 ////////////// /vis/sceneHandler/list ///////////////////////////////////////
390                                                   362 
391 G4VisCommandSceneHandlerList::G4VisCommandScen    363 G4VisCommandSceneHandlerList::G4VisCommandSceneHandlerList () {
392   G4bool omitable;                                364   G4bool omitable;
393   fpCommand = new G4UIcommand ("/vis/sceneHand    365   fpCommand = new G4UIcommand ("/vis/sceneHandler/list", this);
394   fpCommand -> SetGuidance ("Lists scene handl    366   fpCommand -> SetGuidance ("Lists scene handler(s).");
395   fpCommand -> SetGuidance                        367   fpCommand -> SetGuidance
396     ("\"help /vis/verbose\" for definition of     368     ("\"help /vis/verbose\" for definition of verbosity.");
397   G4UIparameter* parameter;                       369   G4UIparameter* parameter;
398   parameter = new G4UIparameter("scene-handler    370   parameter = new G4UIparameter("scene-handler-name", 's', omitable = true);
399   parameter -> SetDefaultValue ("all");           371   parameter -> SetDefaultValue ("all");
400   fpCommand -> SetParameter (parameter);          372   fpCommand -> SetParameter (parameter);
401   parameter = new G4UIparameter ("verbosity",     373   parameter = new G4UIparameter ("verbosity", 's', omitable = true);
402   parameter -> SetDefaultValue ("warnings");      374   parameter -> SetDefaultValue ("warnings");
403   fpCommand -> SetParameter (parameter);          375   fpCommand -> SetParameter (parameter);
404 }                                                 376 }
405                                                   377 
406 G4VisCommandSceneHandlerList::~G4VisCommandSce    378 G4VisCommandSceneHandlerList::~G4VisCommandSceneHandlerList () {
407   delete fpCommand;                               379   delete fpCommand;
408 }                                                 380 }
409                                                   381 
410 G4String G4VisCommandSceneHandlerList::GetCurr    382 G4String G4VisCommandSceneHandlerList::GetCurrentValue (G4UIcommand*) {
411   return "";                                      383   return "";
412 }                                                 384 }
413                                                   385 
414 void G4VisCommandSceneHandlerList::SetNewValue    386 void G4VisCommandSceneHandlerList::SetNewValue (G4UIcommand*,
415             G4String newValue) {                  387             G4String newValue) {
416   G4String name, verbosityString;                 388   G4String name, verbosityString;
417   std::istringstream is (newValue);               389   std::istringstream is (newValue);
418   is >> name >> verbosityString;                  390   is >> name >> verbosityString;
419   G4VisManager::Verbosity verbosity =             391   G4VisManager::Verbosity verbosity =
420     fpVisManager->GetVerbosityValue(verbosityS    392     fpVisManager->GetVerbosityValue(verbosityString);
421   const G4VSceneHandler* currentSceneHandler =    393   const G4VSceneHandler* currentSceneHandler =
422     fpVisManager -> GetCurrentSceneHandler ();    394     fpVisManager -> GetCurrentSceneHandler ();
423   G4String currentName;                           395   G4String currentName;
424   if (currentSceneHandler) currentName = curre    396   if (currentSceneHandler) currentName = currentSceneHandler->GetName();
425                                                   397 
426   const G4SceneHandlerList& list = fpVisManage    398   const G4SceneHandlerList& list = fpVisManager -> GetAvailableSceneHandlers ();
427   G4bool found = false;                           399   G4bool found = false;
428   for (std::size_t iSH = 0; iSH < list.size () << 400   for (size_t iSH = 0; iSH < list.size (); iSH++) {
429     const G4String& iName = list [iSH] -> GetN    401     const G4String& iName = list [iSH] -> GetName ();
430     if (name != "all") {                          402     if (name != "all") {
431       if (name != iName) continue;                403       if (name != iName) continue;
432     }                                             404     }
433     found = true;                                 405     found = true;
434     if (iName == currentName) {                   406     if (iName == currentName) {
435       G4cout << "  (current)";                    407       G4cout << "  (current)";
436     }                                             408     }
437     else {                                        409     else {
438       G4cout << "           ";                    410       G4cout << "           ";
439     }                                             411     }
440     G4cout << " scene handler \"" << list [iSH    412     G4cout << " scene handler \"" << list [iSH] -> GetName () << "\""
441      << " (" << list [iSH] -> GetGraphicsSyste    413      << " (" << list [iSH] -> GetGraphicsSystem () -> GetName () << ")";
442     if (verbosity >= G4VisManager::parameters)    414     if (verbosity >= G4VisManager::parameters) {
443       G4cout << "\n  " << *(list [iSH]);          415       G4cout << "\n  " << *(list [iSH]);
444     }                                             416     }
445     G4cout << G4endl;                             417     G4cout << G4endl;
446   }                                               418   }
447   if (!found) {                                   419   if (!found) {
448     G4cout << "No scene handlers found";          420     G4cout << "No scene handlers found";
449     if (name != "all") {                          421     if (name != "all") {
450       G4cout << " of name \"" << name << "\"";    422       G4cout << " of name \"" << name << "\"";
451     }                                             423     }
452     G4cout << "." << G4endl;                      424     G4cout << "." << G4endl;
453   }                                               425   }
454 }                                                 426 }
455                                                   427 
456 ////////////// /vis/sceneHandler/select //////    428 ////////////// /vis/sceneHandler/select ///////////////////////////////////////
457                                                   429 
458 G4VisCommandSceneHandlerSelect::G4VisCommandSc    430 G4VisCommandSceneHandlerSelect::G4VisCommandSceneHandlerSelect () {
459   G4bool omitable;                                431   G4bool omitable;
460   fpCommand = new G4UIcmdWithAString ("/vis/sc    432   fpCommand = new G4UIcmdWithAString ("/vis/sceneHandler/select", this);
461   fpCommand -> SetGuidance ("Selects a scene h    433   fpCommand -> SetGuidance ("Selects a scene handler.");
462   fpCommand -> SetGuidance                        434   fpCommand -> SetGuidance 
463     ("Makes the scene handler current.  \"/vis    435     ("Makes the scene handler current.  \"/vis/sceneHandler/list\" to see"
464      "\n possible scene handler names.");         436      "\n possible scene handler names.");
465   fpCommand -> SetParameterName ("scene-handle    437   fpCommand -> SetParameterName ("scene-handler-name",
466          omitable = false);                       438          omitable = false);
467 }                                                 439 }
468                                                   440 
469 G4VisCommandSceneHandlerSelect::~G4VisCommandS    441 G4VisCommandSceneHandlerSelect::~G4VisCommandSceneHandlerSelect () {
470   delete fpCommand;                               442   delete fpCommand;
471 }                                                 443 }
472                                                   444 
473 G4String G4VisCommandSceneHandlerSelect::GetCu    445 G4String G4VisCommandSceneHandlerSelect::GetCurrentValue (G4UIcommand*) {
474   return "";                                      446   return "";
475 }                                                 447 }
476                                                   448 
477 void G4VisCommandSceneHandlerSelect::SetNewVal    449 void G4VisCommandSceneHandlerSelect::SetNewValue (G4UIcommand*,
478               G4String newValue) {                450               G4String newValue) {
479                                                   451 
480   G4VisManager::Verbosity verbosity = fpVisMan    452   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
481                                                   453 
482   G4String& selectName = newValue;                454   G4String& selectName = newValue;
483   const G4SceneHandlerList& list = fpVisManage    455   const G4SceneHandlerList& list = fpVisManager -> GetAvailableSceneHandlers ();
484                                                   456 
485   std::size_t iSH;                             << 457   size_t iSH;
486   for (iSH = 0; iSH < list.size (); iSH++) {      458   for (iSH = 0; iSH < list.size (); iSH++) {
487     if (list [iSH] -> GetName () == selectName    459     if (list [iSH] -> GetName () == selectName) break;
488   }                                               460   }
489   if (iSH < list.size ()) {                       461   if (iSH < list.size ()) {
490     if (fpVisManager -> GetCurrentSceneHandler    462     if (fpVisManager -> GetCurrentSceneHandler () -> GetName ()
491   == selectName) {                                463   == selectName) {
492       if (verbosity >= G4VisManager::confirmat    464       if (verbosity >= G4VisManager::confirmations) {
493   G4cout << "Scene handler \"" << selectName <    465   G4cout << "Scene handler \"" << selectName << "\""
494          << " already selected." << G4endl;       466          << " already selected." << G4endl;
495       }                                           467       }
496     }                                             468     }
497     else {                                        469     else {
498       if (verbosity >= G4VisManager::confirmat    470       if (verbosity >= G4VisManager::confirmations) {
499   G4cout << "Scene handler \"" << selectName <    471   G4cout << "Scene handler \"" << selectName << "\""
500          << " being selected." << G4endl;         472          << " being selected." << G4endl;
501       }                                           473       }
502       fpVisManager -> SetCurrentSceneHandler (    474       fpVisManager -> SetCurrentSceneHandler (list [iSH]);
503     }                                             475     }
504   }                                               476   }
505   else {                                          477   else {
506     if (verbosity >= G4VisManager::errors) {      478     if (verbosity >= G4VisManager::errors) {
507       G4warn << "ERROR: Scene handler \"" << s << 479       G4cerr << "ERROR: Scene handler \"" << selectName << "\""
508        << " not found - \"/vis/sceneHandler/li    480        << " not found - \"/vis/sceneHandler/list\" to see possibilities."
509        << G4endl;                                 481        << G4endl;
510     }                                             482     }
511   }                                               483   }
512 }                                                 484 }
513                                                   485