Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/management/src/G4VisCommandsScene.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/G4VisCommandsScene.cc (Version 11.3.0) and /visualization/management/src/G4VisCommandsScene.cc (Version 5.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 //                                                 23 //
                                                   >>  24 // $Id: G4VisCommandsScene.cc,v 1.32 2003/06/16 17:14:22 gunter Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-05-02 $
 27                                                    26 
 28 // /vis/scene commands - John Allison  9th Aug     27 // /vis/scene commands - John Allison  9th August 1998
 29                                                    28 
 30 #include "G4VisCommandsScene.hh"                   29 #include "G4VisCommandsScene.hh"
 31                                                    30 
 32 #include "G4VisManager.hh"                         31 #include "G4VisManager.hh"
 33 #include "G4TransportationManager.hh"              32 #include "G4TransportationManager.hh"
 34 #include "G4RunManager.hh"                     << 
 35 #include "G4RunManagerFactory.hh"              << 
 36 #include "G4Run.hh"                            << 
 37 #include "G4PhysicalVolumeModel.hh"                33 #include "G4PhysicalVolumeModel.hh"
 38 #include "G4ApplicationState.hh"                   34 #include "G4ApplicationState.hh"
 39 #include "G4UImanager.hh"                          35 #include "G4UImanager.hh"
 40 #include "G4UIcommand.hh"                          36 #include "G4UIcommand.hh"
 41 #include "G4UIcmdWithAString.hh"                   37 #include "G4UIcmdWithAString.hh"
 42 #include "G4UIcmdWithoutParameter.hh"          << 
 43 #include "G4ios.hh"                                38 #include "G4ios.hh"
 44 #include <sstream>                             <<  39 #include <strstream>
 45                                                << 
 46 #define G4warn G4cout                          << 
 47                                                    40 
 48 G4VVisCommandScene::G4VVisCommandScene () {}       41 G4VVisCommandScene::G4VVisCommandScene () {}
 49                                                    42 
 50 G4VVisCommandScene::~G4VVisCommandScene () {}      43 G4VVisCommandScene::~G4VVisCommandScene () {}
 51                                                    44 
 52 G4String G4VVisCommandScene::CurrentSceneName      45 G4String G4VVisCommandScene::CurrentSceneName () {
 53   const G4Scene* pScene = fpVisManager -> GetC     46   const G4Scene* pScene = fpVisManager -> GetCurrentScene ();
 54   G4String currentSceneName = "none";          <<  47   G4String currentSceneName;
 55   if (pScene) currentSceneName = pScene -> Get     48   if (pScene) currentSceneName = pScene -> GetName ();
 56   return currentSceneName;                         49   return currentSceneName;
 57 }                                                  50 }
 58                                                    51 
 59 ////////////// /vis/scene/activateModel ////// <<  52 void G4VVisCommandScene::UpdateCandidateLists () {
 60                                                    53 
 61 G4VisCommandSceneActivateModel::G4VisCommandSc <<  54   G4SceneList& sceneList = fpVisManager -> SetSceneList ();
 62   G4bool omitable;                             <<  55   G4int iScene, nScenes = sceneList.size ();
 63   fpCommand = new G4UIcommand ("/vis/scene/act <<  56   G4String nameList;
 64   fpCommand -> SetGuidance                     <<  57   for (iScene = 0; iScene < nScenes; iScene++) {
 65     ("Activate or de-activate model.");        <<  58     nameList += sceneList [iScene] -> GetName () + " ";
 66   fpCommand -> SetGuidance                     <<  59   }
 67     ("Attempts to match search string to name  <<  60   nameList = nameList.strip ();
 68   fpCommand -> SetGuidance                     <<  61   sceneNameCommandsIterator i;
 69     ("Use \"/vis/scene/list\" to see model nam <<  62   for (i = sceneNameCommands.begin (); i != sceneNameCommands.end (); ++i) {
 70   fpCommand -> SetGuidance                     <<  63     (*i)->GetParameter (0) -> SetParameterCandidates (nameList);
 71     ("If name == \"all\" (default), all models << 
 72   G4UIparameter* parameter;                    << 
 73   parameter = new G4UIparameter ("search-strin << 
 74   parameter -> SetDefaultValue ("all");        << 
 75   fpCommand -> SetParameter (parameter);       << 
 76   parameter = new G4UIparameter ("activate", ' << 
 77   parameter -> SetDefaultValue (true);         << 
 78   fpCommand -> SetParameter (parameter);       << 
 79 }                                              << 
 80                                                << 
 81 G4VisCommandSceneActivateModel::~G4VisCommandS << 
 82   delete fpCommand;                            << 
 83 }                                              << 
 84                                                << 
 85 G4String G4VisCommandSceneActivateModel::GetCu << 
 86   return "";                                   << 
 87 }                                              << 
 88                                                << 
 89 void G4VisCommandSceneActivateModel::SetNewVal << 
 90                  G4String newValue) {          << 
 91                                                << 
 92   G4VisManager::Verbosity verbosity = fpVisMan << 
 93                                                << 
 94   G4String searchString, activateString;       << 
 95   std::istringstream is (newValue);            << 
 96   // Need to handle the possibility that the s << 
 97   // contains embedded blanks within quotation << 
 98   // (This arises if the search string is auto << 
 99   // global description, as in G4UIQt, clickin << 
100   auto lastQuotationMark = newValue.find_last_ << 
101   if (lastQuotationMark != std::string::npos)  << 
102     auto firstQuotationMark = newValue.find_fi << 
103     if (lastQuotationMark != firstQuotationMar << 
104       // Note: there must not be more quotatio << 
105       searchString = newValue.substr           << 
106       (firstQuotationMark + 1, lastQuotationMa << 
107       activateString = newValue.substr(lastQuo << 
108       // Perhaps we ought to check number of q << 
109       G4int nQuotes = 0;                       << 
110       for (auto c : newValue) {                << 
111         if (c == '"') nQuotes++;               << 
112       }                                        << 
113       if (nQuotes > 2) {                       << 
114         G4ExceptionDescription ed;             << 
115         ed << "More than 2 quotation marks in  << 
116         G4Exception("G4VisCommandSceneActivate << 
117       }                                        << 
118     }                                          << 
119   }                                            << 
120   else {                                       << 
121     // None or one quotation marks - just inpu << 
122     is >> searchString >> activateString;      << 
123   }                                            << 
124   G4bool activate = G4UIcommand::ConvertToBool << 
125                                                << 
126   G4Scene* pScene = fpVisManager->GetCurrentSc << 
127   if (!pScene) {                               << 
128     if (verbosity >= G4VisManager::errors) {   << 
129       G4warn << "ERROR: No current scene.  Ple << 
130     }                                          << 
131     return;                                    << 
132   }                                            << 
133                                                << 
134   G4VSceneHandler* pSceneHandler = fpVisManage << 
135   if (!pSceneHandler) {                        << 
136     if (verbosity >= G4VisManager::errors) {   << 
137       G4warn << "ERROR: No current sceneHandle << 
138     }                                          << 
139     return;                                    << 
140   }                                            << 
141                                                << 
142   if (searchString == "all" && !activate) {    << 
143     if (verbosity >= G4VisManager::warnings) { << 
144       G4warn <<                                << 
145   "WARNING: You are not allowed to de-activate << 
146   "\n  Command ignored."                       << 
147        << G4endl;                              << 
148     }                                          << 
149     return;                                    << 
150   }                                            << 
151                                                << 
152   G4bool any = false;                          << 
153                                                << 
154   std::vector<G4Scene::Model>& runDurationMode << 
155     pScene->SetRunDurationModelList();         << 
156   for (size_t i = 0; i < runDurationModelList. << 
157     const G4String& modelName = runDurationMod << 
158     if (searchString == "all" || modelName.fin << 
159       any = true;                              << 
160       runDurationModelList[i].fActive = activa << 
161       if (verbosity >= G4VisManager::warnings) << 
162   G4warn << "Model \"" << modelName;           << 
163   if (activate) G4warn << "\" activated.";     << 
164   else  G4warn << "\" de-activated.";          << 
165   G4warn << G4endl;                            << 
166       }                                        << 
167     }                                          << 
168   }                                            << 
169                                                << 
170   std::vector<G4Scene::Model>& endOfEventModel << 
171     pScene->SetEndOfEventModelList();          << 
172   for (size_t i = 0; i < endOfEventModelList.s << 
173     const G4String& modelName = endOfEventMode << 
174     if (searchString == "all" || modelName.fin << 
175       any = true;                              << 
176       endOfEventModelList[i].fActive = activat << 
177       if (verbosity >= G4VisManager::warnings) << 
178   G4warn << "Model \"" << modelName;           << 
179   if (activate) G4warn << "\" activated.";     << 
180   else  G4warn << "\" de-activated.";          << 
181   G4warn << G4endl;                            << 
182       }                                        << 
183     }                                          << 
184   }                                            << 
185                                                << 
186   std::vector<G4Scene::Model>& endOfRunModelLi << 
187     pScene->SetEndOfRunModelList();            << 
188   for (size_t i = 0; i < endOfRunModelList.siz << 
189     const G4String& modelName = endOfRunModelL << 
190     if (searchString == "all" || modelName.fin << 
191       any = true;                              << 
192       endOfRunModelList[i].fActive = activate; << 
193       if (verbosity >= G4VisManager::warnings) << 
194   G4warn << "Model \"" << modelName;           << 
195   if (activate) G4warn << "\" activated.";     << 
196   else  G4warn << "\" de-activated.";          << 
197   G4warn << G4endl;                            << 
198       }                                        << 
199     }                                          << 
200   }                                            << 
201                                                << 
202   if (!any) {                                  << 
203     if (verbosity >= G4VisManager::warnings) { << 
204       G4warn << "WARNING: No match found." <<  << 
205     }                                          << 
206     return;                                    << 
207   }                                                64   }
208                                                << 
209   CheckSceneAndNotifyHandlers (pScene);        << 
210 }                                                  65 }
211                                                    66 
212 ////////////// /vis/scene/create /////////////     67 ////////////// /vis/scene/create ///////////////////////////////////////
213                                                    68 
214 G4VisCommandSceneCreate::G4VisCommandSceneCrea     69 G4VisCommandSceneCreate::G4VisCommandSceneCreate (): fId (0) {
215   G4bool omitable;                             <<  70   G4bool omitable, currentAsDefault;
216   fpCommand = new G4UIcmdWithAString ("/vis/sc     71   fpCommand = new G4UIcmdWithAString ("/vis/scene/create", this);
217   fpCommand -> SetGuidance                     <<  72   fpCommand -> SetGuidance ("/vis/scene/create [<scene-name>]");
218     ("Creates an empty scene.");               <<  73   fpCommand -> SetGuidance ("Creates an empty scene.");
219   fpCommand -> SetGuidance                     <<  74   fpCommand -> SetGuidance ("Invents a name if not supplied.");
220     ("Invents a name if not supplied.  This sc <<  75   fpCommand -> SetGuidance ("This scene becomes current.");
221   fpCommand -> SetParameterName ("scene-name", <<  76   fpCommand -> SetParameterName ("scene-name",
                                                   >>  77          omitable = true,
                                                   >>  78          currentAsDefault = true);
                                                   >>  79   sceneNameCommands.push_back (fpCommand);
222 }                                                  80 }
223                                                    81 
224 G4VisCommandSceneCreate::~G4VisCommandSceneCre     82 G4VisCommandSceneCreate::~G4VisCommandSceneCreate () {
225   delete fpCommand;                                83   delete fpCommand;
226 }                                                  84 }
227                                                    85 
228 G4String G4VisCommandSceneCreate::NextName ()      86 G4String G4VisCommandSceneCreate::NextName () {
229   std::ostringstream oss;                      <<  87   char nextName [20];
230   oss << "scene-" << fId;                      <<  88   std::ostrstream ost (nextName, 20);
231   return oss.str();                            <<  89   ost << "scene-" << fId  << std::ends;
                                                   >>  90   return nextName;
232 }                                                  91 }
233                                                    92 
234 G4String G4VisCommandSceneCreate::GetCurrentVa     93 G4String G4VisCommandSceneCreate::GetCurrentValue (G4UIcommand*) {
235   return "";                                   <<  94   return NextName ();
236 }                                                  95 }
237                                                    96 
238 void G4VisCommandSceneCreate::SetNewValue (G4U     97 void G4VisCommandSceneCreate::SetNewValue (G4UIcommand*, G4String newValue) {
239                                                    98 
240   G4VisManager::Verbosity verbosity = fpVisMan     99   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
241                                                   100 
242   G4String& newName = newValue;                   101   G4String& newName = newValue;
243   G4String nextName = NextName ();                102   G4String nextName = NextName ();
244                                                   103 
245   if (newName == "") {                            104   if (newName == "") {
246     newName = nextName;                           105     newName = nextName;
247   }                                               106   }
248   if (newName == nextName) fId++;                 107   if (newName == nextName) fId++;
249                                                   108 
250   G4SceneList& sceneList = fpVisManager -> Set    109   G4SceneList& sceneList = fpVisManager -> SetSceneList ();
251   std::size_t iScene, nScenes = sceneList.size << 110   G4int iScene, nScenes = sceneList.size ();
252   for (iScene = 0; iScene < nScenes; ++iScene) << 111   for (iScene = 0; iScene < nScenes; iScene++) {
253     if (sceneList [iScene] -> GetName () == ne    112     if (sceneList [iScene] -> GetName () == newName) break;
254   }                                               113   }
255   if (iScene < nScenes) {                         114   if (iScene < nScenes) {
256     if (verbosity >= G4VisManager::warnings) {    115     if (verbosity >= G4VisManager::warnings) {
257       G4warn << "WARNING: Scene \"" << newName << 116       G4cout << "WARNING: Scene \"" << newName << "\" already exists."
258        << "\n  New scene not created."         << 
259        << G4endl;                                 117        << G4endl;
260     }                                             118     }
261   } else {                                     << 119   }
                                                   >> 120   else {
262                                                   121 
263     // Add empty scene data object to list...  << 122     sceneList.push_back (new G4Scene (newName));
264     G4Scene* pScene = new G4Scene (newName);   << 123     // Adds empty scene data object to list.
265     sceneList.push_back (pScene);              << 
266     fpVisManager -> SetCurrentScene (pScene);  << 
267                                                   124 
268     if (verbosity >= G4VisManager::confirmatio    125     if (verbosity >= G4VisManager::confirmations) {
269       G4cout << "New empty scene \"" << newNam    126       G4cout << "New empty scene \"" << newName << "\" created." << G4endl;
270     }                                             127     }
                                                   >> 128 
                                                   >> 129     UpdateCandidateLists ();
271   }                                               130   }
                                                   >> 131   UpdateVisManagerScene (newName);
272 }                                                 132 }
273                                                   133 
274 ////////////// /vis/scene/endOfEventAction /// << 134 ////////////// /vis/scene/edit ///////////////////////////////////////
275                                                   135 
276 G4VisCommandSceneEndOfEventAction::G4VisComman << 136 G4VisCommandSceneEdit::G4VisCommandSceneEdit () {
277   G4bool omitable;                             << 137   G4bool omitable, currentAsDefault;
278   fpCommand = new G4UIcommand ("/vis/scene/end << 138   fpCommand = new G4UIcmdWithAString ("/vis/scene/edit", this);
279   fpCommand -> SetGuidance                     << 139   fpCommand -> SetGuidance ("/vis/scene/edit [<scene-name>]");
280     ("Accumulate or refresh the viewer for eac << 140   fpCommand -> SetGuidance ("Edits a scene (default current scene).");
281   fpCommand -> SetGuidance                     << 141   fpCommand -> SetGuidance ("This scene becomes current.");
282     ("\"accumulate\": viewer accumulates hits, << 142   fpCommand -> SetParameterName ("scene-name",
283   fpCommand -> SetGuidance                     << 143          omitable = true,
284     ("\"refresh\": viewer shows them at end of << 144          currentAsDefault = true);
285      "\n  viewers, refreshes the screen just b << 145   sceneNameCommands.push_back (fpCommand);
286   G4UIparameter* parameter;                    << 
287   parameter = new G4UIparameter ("action", 's' << 
288   parameter -> SetParameterCandidates ("accumu << 
289   parameter -> SetDefaultValue ("refresh");    << 
290   fpCommand -> SetParameter (parameter);       << 
291   parameter = new G4UIparameter ("maxNumber",  << 
292   parameter -> SetDefaultValue (100);          << 
293   parameter -> SetGuidance                     << 
294   ("Maximum number of events kept.  Unlimited  << 
295   fpCommand -> SetParameter (parameter);       << 
296 }                                                 146 }
297                                                   147 
298 G4VisCommandSceneEndOfEventAction::~G4VisComma << 148 G4VisCommandSceneEdit::~G4VisCommandSceneEdit () {
299   delete fpCommand;                               149   delete fpCommand;
300 }                                                 150 }
301                                                   151 
302 G4String G4VisCommandSceneEndOfEventAction::Ge << 152 G4String G4VisCommandSceneEdit::GetCurrentValue (G4UIcommand*) {
303   return "";                                   << 153   return CurrentSceneName ();
304 }                                                 154 }
305                                                   155 
306 void G4VisCommandSceneEndOfEventAction::SetNew << 156 void G4VisCommandSceneEdit::SetNewValue (G4UIcommand*, G4String newValue) {
307                  G4String newValue) {          << 
308                                                   157 
309   G4VisManager::Verbosity verbosity = fpVisMan    158   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
310                                                   159 
311   G4String action;                             << 160   G4String sceneName;
312   G4int maxNumberOfKeptEvents;                 << 161   std::istrstream is ((char*)newValue.data());
313   std::istringstream is (newValue);            << 162   is >> sceneName;
314   is >> action >> maxNumberOfKeptEvents;       << 
315                                                   163 
316   G4Scene* pScene = fpVisManager->GetCurrentSc << 164   G4SceneList& sceneList = fpVisManager -> SetSceneList ();
317   if (!pScene) {                               << 165   G4int iScene, nScenes = sceneList.size ();
318     if (verbosity >= G4VisManager::errors) {   << 166   G4Scene* pScene;
319       G4warn << "ERROR: No current scene.  Ple << 167   for (iScene = 0; iScene < nScenes; iScene++) {
320     }                                          << 168     pScene = sceneList [iScene];
321     return;                                    << 169     if (pScene -> GetName () == sceneName) break;
322   }                                               170   }
323                                                << 171   if (iScene >= nScenes) {
324   G4VSceneHandler* pSceneHandler = fpVisManage << 172     if (verbosity >= G4VisManager::warnings) {
325   if (!pSceneHandler) {                        << 173       G4cout << "WARNING: G4VisCommandSceneEdit::SetNewValue: Scene \""
326     if (verbosity >= G4VisManager::errors) {   << 174        << sceneName << "\" not found."
327       G4warn << "ERROR: No current sceneHandle << 175   "\n  /vis/scene/list to see scenes."
                                                   >> 176        << G4endl;
328     }                                             177     }
329     return;                                       178     return;
330   }                                               179   }
331                                                << 
332   if (action == "accumulate") {                << 
333     pScene->SetRefreshAtEndOfEvent(false);     << 
334     pScene->SetMaxNumberOfKeptEvents(maxNumber << 
335   }                                            << 
336   else if (action == "refresh") {              << 
337     if (!pScene->GetRefreshAtEndOfRun()) {     << 
338       if (verbosity >= G4VisManager::errors) { << 
339   G4warn <<                                    << 
340     "ERROR: Cannot refresh events unless runs  << 
341     "\n  Use \"/vis/scene/endOfRun refresh\"." << 
342          << G4endl;                            << 
343       }                                        << 
344     } else {                                   << 
345       pScene->SetRefreshAtEndOfEvent(true);    << 
346       pScene->SetMaxNumberOfKeptEvents(maxNumb << 
347       pSceneHandler->SetMarkForClearingTransie << 
348     }                                          << 
349   }                                            << 
350   else {                                          180   else {
351     if (verbosity >= G4VisManager::errors) {   << 181     if (verbosity >= G4VisManager::confirmations) {
352       G4warn <<                                << 182       G4cout << "Scene \"" << sceneName << "\" contains:" << G4endl;
353   "ERROR: unrecognised parameter \"" << action << 183       G4String uiCommand ("/vis/scene/list ");
354              << G4endl;                        << 184       uiCommand += sceneName;
355     }                                          << 185       uiCommand += " confirmations";
356     return;                                    << 186       G4UImanager::GetUIpointer () -> ApplyCommand (uiCommand);
357   }                                            << 187       G4cout <<
358                                                << 188       "BUT...YOU CAN DO NOTHING YET - /vis/scene/edit FACILITY IN PREPARATION."
359   // Change of transients behaviour, so...     << 189        << G4endl;
360   fpVisManager->ResetTransientsDrawnFlags();   << 
361                                                << 
362   // Are there any events currently kept...    << 
363   size_t nCurrentlyKept    = 0;                << 
364   G4RunManager* runManager = G4RunManagerFacto << 
365   if(runManager)                               << 
366   {                                            << 
367     const G4Run* currentRun = runManager->GetC << 
368     if(currentRun)                             << 
369     {                                          << 
370       const std::vector<const G4Event*>* event << 
371       if(events)                               << 
372         nCurrentlyKept = events->size();       << 
373     }                                          << 
374   }                                            << 
375                                                << 
376   if (verbosity >= G4VisManager::confirmations << 
377     G4cout << "End of event action set to ";   << 
378     if (pScene->GetRefreshAtEndOfEvent()) G4co << 
379     else {                                     << 
380       G4cout << "\"accumulate\"."              << 
381   "\n  Maximum number of events to be kept: "  << 
382        << maxNumberOfKeptEvents                << 
383        << " (unlimited if negative)."          << 
384   "\n  This may be changed with, e.g., "       << 
385   "\"/vis/scene/endOfEventAction accumulate 10 << 
386     }                                             190     }
387     G4cout << G4endl;                          << 
388   }                                               191   }
389                                                   192 
390   if (!pScene->GetRefreshAtEndOfEvent() &&     << 193   UpdateVisManagerScene (sceneName);
391       maxNumberOfKeptEvents != 0 &&            << 
392       verbosity >= G4VisManager::warnings) {   << 
393     G4warn << "WARNING: ";                     << 
394     if (nCurrentlyKept) {                      << 
395       G4warn <<                                << 
396   "\n  There are currently " << nCurrentlyKept << 
397        << " events kept for refreshing and/or  << 
398     } else {                                   << 
399       G4warn << "The vis manager will keep ";  << 
400       if (maxNumberOfKeptEvents < 0) G4warn << << 
401       else G4warn << "up to " << maxNumberOfKe << 
402       G4warn << " events.";                    << 
403       if (maxNumberOfKeptEvents > 1 || maxNumb << 
404   G4warn <<                                    << 
405     "\n  This may use a lot of memory."        << 
406     "\n  It may be changed with, e.g., "       << 
407     "\"/vis/scene/endOfEventAction accumulate  << 
408     }                                          << 
409     G4warn << G4endl;                          << 
410   }                                            << 
411 }                                                 194 }
412                                                   195 
413 ////////////// /vis/scene/endOfRunAction ///// << 196 ////////////// /vis/scene/endOfEventAction ////////////////////////////
414                                                   197 
415 G4VisCommandSceneEndOfRunAction::G4VisCommandS << 198 G4VisCommandSceneEndOfEventAction::G4VisCommandSceneEndOfEventAction () {
416   G4bool omitable;                                199   G4bool omitable;
417   fpCommand = new G4UIcmdWithAString ("/vis/sc << 200   fpCommand = new G4UIcmdWithAString ("/vis/scene/endOfEventAction", this);
418   fpCommand -> SetGuidance                     << 
419     ("Accumulate or refresh the viewer for eac << 
420   fpCommand -> SetGuidance                        201   fpCommand -> SetGuidance
421     ("\"accumulate\": viewer accumulates hits, << 202     ("/vis/scene/endOfEventAction [accumulate|refresh]");
422   fpCommand -> SetGuidance                        203   fpCommand -> SetGuidance
423     ("\"refresh\": viewer shows them at end of << 204     ("Requests viewer to refresh hits, tracks, etc., at end of event."
424      "\n  viewers, refreshes the screen just b << 205      "\n  Or they are accumulated.  Detector remains or is redrawn.");
425      "\n  event of the next run.");            << 206   fpCommand -> SetParameterName ("action",
426   fpCommand -> SetGuidance ("The detector rema << 207          omitable = true);
427   fpCommand -> SetParameterName ("action", omi << 
428   fpCommand -> SetCandidates ("accumulate refr    208   fpCommand -> SetCandidates ("accumulate refresh");
429   fpCommand -> SetDefaultValue ("refresh");       209   fpCommand -> SetDefaultValue ("refresh");
430 }                                                 210 }
431                                                   211 
432 G4VisCommandSceneEndOfRunAction::~G4VisCommand << 212 G4VisCommandSceneEndOfEventAction::~G4VisCommandSceneEndOfEventAction () {
433   delete fpCommand;                               213   delete fpCommand;
434 }                                                 214 }
435                                                   215 
436 G4String G4VisCommandSceneEndOfRunAction::GetC << 216 G4String G4VisCommandSceneEndOfEventAction::GetCurrentValue(G4UIcommand*) {
437   return "";                                      217   return "";
438 }                                                 218 }
439                                                   219 
440 void G4VisCommandSceneEndOfRunAction::SetNewVa << 220 void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
441                  G4String newValue) {             221                  G4String newValue) {
442                                                   222 
443   G4VisManager::Verbosity verbosity = fpVisMan    223   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
444                                                   224 
445   G4String action;                                225   G4String action;
446   std::istringstream is (newValue);            << 226   std::istrstream is ((char*)newValue.data());
447   is >> action;                                   227   is >> action;
448                                                   228 
449   G4Scene* pScene = fpVisManager->GetCurrentSc    229   G4Scene* pScene = fpVisManager->GetCurrentScene();
450   if (!pScene) {                                  230   if (!pScene) {
451     if (verbosity >= G4VisManager::errors) {      231     if (verbosity >= G4VisManager::errors) {
452       G4warn << "ERROR: No current scene.  Ple << 232       G4cout << "ERROR: No current scene.  Please create one." << G4endl;
453     }                                          << 
454     return;                                    << 
455   }                                            << 
456                                                << 
457   G4VSceneHandler* pSceneHandler = fpVisManage << 
458   if (!pSceneHandler) {                        << 
459     if (verbosity >= G4VisManager::errors) {   << 
460       G4warn << "ERROR: No current sceneHandle << 
461     }                                             233     }
462     return;                                       234     return;
463   }                                               235   }
464                                                   236 
465   if (action == "accumulate") {                   237   if (action == "accumulate") {
466     if (pScene->GetRefreshAtEndOfEvent()) {    << 238     pScene->SetRefreshAtEndOfEvent(false);
467       if (verbosity >= G4VisManager::errors) { << 
468   G4warn <<                                    << 
469     "ERROR: Cannot accumulate runs unless even << 
470     "\n  Use \"/vis/scene/endOfEventAction acc << 
471          << G4endl;                            << 
472       }                                        << 
473     }                                          << 
474     else {                                     << 
475       pScene->SetRefreshAtEndOfRun(false);     << 
476     }                                          << 
477   }                                               239   }
478   else if (action == "refresh") {                 240   else if (action == "refresh") {
479     pScene->SetRefreshAtEndOfRun(true);        << 241     pScene->SetRefreshAtEndOfEvent(true);
480     pSceneHandler->SetMarkForClearingTransient << 
481   }                                               242   }
482   else {                                          243   else {
483     if (verbosity >= G4VisManager::errors) {      244     if (verbosity >= G4VisManager::errors) {
484       G4warn <<                                << 245       G4cout <<
485   "ERROR: unrecognised parameter \"" << action    246   "ERROR: unrecognised parameter \"" << action << "\"."
486              << G4endl;                           247              << G4endl;
487     }                                             248     }
488     return;                                       249     return;
489   }                                               250   }
490                                                   251 
491   // Change of transients behaviour, so...     << 
492   fpVisManager->ResetTransientsDrawnFlags();   << 
493                                                << 
494   if (verbosity >= G4VisManager::confirmations    252   if (verbosity >= G4VisManager::confirmations) {
495     G4cout << "End of run action set to \"";   << 253     G4cout << "End of event action set to \"";
496     if (pScene->GetRefreshAtEndOfRun()) G4cout << 254     if (pScene->GetRefreshAtEndOfEvent()) G4cout << "refresh";
497     else G4cout << "accumulate";                  255     else G4cout << "accumulate";
498     G4cout << "\"" << G4endl;                     256     G4cout << "\"" << G4endl;
499   }                                               257   }
500 }                                                 258 }
501                                                   259 
502 ////////////// /vis/scene/list ///////////////    260 ////////////// /vis/scene/list ///////////////////////////////////////
503                                                   261 
504 G4VisCommandSceneList::G4VisCommandSceneList (    262 G4VisCommandSceneList::G4VisCommandSceneList () {
505   G4bool omitable;                                263   G4bool omitable;
506   fpCommand = new G4UIcommand ("/vis/scene/lis    264   fpCommand = new G4UIcommand ("/vis/scene/list", this);
                                                   >> 265   fpCommand -> SetGuidance ("/vis/scene/list [<scene-name>] [<verbosity>]");
507   fpCommand -> SetGuidance ("Lists scene(s).")    266   fpCommand -> SetGuidance ("Lists scene(s).");
                                                   >> 267   fpCommand -> SetGuidance ("<scene-name> default is \"all\"");
508   fpCommand -> SetGuidance                        268   fpCommand -> SetGuidance
509     ("\"help /vis/verbose\" for definition of  << 269     ("See /vis/verbose for definition of verbosity.");
510   G4UIparameter* parameter;                       270   G4UIparameter* parameter;
511   parameter = new G4UIparameter ("scene-name", << 271   parameter = new G4UIparameter ("scene-name", 's',
                                                   >> 272          omitable = true);
                                                   >> 273   parameter -> SetCurrentAsDefault (false);
512   parameter -> SetDefaultValue ("all");           274   parameter -> SetDefaultValue ("all");
513   fpCommand -> SetParameter (parameter);          275   fpCommand -> SetParameter (parameter);
514   parameter = new G4UIparameter ("verbosity",  << 276   parameter = new G4UIparameter ("verbosity", 's',
515   parameter -> SetDefaultValue ("warnings");   << 277          omitable = true);
                                                   >> 278   parameter -> SetCurrentAsDefault (false);
                                                   >> 279   parameter -> SetDefaultValue (0);
516   fpCommand -> SetParameter (parameter);          280   fpCommand -> SetParameter (parameter);
                                                   >> 281   sceneNameCommands.push_back (fpCommand);
517 }                                                 282 }
518                                                   283 
519 G4VisCommandSceneList::~G4VisCommandSceneList     284 G4VisCommandSceneList::~G4VisCommandSceneList () {
520   delete fpCommand;                               285   delete fpCommand;
521 }                                                 286 }
522                                                   287 
523 G4String G4VisCommandSceneList::GetCurrentValu    288 G4String G4VisCommandSceneList::GetCurrentValue (G4UIcommand*) {
524   return "";                                      289   return "";
525 }                                                 290 }
526                                                   291 
527 void G4VisCommandSceneList::SetNewValue (G4UIc    292 void G4VisCommandSceneList::SetNewValue (G4UIcommand*, G4String newValue) {
528   G4String name, verbosityString;                 293   G4String name, verbosityString;
529   std::istringstream is (newValue);            << 294   std::istrstream is ((char*)newValue.data());
530   is >> name >> verbosityString;                  295   is >> name >> verbosityString;
531   G4VisManager::Verbosity verbosity =             296   G4VisManager::Verbosity verbosity =
532     fpVisManager->GetVerbosityValue(verbosityS    297     fpVisManager->GetVerbosityValue(verbosityString);
533   const G4Scene* currentScene = fpVisManager - << 
534   G4String currentName;                        << 
535   if (currentScene) currentName = currentScene << 
536                                                   298 
537   G4SceneList& sceneList = fpVisManager -> Set    299   G4SceneList& sceneList = fpVisManager -> SetSceneList ();
538   std::size_t iScene, nScenes = sceneList.size << 300   G4int iScene, nScenes = sceneList.size ();
539   G4bool found = false;                           301   G4bool found = false;
540   for (iScene = 0; iScene < nScenes; ++iScene) << 302   for (iScene = 0; iScene < nScenes; iScene++) {
541     G4Scene* pScene = sceneList [iScene];         303     G4Scene* pScene = sceneList [iScene];
542     const G4String& iName = pScene -> GetName     304     const G4String& iName = pScene -> GetName ();
543     if (name != "all") {                          305     if (name != "all") {
544       if (name != iName) continue;                306       if (name != iName) continue;
545     }                                             307     }
546     found = true;                                 308     found = true;
547     if (iName == currentName) {                << 309     G4cout << "Scene name: \"" << iName << "\"";
548       G4cout << "  (current)";                 << 310     if (verbosity >= G4VisManager::confirmations) {
549     }                                          << 311       G4int i;
550     else {                                     << 
551       G4cout << "           ";                 << 
552     }                                          << 
553     G4cout << " scene \"" << iName << "\"";    << 
554     if (verbosity >= G4VisManager::warnings) { << 
555       std::size_t i;                           << 
556       G4cout << "\n  Run-duration models:";       312       G4cout << "\n  Run-duration models:";
557       std::size_t nRunModels = pScene -> GetRu << 313       G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
558       if (nRunModels == 0) {                      314       if (nRunModels == 0) {
559   G4cout << " none.";                             315   G4cout << " none.";
560       }                                           316       }
561       for (i = 0; i < nRunModels; ++i) {       << 317       for (i = 0; i < nRunModels; i++) {
562   if (pScene -> GetRunDurationModelList()[i].f << 318   G4VModel* pModel = pScene -> GetRunDurationModelList () [i];
563     G4cout << "\n   Active:   ";               << 319   G4cout << "\n    " << pModel -> GetGlobalDescription ();
564   else G4cout << "\n   Inactive: ";            << 
565   G4VModel* pModel = pScene -> GetRunDurationM << 
566   G4cout << pModel -> GetGlobalDescription (); << 
567       }                                           320       }
568       G4cout << "\n  End-of-event models:";       321       G4cout << "\n  End-of-event models:";
569       std::size_t nEOEModels = pScene -> GetEn << 322       G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
570       if (nEOEModels == 0) {                      323       if (nEOEModels == 0) {
571   G4cout << " none.";                             324   G4cout << " none.";
572       }                                           325       }
573       for (i = 0; i < nEOEModels; ++i) {       << 326       for (i = 0; i < nEOEModels; i++) {
574   if (pScene -> GetEndOfEventModelList()[i].fA << 327   G4VModel* pModel = pScene -> GetEndOfEventModelList () [i];
575     G4cout << "\n   Active:   ";               << 328   G4cout << "\n    " << pModel -> GetGlobalDescription ();
576   else G4cout << "\n   Inactive: ";            << 
577   G4VModel* pModel = pScene -> GetEndOfEventMo << 
578   G4cout << pModel -> GetGlobalDescription (); << 
579       }                                        << 
580       G4cout << "\n  End-of-run models:";      << 
581       std::size_t nEORModels = pScene -> GetEn << 
582       if (nEORModels == 0) {                   << 
583   G4cout << " none.";                          << 
584       }                                        << 
585       for (i = 0; i < nEORModels; ++i) {       << 
586   if (pScene -> GetEndOfRunModelList()[i].fAct << 
587     G4cout << "\n   Active:   ";               << 
588   else G4cout << "\n   Inactive: ";            << 
589   G4VModel* pModel = pScene -> GetEndOfRunMode << 
590   G4cout << pModel -> GetGlobalDescription (); << 
591       }                                           329       }
592     }                                             330     }
593     if (verbosity >= G4VisManager::parameters)    331     if (verbosity >= G4VisManager::parameters) {
594       G4cout << "\n  " << *sceneList [iScene];    332       G4cout << "\n  " << *sceneList [iScene];
595     }                                             333     }
596     G4cout << G4endl;                             334     G4cout << G4endl;
597   }                                               335   }
598   if (!found) {                                   336   if (!found) {
599     G4warn << "No scenes found";               << 337     G4cout << "No scenes found";
600     if (name != "all") {                          338     if (name != "all") {
601       G4warn << " of name \"" << name << "\""; << 339       G4cout << " of name \"" << name << "\"";
602     }                                             340     }
603     G4warn << "." << G4endl;                   << 341     G4cout << "." << G4endl;
604   }                                               342   }
605 }                                                 343 }
606                                                   344 
607 ////////////// /vis/scene/notifyHandlers /////    345 ////////////// /vis/scene/notifyHandlers /////////////////////////
608                                                   346 
609 G4VisCommandSceneNotifyHandlers::G4VisCommandS    347 G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers () {
610   G4bool omitable;                                348   G4bool omitable;
611   fpCommand = new G4UIcommand ("/vis/scene/not    349   fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this);
612   fpCommand -> SetGuidance                        350   fpCommand -> SetGuidance
613     ("Notifies scene handlers and forces re-re << 351     ("/vis/scene/notifyHandlers [<scene-name>] [r[efresh]|f[lush]]");
                                                   >> 352   fpCommand -> SetGuidance
                                                   >> 353     ("Notifies scene handlers of possible changes of scene.");
                                                   >> 354   fpCommand -> SetGuidance ("<scene-name> default is current scene name.");
614   fpCommand -> SetGuidance                        355   fpCommand -> SetGuidance
615     ("Notifies the handler(s) of the specified << 356     ("Clears and refreshes all viewers of current scene."
616      "\nreconstruction of any graphical databa << 
617      "\nClears and refreshes all viewers of cu << 
618      "\n  The default action \"refresh\" does     357      "\n  The default action \"refresh\" does not issue \"update\" (see"
619      "\n    /vis/viewer/update)."                 358      "\n    /vis/viewer/update)."
620      "\nIf \"flush\" is specified, it issues a    359      "\nIf \"flush\" is specified, it issues an \"update\" as well as"
621      "\n  \"refresh\" - \"update\" and initiat << 360      "\n  \"refresh\".  Useful for refreshing and initiating post-processing"
622      "\n  for graphics systems which need it." << 361      "\n  for graphics systems which need post-processing.");
623   fpCommand -> SetGuidance                     << 
624     ("The default for <scene-name> is the curr << 
625   fpCommand -> SetGuidance                        362   fpCommand -> SetGuidance
626     ("This command does not change current sce    363     ("This command does not change current scene, scene handler or viewer.");
627   G4UIparameter* parameter;                       364   G4UIparameter* parameter;
628   parameter = new G4UIparameter ("scene-name",    365   parameter = new G4UIparameter ("scene-name", 's',
629          omitable = true);                        366          omitable = true);
630   parameter -> SetCurrentAsDefault(true);         367   parameter -> SetCurrentAsDefault(true);
631   fpCommand -> SetParameter (parameter);          368   fpCommand -> SetParameter (parameter);
632   parameter = new G4UIparameter ("refresh-flus    369   parameter = new G4UIparameter ("refresh-flush", 's',
633          omitable = true);                        370          omitable = true);
634   parameter -> SetDefaultValue("refresh");        371   parameter -> SetDefaultValue("refresh");
635   parameter -> SetParameterCandidates("r refre << 
636   fpCommand -> SetParameter (parameter);          372   fpCommand -> SetParameter (parameter);
                                                   >> 373   sceneNameCommands.push_back (fpCommand);
637 }                                                 374 }
638                                                   375 
639 G4VisCommandSceneNotifyHandlers::~G4VisCommand    376 G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers () {
640   delete fpCommand;                               377   delete fpCommand;
641 }                                                 378 }
642                                                   379 
643 G4String G4VisCommandSceneNotifyHandlers::GetC    380 G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue(G4UIcommand*) {
644   return CurrentSceneName ();                     381   return CurrentSceneName ();
645 }                                                 382 }
646                                                   383 
647 void G4VisCommandSceneNotifyHandlers::SetNewVa    384 void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
648                G4String newValue) {               385                G4String newValue) {
649                                                   386 
650   G4VisManager::Verbosity verbosity = fpVisMan    387   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
651                                                   388 
652   G4String sceneName, refresh_flush;              389   G4String sceneName, refresh_flush;
653   std::istringstream is (newValue);            << 390   std::istrstream is ((char*)newValue.data());
654   is >> sceneName >> refresh_flush;               391   is >> sceneName >> refresh_flush;
655   G4bool flush = false;                        << 392   G4bool flush(false);
656   if (refresh_flush[0] == 'f') flush = true;   << 393   if (refresh_flush(0) == 'f') flush = true;
657                                                   394 
658   const G4SceneList& sceneList = fpVisManager     395   const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
659   G4SceneHandlerList& sceneHandlerList =          396   G4SceneHandlerList& sceneHandlerList =
660     fpVisManager -> SetAvailableSceneHandlers     397     fpVisManager -> SetAvailableSceneHandlers ();
661                                                   398 
662   // Check scene name.                            399   // Check scene name.
663   const std::size_t nScenes = sceneList.size ( << 400   const G4int nScenes = sceneList.size ();
664   std::size_t iScene;                          << 401   G4int iScene;
665   for (iScene = 0; iScene < nScenes; ++iScene) << 402   for (iScene = 0; iScene < nScenes; iScene++) {
666     G4Scene* scene = sceneList [iScene];          403     G4Scene* scene = sceneList [iScene];
667     if (sceneName == scene -> GetName ()) brea    404     if (sceneName == scene -> GetName ()) break;
668   }                                               405   }
669   if (iScene >= nScenes ) {                       406   if (iScene >= nScenes ) {
670     if (verbosity >= G4VisManager::warnings) {    407     if (verbosity >= G4VisManager::warnings) {
671       G4warn << "WARNING: Scene \"" << sceneNa << 408       G4cout << "WARNING: Scene \"" << sceneName << "\" not found."
672   "\n  /vis/scene/list to see scenes."            409   "\n  /vis/scene/list to see scenes."
673        << G4endl;                                 410        << G4endl;
674     }                                             411     }
675     return;                                       412     return;
676   }                                               413   }
677                                                   414 
678   // Store current context...                  << 
679   G4VSceneHandler* pCurrentSceneHandler =      << 
680     fpVisManager -> GetCurrentSceneHandler();  << 
681   if (!pCurrentSceneHandler) {                 << 
682     if (verbosity >= G4VisManager::warnings) { << 
683       G4warn << "WARNING: No current scene han << 
684        << G4endl;                              << 
685     }                                          << 
686     return;                                    << 
687   }                                            << 
688   G4VViewer* pCurrentViewer = fpVisManager ->  << 
689   if (!pCurrentViewer) {                       << 
690     if (verbosity >= G4VisManager::warnings) { << 
691       G4warn << "WARNING: No current viewer."  << 
692        << G4endl;                              << 
693     }                                          << 
694     return;                                    << 
695   }                                            << 
696   G4Scene* pCurrentScene = fpVisManager -> Get << 
697   if (!pCurrentScene) {                        << 
698     if (verbosity >= G4VisManager::warnings) { << 
699       G4warn << "WARNING: No current scene."   << 
700        << G4endl;                              << 
701     }                                          << 
702     return;                                    << 
703   }                                            << 
704                                                << 
705   G4VisManager::Verbosity currentVerbosity = f << 
706                                                << 
707   // Suppress messages during this process (on << 
708   //fpVisManager -> SetVerboseLevel(G4VisManag << 
709                                                << 
710   // For each scene handler, if it contains th    415   // For each scene handler, if it contains the scene, clear and
711   // rebuild the graphical database, then for     416   // rebuild the graphical database, then for each viewer set (make
712   // current), clear, (re)draw, and show.         417   // current), clear, (re)draw, and show.
713   const std::size_t nSceneHandlers = sceneHand << 418   const G4int nSceneHandlers = sceneHandlerList.size ();
714   for (std::size_t iSH = 0; iSH < nSceneHandle << 419   for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
715     G4VSceneHandler* aSceneHandler = sceneHand    420     G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH];
716     G4Scene* aScene = aSceneHandler -> GetScen    421     G4Scene* aScene = aSceneHandler -> GetScene ();
717     if (aScene) {                                 422     if (aScene) {
718       const G4String& aSceneName = aScene -> G    423       const G4String& aSceneName = aScene -> GetName ();
719       if (sceneName == aSceneName) {              424       if (sceneName == aSceneName) {
720   aScene->CalculateExtent();  // Check and rec << 425   // Clear store and force a rebuild of graphical database...
                                                   >> 426   aSceneHandler -> ClearStore ();
721   G4ViewerList& viewerList = aSceneHandler ->     427   G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
722   const std::size_t nViewers = viewerList.size << 428   const G4int nViewers = viewerList.size ();
723   for (std::size_t iV = 0; iV < nViewers; ++iV << 429   for (G4int iV = 0; iV < nViewers; iV++) {
724     G4VViewer* aViewer = viewerList [iV];         430     G4VViewer* aViewer = viewerList [iV];
725     // Force rebuild of graphical database, if << 431     aSceneHandler -> SetCurrentViewer (aViewer);  // Temporarily.
726     aViewer -> NeedKernelVisit();              << 432     aViewer -> SetView ();  // Temporarily switch contexts.
727     if (aViewer->GetViewParameters().IsAutoRef << 433     //??aViewer -> ClearView ();
728       aSceneHandler -> SetCurrentViewer (aView << 434     aViewer -> DrawView ();
729       // Ensure consistency of vis manager...  << 435     if (flush) aViewer -> ShowView ();
730       fpVisManager -> SetCurrentViewer(aViewer << 436     if (verbosity >= G4VisManager::confirmations) {
731       fpVisManager -> SetCurrentSceneHandler(a << 437       G4cout << "Viewer \"" << aViewer -> GetName ()
732       fpVisManager -> SetCurrentScene(aScene); << 438        << "\" of scene handler \"" << aSceneHandler -> GetName ()
733       aViewer -> SetView ();                   << 439        << "\"\n  ";
734       aViewer -> ClearView ();                 << 440       if (flush) G4cout << "flushed";
735       aViewer -> DrawView ();                  << 441       else G4cout << "refreshed";
736       if (flush) aViewer -> ShowView ();       << 442       G4cout << " at request of scene \"" << sceneName
737       if (verbosity >= G4VisManager::confirmat << 443        << "\"." << G4endl;
738         G4cout << "Viewer \"" << aViewer -> Ge << 
739          << "\" of scene handler \"" << aScene << 
740          << "\"\n  ";                          << 
741         if (flush) G4cout << "flushed";        << 
742         else G4cout << "refreshed";            << 
743         G4cout << " at request of scene \"" << << 
744          << "\"." << G4endl;                   << 
745       }                                        << 
746     } else {                                   << 
747       if (verbosity >= G4VisManager::confirmat << 
748         G4cout << "NOTE: The scene, \""        << 
749          << sceneName                          << 
750          << "\", of viewer \""                 << 
751          << aViewer -> GetName ()              << 
752          << "\"\n  of scene handler \""        << 
753          << aSceneHandler -> GetName ()        << 
754          << "\"  has changed.  To see effect," << 
755          << "\n  \"/vis/viewer/select "        << 
756          << aViewer -> GetShortName ()         << 
757          << "\" and \"/vis/viewer/rebuild\"."  << 
758          << G4endl;                            << 
759       }                                        << 
760     }                                             444     }
761   }                                               445   }
762       }                                           446       }
763     }                                             447     }
764     else {                                        448     else {
765       if (verbosity >= G4VisManager::warnings)    449       if (verbosity >= G4VisManager::warnings) {
766   G4warn << "WARNING: G4VisCommandSceneNotifyH << 450   G4cout << "WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
767          << aSceneHandler->GetName()              451          << aSceneHandler->GetName()
768          << "\" has a null scene."                452          << "\" has a null scene."
769          << G4endl;                               453          << G4endl;
770       }                                           454       }
771     }                                             455     }
772   }                                               456   }
773                                                << 457   // Reclaim original context...
774   // Reclaim original context - but set viewer << 458   G4VSceneHandler* pCurrentSceneHandler =
775   // handler, because the latter might have be << 459     fpVisManager -> GetCurrentSceneHandler();
776   // and, not yet having a viewer, the current << 460   G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
777   // temporarily, refer to another scene handl << 
778   // actually resets the scene handler, which  << 
779   // so we set it again on the next line...    << 
780   fpVisManager -> SetCurrentViewer(pCurrentVie << 
781   fpVisManager -> SetCurrentSceneHandler(pCurr << 
782   fpVisManager -> SetCurrentScene(pCurrentScen << 
783   fpVisManager -> SetVerboseLevel(currentVerbo << 
784   // Take care of special case of scene handle << 
785   if (pCurrentSceneHandler) {                     461   if (pCurrentSceneHandler) {
786     G4ViewerList& viewerList = pCurrentSceneHa << 462     pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
787     const std::size_t nViewers = viewerList.si << 463     if (pCurrentViewer && pCurrentSceneHandler->GetScene())
788     if (nViewers) {                            << 464       pCurrentViewer -> SetView ();
789       pCurrentSceneHandler -> SetCurrentViewer << 
790       // JA: I don't think we need this. SetVi << 
791       // if (pCurrentViewer && pCurrentSceneHa << 
792       //   pCurrentViewer -> SetView ();       << 
793       // }                                     << 
794     }                                          << 
795   }                                               465   }
796 }                                                 466 }
797                                                   467 
798 ////////////// /vis/scene/removeModel //////// << 468 ////////////// /vis/scene/remove ///////////////////////////////////////
799                                                   469 
800 G4VisCommandSceneRemoveModel::G4VisCommandScen << 470 G4VisCommandSceneRemove::G4VisCommandSceneRemove () {
801   G4bool omitable;                             << 471   G4bool omitable, currentAsDefault;
802   fpCommand = new G4UIcommand ("/vis/scene/rem << 472   fpCommand = new G4UIcmdWithAString ("/vis/scene/remove", this);
803   fpCommand -> SetGuidance("Remove model.");   << 473   fpCommand -> SetGuidance ("/vis/scene/remove <scene-name>");
804   fpCommand -> SetGuidance                     << 474   fpCommand -> SetGuidance ("Removes scenes.");
805   ("Attempts to match search string to name of << 
806   fpCommand -> SetGuidance                        475   fpCommand -> SetGuidance
807   ("Use \"/vis/scene/list\" to see model names << 476     ("/vis/scene/list to see possibilities.");
808   G4UIparameter* parameter;                    << 477   fpCommand -> SetParameterName ("scene-name",
809   parameter = new G4UIparameter ("search-strin << 478          omitable = false,
810   fpCommand -> SetParameter (parameter);       << 479          currentAsDefault = true);
                                                   >> 480   sceneNameCommands.push_back (fpCommand);
811 }                                                 481 }
812                                                   482 
813 G4VisCommandSceneRemoveModel::~G4VisCommandSce << 483 G4VisCommandSceneRemove::~G4VisCommandSceneRemove () {
814   delete fpCommand;                               484   delete fpCommand;
815 }                                                 485 }
816                                                   486 
817 G4String G4VisCommandSceneRemoveModel::GetCurr << 487 G4String G4VisCommandSceneRemove::GetCurrentValue (G4UIcommand*) {
818   return "";                                   << 488   return CurrentSceneName ();
819 }                                                 489 }
820                                                   490 
821 void G4VisCommandSceneRemoveModel::SetNewValue << 491 void G4VisCommandSceneRemove::SetNewValue (G4UIcommand*, G4String newValue) {
822               G4String newValue) {             << 
823                                                   492 
824   G4VisManager::Verbosity verbosity = fpVisMan    493   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
825                                                   494 
826   G4String searchString;                       << 495   G4String& removeName = newValue;
827   std::istringstream is (newValue);            << 496   const G4String& currentSceneName =
828   is >> searchString;                          << 497     fpVisManager -> GetCurrentScene () -> GetName ();
829                                                << 498   G4SceneList& sceneList = fpVisManager -> SetSceneList ();
830   G4Scene* pScene = fpVisManager->GetCurrentSc << 499   G4SceneListIterator iScene;
831   if (!pScene) {                               << 500   for (iScene = sceneList.begin(); iScene != sceneList.end(); ++iScene) {
832     if (verbosity >= G4VisManager::errors) {   << 501     if ((*iScene) -> GetName () == removeName) break;
833       G4warn << "ERROR: No current scene.  Ple << 502   }
834     }                                          << 503   if (iScene != sceneList.end()) {
835     return;                                    << 504     delete *iScene;
836   }                                            << 505     sceneList.erase (iScene);
837                                                << 506     if (verbosity >= G4VisManager::confirmations) {
838   G4VSceneHandler* pSceneHandler = fpVisManage << 507       G4cout << "Scene \"" << removeName << "\" removed." << G4endl;
839   if (!pSceneHandler) {                        << 
840     if (verbosity >= G4VisManager::errors) {   << 
841       G4warn << "ERROR: No current sceneHandle << 
842     }                                             508     }
843     return;                                    << 509     UpdateCandidateLists ();
844   }                                            << 510     if (sceneList.empty ()) {
845                                                << 
846   G4bool any = false;                          << 
847                                                << 
848   std::vector<G4Scene::Model>& runDurationMode << 
849   pScene->SetRunDurationModelList();           << 
850   for (size_t i = 0; i < runDurationModelList. << 
851     const G4String& modelName =                << 
852     runDurationModelList[i].fpModel->GetGlobal << 
853     if (modelName.find(searchString) != std::s << 
854       runDurationModelList.erase(runDurationMo << 
855       any = true;                              << 
856       if (verbosity >= G4VisManager::warnings)    511       if (verbosity >= G4VisManager::warnings) {
857   G4warn << "Model \"" << modelName << "\" rem << 512   G4cout << "WARNING: No scenes left.  Please create a new one."
                                                   >> 513          << G4endl;
858       }                                           514       }
859       break;  // Allow only one model at a tim << 515       UpdateVisManagerScene ();
860     }                                             516     }
861   }                                            << 517     else {
862                                                << 518       if (currentSceneName == removeName) {
863   std::vector<G4Scene::Model>& endOfEventModel << 519   if (verbosity >= G4VisManager::warnings) {
864   pScene->SetEndOfEventModelList();            << 520     G4cout << "WARNING: Current scene is now \""
865   for (size_t i = 0; i < endOfEventModelList.s << 521      << fpVisManager -> GetCurrentScene () -> GetName ()
866     const G4String& modelName =                << 522      << "\"" << G4endl;
867     endOfEventModelList[i].fpModel->GetGlobalD << 523   }
868     if (modelName.find(searchString) != std::s << 524   UpdateVisManagerScene (sceneList [0] -> GetName ());
869       endOfEventModelList.erase(endOfEventMode << 
870       any = true;                              << 
871       if (verbosity >= G4VisManager::warnings) << 
872   G4warn << "Model \"" << modelName << "\" rem << 
873       }                                           525       }
874       break;  // Allow only one model at a tim << 526       else {
875     }                                          << 527   if (verbosity >= G4VisManager::confirmations) {
876   }                                            << 528     G4cout << "Current scene unchanged." << G4endl;
877                                                << 529   }
878   std::vector<G4Scene::Model>& endOfRunModelLi << 
879   pScene->SetEndOfRunModelList();              << 
880   for (size_t i = 0; i < endOfRunModelList.siz << 
881     const G4String& modelName =                << 
882     endOfRunModelList[i].fpModel->GetGlobalDes << 
883     if (modelName.find(searchString) != std::s << 
884       endOfRunModelList.erase(endOfRunModelLis << 
885       any = true;                              << 
886       if (verbosity >= G4VisManager::warnings) << 
887   G4warn << "Model \"" << modelName << "\" rem << 
888       }                                           530       }
889       break;  // Allow only one model at a tim << 
890     }                                             531     }
891   }                                               532   }
892                                                << 533   else {
893   if (!any) {                                  << 
894     if (verbosity >= G4VisManager::warnings) {    534     if (verbosity >= G4VisManager::warnings) {
895       G4warn << "WARNING: No match found." <<  << 535       G4cout << "WARNING: Scene \"" << removeName
                                                   >> 536        << "\" not found - \"/vis/scene/list\" to see possibilities."
                                                   >> 537        << G4endl;
896     }                                             538     }
897     return;                                    << 
898   }                                               539   }
899                                                << 
900   CheckSceneAndNotifyHandlers (pScene);        << 
901 }                                                 540 }
902                                                   541 
903 ////////////// /vis/scene/select /////////////    542 ////////////// /vis/scene/select ///////////////////////////////////////
904                                                   543 
905 G4VisCommandSceneSelect::G4VisCommandSceneSele    544 G4VisCommandSceneSelect::G4VisCommandSceneSelect () {
906   G4bool omitable;                             << 545   G4bool omitable, currentAsDefault;
907   fpCommand = new G4UIcmdWithAString ("/vis/sc    546   fpCommand = new G4UIcmdWithAString ("/vis/scene/select", this);
908   fpCommand -> SetGuidance ("Selects a scene") << 547   fpCommand -> SetGuidance ("/vis/scene/select [<scene-name>]");
                                                   >> 548   fpCommand -> SetGuidance ("Selects current scene.");
909   fpCommand -> SetGuidance                        549   fpCommand -> SetGuidance
910   ("Makes the scene current.  \"/vis/scene/lis << 550     ("Specify scene by name (\"/vis/scene/list\" to see possibilities).");
911    "\n possible scene names.");                << 551   fpCommand -> SetParameterName ("scene-name",
912   fpCommand -> SetParameterName ("scene-name", << 552          omitable = true,
                                                   >> 553          currentAsDefault = true);
                                                   >> 554   sceneNameCommands.push_back (fpCommand);
913 }                                                 555 }
914                                                   556 
915 G4VisCommandSceneSelect::~G4VisCommandSceneSel    557 G4VisCommandSceneSelect::~G4VisCommandSceneSelect () {
916   delete fpCommand;                               558   delete fpCommand;
917 }                                                 559 }
918                                                   560 
919 G4String G4VisCommandSceneSelect::GetCurrentVa    561 G4String G4VisCommandSceneSelect::GetCurrentValue (G4UIcommand*) {
920   return "";                                   << 562   return CurrentSceneName ();
921 }                                                 563 }
922                                                   564 
923 void G4VisCommandSceneSelect::SetNewValue (G4U    565 void G4VisCommandSceneSelect::SetNewValue (G4UIcommand*, G4String newValue) {
924                                                   566 
925   G4VisManager::Verbosity verbosity = fpVisMan    567   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
926                                                   568 
927   G4String& selectName = newValue;                569   G4String& selectName = newValue;
928   G4SceneList& sceneList = fpVisManager -> Set    570   G4SceneList& sceneList = fpVisManager -> SetSceneList ();
929   std::size_t iScene, nScenes = sceneList.size << 571   G4int iScene, nScenes = sceneList.size ();
930   for (iScene = 0; iScene < nScenes; ++iScene) << 572   for (iScene = 0; iScene < nScenes; iScene++) {
931     if (sceneList [iScene] -> GetName () == se    573     if (sceneList [iScene] -> GetName () == selectName) break;
932   }                                               574   }
933   if (iScene >= nScenes) {                        575   if (iScene >= nScenes) {
934     if (verbosity >= G4VisManager::warnings) {    576     if (verbosity >= G4VisManager::warnings) {
935       G4warn << "WARNING: Scene \"" << selectN << 577       G4cout << "WARNING: Scene \"" << selectName
936       << "\" not found - \"/vis/scene/list\" t << 578        << "\" not found - \"/vis/scene/list\" to see possibilities."
937       << G4endl;                               << 579        << G4endl;
938     }                                             580     }
939     return;                                       581     return;
940   }                                               582   }
941                                                   583 
942   if (verbosity >= G4VisManager::confirmations    584   if (verbosity >= G4VisManager::confirmations) {
943     G4cout << "Scene \"" << selectName            585     G4cout << "Scene \"" << selectName
944     << "\" selected." << G4endl;               << 586      << "\" selected." << G4endl;
945   }                                            << 
946                                                << 
947   CheckSceneAndNotifyHandlers (sceneList [iSce << 
948 }                                              << 
949                                                << 
950 ////////////// /vis/scene/showExtents //////// << 
951                                                << 
952 G4VisCommandSceneShowExtents::G4VisCommandScen << 
953   fpCommand = new G4UIcmdWithoutParameter ("/v << 
954   fpCommand -> SetGuidance ("Prints and draws  << 
955 }                                              << 
956                                                << 
957 G4VisCommandSceneShowExtents::~G4VisCommandSce << 
958   delete fpCommand;                            << 
959 }                                              << 
960                                                << 
961 G4String G4VisCommandSceneShowExtents::GetCurr << 
962   return "";                                   << 
963 }                                              << 
964                                                << 
965 void G4VisCommandSceneShowExtents::SetNewValue << 
966                                                << 
967   G4VisManager::Verbosity verbosity = fpVisMan << 
968                                                << 
969   G4VSceneHandler* pCurrentSceneHandler =      << 
970   fpVisManager -> GetCurrentSceneHandler();    << 
971   if (!pCurrentSceneHandler) {                 << 
972     if (verbosity >= G4VisManager::warnings) { << 
973       G4warn << "WARNING: No current scene han << 
974       << G4endl;                               << 
975     }                                          << 
976     return;                                    << 
977   }                                            << 
978   G4VViewer* pCurrentViewer = fpVisManager ->  << 
979   if (!pCurrentViewer) {                       << 
980     if (verbosity >= G4VisManager::warnings) { << 
981       G4warn << "WARNING: No current viewer."  << 
982       << G4endl;                               << 
983     }                                          << 
984     return;                                    << 
985   }                                            << 
986   G4Scene* pCurrentScene = fpVisManager -> Get << 
987   if (!pCurrentScene) {                        << 
988     if (verbosity >= G4VisManager::warnings) { << 
989       G4warn << "WARNING: No current scene."   << 
990       << G4endl;                               << 
991     }                                          << 
992     return;                                    << 
993   }                                               587   }
                                                   >> 588   UpdateVisManagerScene (selectName);
994                                                   589 
995   G4cout << "\n  Run-duration models:";        << 
996   std::size_t nRunModels = pCurrentScene -> Ge << 
997   if (nRunModels == 0) {                       << 
998     G4cout << " none.";                        << 
999   }                                            << 
1000   for (std::size_t i = 0; i < nRunModels; ++i << 
1001     if (pCurrentScene -> GetRunDurationModelL << 
1002       G4cout << "\n   Active:   ";            << 
1003     else G4cout << "\n   Inactive: ";         << 
1004     G4VModel* pModel = pCurrentScene -> GetRu << 
1005     const G4VisExtent& transformedExtent = pM << 
1006     G4cout << pModel -> GetGlobalDescription  << 
1007     << "\n" << transformedExtent;             << 
1008     DrawExtent(transformedExtent);            << 
1009   }                                           << 
1010   G4cout << "\n  End-of-event models:";       << 
1011   std::size_t nEOEModels = pCurrentScene -> G << 
1012   if (nEOEModels == 0) {                      << 
1013     G4cout << " none.";                       << 
1014   }                                           << 
1015   for (std::size_t i = 0; i < nEOEModels; ++i << 
1016     if (pCurrentScene -> GetEndOfEventModelLi << 
1017       G4cout << "\n   Active:   ";            << 
1018     else G4cout << "\n   Inactive: ";         << 
1019     G4VModel* pModel = pCurrentScene -> GetEn << 
1020     const G4VisExtent& transformedExtent = pM << 
1021     G4cout << pModel -> GetGlobalDescription  << 
1022     << "\n" << transformedExtent;             << 
1023     DrawExtent(transformedExtent);            << 
1024   }                                           << 
1025   G4cout << "\n  End-of-run models:";         << 
1026   std::size_t nEORModels = pCurrentScene -> G << 
1027   if (nEORModels == 0) {                      << 
1028     G4cout << " none.";                       << 
1029   }                                           << 
1030   for (std::size_t i = 0; i < nEORModels; ++i << 
1031     if (pCurrentScene -> GetEndOfRunModelList << 
1032       G4cout << "\n   Active:   ";            << 
1033     else G4cout << "\n   Inactive: ";         << 
1034     G4VModel* pModel = pCurrentScene -> GetEn << 
1035     const G4VisExtent& transformedExtent = pM << 
1036     G4cout << pModel -> GetGlobalDescription  << 
1037     << "\n" << transformedExtent;             << 
1038     DrawExtent(transformedExtent);            << 
1039   }                                           << 
1040   G4cout << "\n  Overall extent:\n";          << 
1041   DrawExtent(pCurrentScene->GetExtent());     << 
1042   G4cout << G4endl;                           << 
1043 }                                                590 }
1044                                                  591