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