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 9.4.p4)


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