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 1.1)


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