Geant4 Cross Reference

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


  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: G4VisCommandsViewer.cc,v 1.37 2003/06/16 17:14:25 gunter Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-05-02-patch-01 $
 27                                                    26 
 28 // /vis/viewer commands - John Allison  25th O     27 // /vis/viewer commands - John Allison  25th October 1998
 29                                                    28 
 30 #include "G4VisCommandsViewer.hh"                  29 #include "G4VisCommandsViewer.hh"
 31                                                    30 
 32 #include "G4VisManager.hh"                         31 #include "G4VisManager.hh"
 33 #include "G4GraphicsSystemList.hh"                 32 #include "G4GraphicsSystemList.hh"
 34 #include "G4VisCommandsScene.hh"                   33 #include "G4VisCommandsScene.hh"
 35 #include "G4UImanager.hh"                          34 #include "G4UImanager.hh"
 36 #include "G4UIcommand.hh"                          35 #include "G4UIcommand.hh"
 37 #include "G4UIcmdWithoutParameter.hh"          << 
 38 #include "G4UIcmdWithAString.hh"                   36 #include "G4UIcmdWithAString.hh"
 39 #include "G4UIcmdWithADouble.hh"                   37 #include "G4UIcmdWithADouble.hh"
 40 #include "G4UIcmdWithADoubleAndUnit.hh"            38 #include "G4UIcmdWithADoubleAndUnit.hh"
 41 #include "G4UIcmdWith3Vector.hh"               << 
 42 #include "G4PhysicalVolumesSearchScene.hh"     << 
 43 #include "G4TransportationManager.hh"          << 
 44 #include "G4Point3D.hh"                        << 
 45 #include "G4SystemOfUnits.hh"                  << 
 46 #include "G4UnitsTable.hh"                         39 #include "G4UnitsTable.hh"
 47 #include "G4Filesystem.hh"                     <<  40 #include "G4ios.hh"
 48 #include <chrono>                              <<  41 #include <strstream>
 49 #include <thread>                              << 
 50 #include <sstream>                             << 
 51 #include <fstream>                             << 
 52 #include <iomanip>                             << 
 53 #include <cstdio>                              << 
 54 #include <regex>                               << 
 55 #include <set>                                 << 
 56                                                    42 
 57 #define G4warn G4cout                          <<  43 G4VVisCommandViewer::G4VVisCommandViewer () {}
 58                                                    44 
 59 ////////////// /vis/viewer/addCutawayPlane /// <<  45 G4VVisCommandViewer::~G4VVisCommandViewer () {}
 60                                                    46 
 61 G4VisCommandViewerAddCutawayPlane::G4VisComman <<  47 void G4VVisCommandViewer::SetViewParameters
 62   G4bool omitable;                             <<  48 (G4VViewer* viewer, const G4ViewParameters& viewParams) {
 63   fpCommand = new G4UIcommand ("/vis/viewer/ad << 
 64   fpCommand -> SetGuidance                     << 
 65     ("Add cutaway plane to current viewer.");  << 
 66   G4UIparameter* parameter;                    << 
 67   parameter  =  new G4UIparameter("x",'d',omit << 
 68   parameter  -> SetDefaultValue  (0);          << 
 69   parameter  -> SetGuidance      ("Coordinate  << 
 70   fpCommand->SetParameter(parameter);          << 
 71   parameter  =  new G4UIparameter("y",'d',omit << 
 72   parameter  -> SetDefaultValue  (0);          << 
 73   parameter  -> SetGuidance      ("Coordinate  << 
 74   fpCommand->SetParameter(parameter);          << 
 75   parameter  =  new G4UIparameter("z",'d',omit << 
 76   parameter  -> SetDefaultValue  (0);          << 
 77   parameter  -> SetGuidance      ("Coordinate  << 
 78   fpCommand->SetParameter(parameter);          << 
 79   parameter  =  new G4UIparameter("unit",'s',o << 
 80   parameter  -> SetDefaultValue  ("m");        << 
 81   parameter  -> SetGuidance      ("Unit of poi << 
 82   fpCommand->SetParameter(parameter);          << 
 83   parameter  =  new G4UIparameter("nx",'d',omi << 
 84   parameter  -> SetDefaultValue  (1);          << 
 85   parameter  -> SetGuidance      ("Component o << 
 86   fpCommand->SetParameter(parameter);          << 
 87   parameter  =  new G4UIparameter("ny",'d',omi << 
 88   parameter  -> SetDefaultValue  (0);          << 
 89   parameter  -> SetGuidance      ("Component o << 
 90   fpCommand->SetParameter(parameter);          << 
 91   parameter  =  new G4UIparameter("nz",'d',omi << 
 92   parameter  -> SetDefaultValue  (0);          << 
 93   parameter  -> SetGuidance      ("Component o << 
 94   fpCommand->SetParameter(parameter);          << 
 95 }                                              << 
 96                                                << 
 97 G4VisCommandViewerAddCutawayPlane::~G4VisComma << 
 98   delete fpCommand;                            << 
 99 }                                              << 
100                                                << 
101 G4String G4VisCommandViewerAddCutawayPlane::Ge << 
102   return "";                                   << 
103 }                                              << 
104                                                << 
105 void G4VisCommandViewerAddCutawayPlane::SetNew << 
106                                                << 
107   G4VisManager::Verbosity verbosity = fpVisMan << 
108                                                << 
109   G4VViewer* viewer = fpVisManager -> GetCurre << 
110   if (!viewer) {                               << 
111     if (verbosity >= G4VisManager::errors) {   << 
112       G4warn <<                                << 
113   "ERROR: No current viewer - \"/vis/viewer/li << 
114        << G4endl;                              << 
115     }                                          << 
116     return;                                    << 
117   }                                            << 
118                                                << 
119   G4double x, y, z, nx, ny, nz;                << 
120   G4String unit;                               << 
121   std::istringstream is (newValue);            << 
122   is >> x >> y >> z >> unit >> nx >> ny >> nz; << 
123   G4double F = G4UIcommand::ValueOf(unit);     << 
124   x *= F; y *= F; z *= F;                      << 
125                                                << 
126   G4ViewParameters vp = viewer->GetViewParamet << 
127   // Make sure normal is normalised.           << 
128   vp.AddCutawayPlane(G4Plane3D(G4Normal3D(nx,n << 
129   if (verbosity >= G4VisManager::confirmations << 
130     G4cout << "Cutaway planes for viewer \"" < << 
131     const G4Planes& cutaways = vp.GetCutawayPl << 
132     for (std::size_t i = 0; i < cutaways.size( << 
133       G4cout << "\n  " << i << ": " << cutaway << 
134     G4cout << G4endl;                          << 
135   }                                            << 
136                                                << 
137   SetViewParameters(viewer, vp);               << 
138 }                                              << 
139                                                << 
140 ////////////// /vis/viewer/centreOn ////////// << 
141                                                << 
142 G4VisCommandViewerCentreOn::G4VisCommandViewer << 
143   G4bool omitable;                             << 
144   fpCommandCentreAndZoomInOn = new G4UIcommand << 
145   fpCommandCentreAndZoomInOn->SetGuidance      << 
146   ("Centre and zoom in on the given physical v << 
147   fpCommandCentreAndZoomInOn->SetGuidance      << 
148   ("The names of all volumes in all worlds are << 
149    "\ncopy-no is supplied, it matches the copy << 
150    "\nform \"/regexp/\", where regexp is a reg << 
151    "\nthe match uses the usual rules of regula << 
152    "\nOtherwise an exact match is required."   << 
153    "\nFor example, \"/Shap/\" matches \"Shape1 << 
154   fpCommandCentreAndZoomInOn->SetGuidance      << 
155   ("It may help to see a textual representatio << 
156    "\nthe worlds. Try \"/vis/drawTree [worlds] << 
157    "\ncombinations that have the required func << 
158   fpCommandCentreAndZoomInOn->SetGuidance      << 
159    ("If there are more than one matching physi << 
160     "\nincluded. If this is not what you want, << 
161     "\nparticular touchable, then select the t << 
162     "\nuse \"/vis/touchable/centreOn\". (You m << 
163   G4UIparameter* parameter;                    << 
164   parameter =  new G4UIparameter("pv-name",'s' << 
165   parameter->SetGuidance      ("Physical volum << 
166   fpCommandCentreAndZoomInOn->SetParameter(par << 
167   parameter =  new G4UIparameter("copy-no",'i' << 
168   parameter->SetDefaultValue  (-1);            << 
169   parameter->SetGuidance      ("Copy number. - << 
170   fpCommandCentreAndZoomInOn->SetParameter(par << 
171                                                << 
172   fpCommandCentreOn = new G4UIcommand ("/vis/v << 
173   fpCommandCentreOn->SetGuidance ("Centre the  << 
174   // Pick up additional guidance from /vis/vie << 
175   CopyGuidanceFrom(fpCommandCentreAndZoomInOn, << 
176   // Pick up parameters from /vis/viewer/centr << 
177   CopyParametersFrom(fpCommandCentreAndZoomInO << 
178 }                                              << 
179                                                << 
180 G4VisCommandViewerCentreOn::~G4VisCommandViewe << 
181   delete fpCommandCentreAndZoomInOn;           << 
182   delete fpCommandCentreOn;                    << 
183 }                                              << 
184                                                << 
185 G4String G4VisCommandViewerCentreOn::GetCurren << 
186   return "";                                   << 
187 }                                              << 
188                                                << 
189 void G4VisCommandViewerCentreOn::SetNewValue ( << 
190                                                << 
191   G4VisManager::Verbosity verbosity = fpVisMan     49   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
192   G4bool warn = verbosity >= G4VisManager::war <<  50   viewer->SetViewParameters(viewParams);
193                                                <<  51   G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
194   G4VViewer* currentViewer = fpVisManager -> G <<  52   if (sceneHandler && sceneHandler->GetScene()) {
195   if (!currentViewer) {                        <<  53     if (viewParams.IsAutoRefresh()) {
196     if (verbosity >= G4VisManager::errors) {   <<  54       G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
197       G4warn <<                                << 
198       "ERROR: No current viewer - \"/vis/viewe << 
199       << G4endl;                               << 
200     }                                          << 
201     return;                                    << 
202   }                                            << 
203                                                << 
204   G4String pvName;                             << 
205   G4int copyNo;                                << 
206   std::istringstream is (newValue);            << 
207   is >> pvName >> copyNo;                      << 
208                                                << 
209   // Find physical volumes                     << 
210   G4TransportationManager* transportationManag << 
211   G4TransportationManager::GetTransportationMa << 
212   std::size_t nWorlds = transportationManager- << 
213   std::vector<G4PhysicalVolumesSearchScene::Fi << 
214   std::vector<G4VPhysicalVolume*>::iterator it << 
215   transportationManager->GetWorldsIterator();  << 
216   for (std::size_t i = 0; i < nWorlds; ++i, ++ << 
217     G4PhysicalVolumeModel searchModel (*iterWo << 
218     G4ModelingParameters mp;  // Default - no  << 
219     searchModel.SetModelingParameters (&mp);   << 
220     // Find all instances at any position in t << 
221     G4PhysicalVolumesSearchScene searchScene ( << 
222     searchModel.DescribeYourselfTo (searchScen << 
223     for (const auto& findings: searchScene.Get << 
224       findingsVector.push_back(findings);      << 
225     }                                              55     }
226   }                                            <<  56     else {
227                                                <<  57       if (verbosity >= G4VisManager::confirmations) {
228   if (findingsVector.empty()) {                <<  58   G4cout << "Issue /vis/viewer/refresh to see effect." << G4endl;
229     if (verbosity >= G4VisManager::warnings) { << 
230       G4warn                                   << 
231       << "WARNING: Volume \"" << pvName << "\" << 
232       if (copyNo > 0) {                        << 
233         G4warn << "copy number " << copyNo;    << 
234       }                                            59       }
235       G4warn << " not found." << G4endl;       << 
236     }                                          << 
237     return;                                    << 
238   }                                            << 
239                                                << 
240   // A vector of found paths so that we can hi << 
241   std::vector<std::vector<G4PhysicalVolumeMode << 
242                                                << 
243   // Use a temporary scene in order to find vi << 
244   G4Scene tempScene("Centre Scene");           << 
245   G4bool successfullyAdded = true;             << 
246   for (const auto& findings: findingsVector) { << 
247     // To handle paramaterisations we have to  << 
248     findings.fpFoundPV->SetCopyNo(findings.fFo << 
249     // Create a temporary physical volume mode << 
250     // They have to be created on the heap bec << 
251     // to hang about long enough to be conflat << 
252     G4PhysicalVolumeModel* tempPVModel = new G << 
253     (findings.fpFoundPV,                       << 
254      0, // Only interested in top volume       << 
255      findings.fFoundObjectTransformation,      << 
256      0, // No modelling parameters (these are  << 
257      true,  // Use full extent                 << 
258      findings.fFoundBasePVPath);               << 
259     // ...and add it to the scene.             << 
260     auto successful = tempScene.AddRunDuration << 
261     if (!successful) {                         << 
262       successfullyAdded = false;               << 
263       continue;                                << 
264     }                                          << 
265     if (verbosity >= G4VisManager::parameters) << 
266       G4cout << "\"" << findings.fpFoundPV->Ge << 
267       << "\", copy no. " << findings.fFoundPVC << 
268       << ",\n  found in searched volume \""    << 
269       << findings.fpSearchPV->GetName()        << 
270       << "\" at depth " << findings.fFoundDept << 
271       << ",\n  base path: \"" << findings.fFou << 
272       << ",\n  has been added to temporary sce << 
273       << G4endl;                               << 
274     }                                          << 
275     foundPaths.push_back(findings.fFoundFullPV << 
276   }                                            << 
277   // Delete temporary physical volume models   << 
278   for (const auto& sceneModel: tempScene.GetRu << 
279     delete sceneModel.fpModel;                 << 
280   }                                            << 
281   if (!successfullyAdded) return;              << 
282                                                << 
283   // Relevant results                          << 
284   const G4VisExtent& newExtent = tempScene.Get << 
285   const G4ThreeVector& newTargetPoint = newExt << 
286                                                << 
287   G4Scene* currentScene = currentViewer->GetSc << 
288   G4ViewParameters saveVP = currentViewer->Get << 
289   G4ViewParameters newVP = saveVP;             << 
290   if (command == fpCommandCentreAndZoomInOn) { << 
291     // Calculate the new zoom factor           << 
292     const G4double zoomFactor                  << 
293     = currentScene->GetExtent().GetExtentRadiu << 
294     newVP.SetZoomFactor(zoomFactor);           << 
295   }                                            << 
296   // Change the target point                   << 
297   const G4Point3D& standardTargetPoint = curre << 
298   newVP.SetCurrentTargetPoint(newTargetPoint - << 
299                                                << 
300   // If this particular view is simple enough  << 
301   if (currentViewer->GetKernelVisitElapsedTime << 
302     // Interpolate                             << 
303     auto keepVisVerbosity = fpVisManager->GetV << 
304     fpVisManager->SetVerboseLevel(G4VisManager << 
305     if (newVP != saveVP) InterpolateToNewView( << 
306     // ...and twinkle                          << 
307     Twinkle(currentViewer,newVP,foundPaths);   << 
308     fpVisManager->SetVerboseLevel(keepVisVerbo << 
309   }                                            << 
310                                                << 
311   if (verbosity >= G4VisManager::confirmations << 
312     G4cout                                     << 
313     << "Viewer \"" << currentViewer->GetName() << 
314     << "\" centred ";                          << 
315     if (fpCommandCentreAndZoomInOn) {          << 
316       G4cout << "and zoomed in";               << 
317     }                                              60     }
318     G4cout << " on physical volume(s) \"" << p << 
319     << G4endl;                                 << 
320   }                                                61   }
321                                                << 
322   SetViewParameters(currentViewer, newVP);     << 
323 }                                              << 
324                                                << 
325 ////////////// /vis/viewer/changeCutawayPlane  << 
326                                                << 
327 G4VisCommandViewerChangeCutawayPlane::G4VisCom << 
328   G4bool omitable;                             << 
329   fpCommand = new G4UIcommand ("/vis/viewer/ch << 
330   fpCommand -> SetGuidance("Change cutaway pla << 
331   G4UIparameter* parameter;                    << 
332   parameter  =  new G4UIparameter("index",'i', << 
333   parameter  -> SetGuidance      ("Index of pl << 
334   fpCommand->SetParameter(parameter);          << 
335   parameter  =  new G4UIparameter("x",'d',omit << 
336   parameter  -> SetDefaultValue  (0);          << 
337   parameter  -> SetGuidance      ("Coordinate  << 
338   fpCommand->SetParameter(parameter);          << 
339   parameter  =  new G4UIparameter("y",'d',omit << 
340   parameter  -> SetDefaultValue  (0);          << 
341   parameter  -> SetGuidance      ("Coordinate  << 
342   fpCommand->SetParameter(parameter);          << 
343   parameter  =  new G4UIparameter("z",'d',omit << 
344   parameter  -> SetDefaultValue  (0);          << 
345   parameter  -> SetGuidance      ("Coordinate  << 
346   fpCommand->SetParameter(parameter);          << 
347   parameter  =  new G4UIparameter("unit",'s',o << 
348   parameter  -> SetDefaultValue  ("m");        << 
349   parameter  -> SetGuidance      ("Unit of poi << 
350   fpCommand->SetParameter(parameter);          << 
351   parameter  =  new G4UIparameter("nx",'d',omi << 
352   parameter  -> SetDefaultValue  (1);          << 
353   parameter  -> SetGuidance      ("Component o << 
354   fpCommand->SetParameter(parameter);          << 
355   parameter  =  new G4UIparameter("ny",'d',omi << 
356   parameter  -> SetDefaultValue  (0);          << 
357   parameter  -> SetGuidance      ("Component o << 
358   fpCommand->SetParameter(parameter);          << 
359   parameter  =  new G4UIparameter("nz",'d',omi << 
360   parameter  -> SetDefaultValue  (0);          << 
361   parameter  -> SetGuidance      ("Component o << 
362   fpCommand->SetParameter(parameter);          << 
363 }                                              << 
364                                                << 
365 G4VisCommandViewerChangeCutawayPlane::~G4VisCo << 
366   delete fpCommand;                            << 
367 }                                                  62 }
368                                                    63 
369 G4String G4VisCommandViewerChangeCutawayPlane: <<  64 void G4VVisCommandViewer::UpdateCandidateLists () {
370   return "";                                   << 
371 }                                              << 
372                                                << 
373 void G4VisCommandViewerChangeCutawayPlane::Set << 
374                                                    65 
375   G4VisManager::Verbosity verbosity = fpVisMan <<  66   const G4SceneHandlerList& sceneHandlerList =
                                                   >>  67     fpVisManager -> GetAvailableSceneHandlers ();
                                                   >>  68   G4int nHandlers = sceneHandlerList.size ();
376                                                    69 
377   G4VViewer* viewer = fpVisManager -> GetCurre <<  70   G4String viewerNameList;
378   if (!viewer) {                               <<  71   for (int iHandler = 0; iHandler < nHandlers; iHandler++) {
379     if (verbosity >= G4VisManager::errors) {   <<  72     G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
380       G4warn <<                                <<  73     const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
381   "ERROR: No current viewer - \"/vis/viewer/li <<  74     for (size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
382        << G4endl;                              <<  75       viewerNameList += viewerList [iViewer] -> GetShortName () + " ";
383     }                                              76     }
384     return;                                    << 
385   }                                                77   }
386                                                <<  78   viewerNameList = viewerNameList.strip ();
387   std::size_t index;                           <<  79   viewerNameCommandsIterator i;
388   G4double x, y, z, nx, ny, nz;                <<  80   for (i = viewerNameCommands.begin (); i != viewerNameCommands.end (); ++i) {
389   G4String unit;                               <<  81     (*i)->GetParameter (0) -> SetParameterCandidates (viewerNameList);
390   std::istringstream is (newValue);            << 
391   is >> index >> x >> y >> z >> unit >> nx >>  << 
392   G4double F = G4UIcommand::ValueOf(unit);     << 
393   x *= F; y *= F; z *= F;                      << 
394                                                << 
395   G4ViewParameters vp = viewer->GetViewParamet << 
396   // Make sure normal is normalised.           << 
397   vp.ChangeCutawayPlane(index,                 << 
398       G4Plane3D(G4Normal3D(nx,ny,nz).unit(), G << 
399   if (verbosity >= G4VisManager::confirmations << 
400     G4cout << "Cutaway planes for viewer \"" < << 
401     const G4Planes& cutaways = vp.GetCutawayPl << 
402     for (std::size_t i = 0; i < cutaways.size( << 
403       G4cout << "\n  " << i << ": " << cutaway << 
404     G4cout << G4endl;                          << 
405   }                                                82   }
406                                                << 
407   SetViewParameters(viewer, vp);               << 
408 }                                                  83 }
409                                                    84 
410 ////////////// /vis/viewer/clear /////////////     85 ////////////// /vis/viewer/clear ///////////////////////////////////////
411                                                    86 
412 G4VisCommandViewerClear::G4VisCommandViewerCle     87 G4VisCommandViewerClear::G4VisCommandViewerClear () {
413   G4bool omitable, currentAsDefault;               88   G4bool omitable, currentAsDefault;
414   fpCommand = new G4UIcmdWithAString ("/vis/vi     89   fpCommand = new G4UIcmdWithAString ("/vis/viewer/clear", this);
                                                   >>  90   fpCommand -> SetGuidance ("/vis/viewer/clear [<viewer-name>]");
415   fpCommand -> SetGuidance ("Clears viewer.");     91   fpCommand -> SetGuidance ("Clears viewer.");
416   fpCommand -> SetGuidance                     <<  92   fpCommand -> SetGuidance ("Viewer becomes current.");
417     ("By default, clears current viewer.  Spec <<  93   fpCommand -> SetGuidance
418      "\n\"/vis/viewer/list\" to see  possible  <<  94     ("Specify viewer by name (\"/vis/viewer/list\""
                                                   >>  95      "\n  to see possibilities).");
419   fpCommand -> SetParameterName ("viewer-name"     96   fpCommand -> SetParameterName ("viewer-name",
420          omitable = true,                          97          omitable = true,
421          currentAsDefault = true);                 98          currentAsDefault = true);
                                                   >>  99   viewerNameCommands.push_back (fpCommand);
422 }                                                 100 }
423                                                   101 
424 G4VisCommandViewerClear::~G4VisCommandViewerCl    102 G4VisCommandViewerClear::~G4VisCommandViewerClear () {
425   delete fpCommand;                               103   delete fpCommand;
426 }                                                 104 }
427                                                   105 
428 G4String G4VisCommandViewerClear::GetCurrentVa    106 G4String G4VisCommandViewerClear::GetCurrentValue (G4UIcommand*) {
429   G4VViewer* viewer = fpVisManager -> GetCurre    107   G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
430   return viewer ? viewer -> GetName () : G4Str << 108   if (viewer) {
                                                   >> 109     return viewer -> GetName ();
                                                   >> 110   }
                                                   >> 111   else {
                                                   >> 112     return "none";
                                                   >> 113   }
431 }                                                 114 }
432                                                   115 
433 void G4VisCommandViewerClear::SetNewValue (G4U    116 void G4VisCommandViewerClear::SetNewValue (G4UIcommand*, G4String newValue) {
434                                                   117 
435   G4VisManager::Verbosity verbosity = fpVisMan    118   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
436                                                   119 
437   G4String& clearName = newValue;                 120   G4String& clearName = newValue;
438   G4VViewer* viewer = fpVisManager -> GetViewe    121   G4VViewer* viewer = fpVisManager -> GetViewer (clearName);
439   if (!viewer) {                                  122   if (!viewer) {
440     if (verbosity >= G4VisManager::errors) {      123     if (verbosity >= G4VisManager::errors) {
441       G4warn << "ERROR: Viewer \"" << clearNam << 124       G4cout << "ERROR: Viewer \"" << clearName
442        << "\" not found - \"/vis/viewer/list\"    125        << "\" not found - \"/vis/viewer/list\" to see possibilities."
443        << G4endl;                                 126        << G4endl;
444     }                                             127     }
445     return;                                       128     return;
446   }                                               129   }
447                                                   130 
448   viewer->SetView();                           << 
449   viewer->ClearView();                            131   viewer->ClearView();
450   viewer->FinishView();                           132   viewer->FinishView();
451   if (verbosity >= G4VisManager::confirmations    133   if (verbosity >= G4VisManager::confirmations) {
452     G4cout << "Viewer \"" << clearName << "\"     134     G4cout << "Viewer \"" << clearName << "\" cleared." << G4endl;
453   }                                               135   }
454                                                   136 
455 }                                                 137 }
456                                                   138 
457 ////////////// /vis/viewer/clearCutawayPlanes  << 
458                                                << 
459 G4VisCommandViewerClearCutawayPlanes::G4VisCom << 
460   fpCommand = new G4UIcmdWithoutParameter      << 
461     ("/vis/viewer/clearCutawayPlanes", this);  << 
462   fpCommand -> SetGuidance ("Clear cutaway pla << 
463 }                                              << 
464                                                << 
465 G4VisCommandViewerClearCutawayPlanes::~G4VisCo << 
466   delete fpCommand;                            << 
467 }                                              << 
468                                                << 
469 G4String G4VisCommandViewerClearCutawayPlanes: << 
470   return "";                                   << 
471 }                                              << 
472                                                << 
473 void G4VisCommandViewerClearCutawayPlanes::Set << 
474                                                << 
475   G4VisManager::Verbosity verbosity = fpVisMan << 
476                                                << 
477   G4VViewer* viewer = fpVisManager -> GetCurre << 
478   if (!viewer) {                               << 
479     if (verbosity >= G4VisManager::errors) {   << 
480       G4warn <<                                << 
481   "ERROR: No current viewer - \"/vis/viewer/li << 
482        << G4endl;                              << 
483     }                                          << 
484     return;                                    << 
485   }                                            << 
486                                                << 
487   G4ViewParameters vp = viewer->GetViewParamet << 
488   vp.ClearCutawayPlanes();                     << 
489   if (verbosity >= G4VisManager::confirmations << 
490     G4cout << "Cutaway planes for viewer \"" < << 
491      << "\" now cleared." << G4endl;           << 
492   }                                            << 
493                                                << 
494   SetViewParameters(viewer, vp);               << 
495 }                                              << 
496                                                << 
497 ////////////// /vis/viewer/clearTransients /// << 
498                                                << 
499 G4VisCommandViewerClearTransients::G4VisComman << 
500   G4bool omitable, currentAsDefault;           << 
501   fpCommand = new G4UIcmdWithAString ("/vis/vi << 
502   fpCommand -> SetGuidance ("Clears transients << 
503   fpCommand -> SetGuidance                     << 
504   ("By default, operates on current viewer.  S << 
505      "\n\"/vis/viewer/list\" to see  possible  << 
506   fpCommand -> SetParameterName ("viewer-name" << 
507          omitable = true,                      << 
508          currentAsDefault = true);             << 
509 }                                              << 
510                                                << 
511 G4VisCommandViewerClearTransients::~G4VisComma << 
512   delete fpCommand;                            << 
513 }                                              << 
514                                                << 
515 G4String G4VisCommandViewerClearTransients::Ge << 
516   G4VViewer* viewer = fpVisManager -> GetCurre << 
517   return viewer ? viewer -> GetName () : G4Str << 
518 }                                              << 
519                                                << 
520 void G4VisCommandViewerClearTransients::SetNew << 
521                                                << 
522   G4VisManager::Verbosity verbosity = fpVisMan << 
523                                                << 
524   G4String& clearName = newValue;              << 
525   G4VViewer* viewer = fpVisManager -> GetViewe << 
526   if (!viewer) {                               << 
527     if (verbosity >= G4VisManager::errors) {   << 
528       G4warn << "ERROR: Viewer \"" << clearNam << 
529        << "\" not found - \"/vis/viewer/list\" << 
530        << G4endl;                              << 
531     }                                          << 
532     return;                                    << 
533   }                                            << 
534                                                << 
535   G4VSceneHandler* sceneHandler = viewer->GetS << 
536   sceneHandler->SetMarkForClearingTransientSto << 
537   fpVisManager->ResetTransientsDrawnFlags();   << 
538   sceneHandler->ClearTransientStore();         << 
539   if (verbosity >= G4VisManager::confirmations << 
540     G4cout << "Viewer \"" << clearName << "\"  << 
541      << G4endl;                                << 
542   }                                            << 
543                                                << 
544 }                                              << 
545                                                << 
546 ////////////// /vis/viewer/clearVisAttributesM << 
547                                                << 
548 G4VisCommandViewerClearVisAttributesModifiers: << 
549   fpCommand = new G4UIcmdWithoutParameter      << 
550   ("/vis/viewer/clearVisAttributesModifiers",  << 
551   fpCommand -> SetGuidance ("Clear vis attribu << 
552   fpCommand -> SetGuidance ("(These are used f << 
553 }                                              << 
554                                                << 
555 G4VisCommandViewerClearVisAttributesModifiers: << 
556   delete fpCommand;                            << 
557 }                                              << 
558                                                << 
559 G4String G4VisCommandViewerClearVisAttributesM << 
560   return "";                                   << 
561 }                                              << 
562                                                << 
563 void G4VisCommandViewerClearVisAttributesModif << 
564                                                << 
565   G4VisManager::Verbosity verbosity = fpVisMan << 
566                                                << 
567   G4VViewer* viewer = fpVisManager -> GetCurre << 
568   if (!viewer) {                               << 
569     if (verbosity >= G4VisManager::errors) {   << 
570       G4warn <<                                << 
571       "ERROR: No current viewer - \"/vis/viewe << 
572        << G4endl;                              << 
573     }                                          << 
574     return;                                    << 
575   }                                            << 
576                                                << 
577   G4ViewParameters vp = viewer->GetViewParamet << 
578   vp.ClearVisAttributesModifiers();            << 
579   if (verbosity >= G4VisManager::confirmations << 
580     G4cout << "Vis attributes modifiers for vi << 
581      << "\" now cleared." << G4endl;           << 
582   }                                            << 
583                                                << 
584   SetViewParameters(viewer, vp);               << 
585 }                                              << 
586                                                << 
587 ////////////// /vis/viewer/clone ///////////// << 
588                                                << 
589 G4VisCommandViewerClone::G4VisCommandViewerClo << 
590   G4bool omitable;                             << 
591   fpCommand = new G4UIcommand ("/vis/viewer/cl << 
592   fpCommand -> SetGuidance ("Clones viewer."); << 
593   fpCommand -> SetGuidance                     << 
594     ("By default, clones current viewer.  Clon << 
595      "\nClone name, if not provided, is derive << 
596      "\n\"/vis/viewer/list\" to see  possible  << 
597   G4UIparameter* parameter;                    << 
598   parameter = new G4UIparameter ("original-vie << 
599   parameter -> SetCurrentAsDefault (true);     << 
600   fpCommand -> SetParameter (parameter);       << 
601   parameter = new G4UIparameter ("clone-name", << 
602   parameter -> SetDefaultValue ("none");       << 
603   fpCommand -> SetParameter (parameter);       << 
604 }                                              << 
605                                                << 
606 G4VisCommandViewerClone::~G4VisCommandViewerCl << 
607   delete fpCommand;                            << 
608 }                                              << 
609                                                << 
610 G4String G4VisCommandViewerClone::GetCurrentVa << 
611   G4VViewer* viewer = fpVisManager -> GetCurre << 
612   G4String originalName = viewer ? viewer -> G << 
613   return "\"" + originalName + "\"";           << 
614 }                                              << 
615                                                << 
616 void G4VisCommandViewerClone::SetNewValue (G4U << 
617                                                << 
618   G4VisManager::Verbosity verbosity = fpVisMan << 
619                                                << 
620   G4String originalName, cloneName;            << 
621   std::istringstream is (newValue);            << 
622                                                << 
623   // Need to handle the possibility that the n << 
624   // blanks within quotation marks...          << 
625   char c = ' ';                                << 
626   while (is.get(c) && c == ' '){}              << 
627   if (c == '"') {                              << 
628     while (is.get(c) && c != '"') {originalNam << 
629   }                                            << 
630   else {                                       << 
631     originalName += c;                         << 
632     while (is.get(c) && c != ' ') {originalNam << 
633   }                                            << 
634   G4StrUtil::strip(originalName, ' ');         << 
635   G4StrUtil::strip(originalName, '"');         << 
636                                                << 
637   G4VViewer* originalViewer = fpVisManager ->  << 
638   if (!originalViewer) {                       << 
639     if (verbosity >= G4VisManager::errors) {   << 
640       G4warn << "ERROR: Viewer \"" << original << 
641        << "\" not found - \"/vis/viewer/list\" << 
642        << G4endl;                              << 
643     }                                          << 
644     return;                                    << 
645   }                                            << 
646   originalName = originalViewer->GetName();  / << 
647                                                << 
648   while (is.get(c) && c == ' '){}              << 
649   if (c == '"') {                              << 
650     while (is.get(c) && c != '"') {cloneName + << 
651   }                                            << 
652   else {                                       << 
653     cloneName += c;                            << 
654     while (is.get(c) && c != ' ') {cloneName + << 
655   }                                            << 
656   G4StrUtil::strip(cloneName, ' ');            << 
657   G4StrUtil::strip(cloneName, '"');            << 
658                                                << 
659   G4bool errorWhileNaming = false;             << 
660   if (cloneName == "none") {                   << 
661     G4int subID = 0;                           << 
662     do {                                       << 
663       cloneName = originalName;                << 
664       std::ostringstream oss;                  << 
665       oss << '-' << subID++;                   << 
666       G4String::size_type lastDashPosition, ne << 
667       if ((lastDashPosition = cloneName.rfind( << 
668     (nextSpacePosition = cloneName.find(" ", l << 
669     G4String::npos) {                          << 
670   cloneName.insert(nextSpacePosition, oss.str( << 
671       } else {                                 << 
672   G4String::size_type spacePosition = cloneNam << 
673   if (spacePosition != G4String::npos)         << 
674     cloneName.insert(spacePosition, oss.str()) << 
675   else                                         << 
676     errorWhileNaming = true;                   << 
677       }                                        << 
678     } while (!errorWhileNaming && fpVisManager << 
679   }                                            << 
680                                                << 
681   if (errorWhileNaming) {                      << 
682     if (verbosity >= G4VisManager::errors) {   << 
683       G4warn << "ERROR: While naming clone vie << 
684        << "\"."                                << 
685        << G4endl;                              << 
686     }                                          << 
687     return;                                    << 
688   }                                            << 
689                                                << 
690   if (fpVisManager -> GetViewer (cloneName)) { << 
691     if (verbosity >= G4VisManager::errors) {   << 
692       G4warn << "ERROR: Putative clone viewer  << 
693        << "\" already exists."                 << 
694        << G4endl;                              << 
695     }                                          << 
696     return;                                    << 
697   }                                            << 
698                                                << 
699   G4String windowSizeHint =                    << 
700     originalViewer->GetViewParameters().GetXGe << 
701                                                << 
702   G4UImanager* UImanager = G4UImanager::GetUIp << 
703   UImanager->ApplyCommand(G4String("/vis/viewe << 
704   UImanager->ApplyCommand                      << 
705     (G4String("/vis/viewer/create ! \"" + clon << 
706   UImanager->ApplyCommand(G4String("/vis/viewe << 
707                                                << 
708   if (verbosity >= G4VisManager::confirmations << 
709     G4cout << "Viewer \"" << originalName << " << 
710     G4cout << "Clone \"" << cloneName << "\" n << 
711   }                                            << 
712 }                                              << 
713                                                << 
714 ////////////// /vis/viewer/colourByDensity /// << 
715                                                << 
716 G4VisCommandViewerColourByDensity::G4VisComman << 
717   G4bool omitable;                             << 
718   fpCommand = new G4UIcommand ("/vis/viewer/co << 
719   fpCommand -> SetGuidance                     << 
720   ("If a volume has no vis attributes, colour  << 
721   fpCommand -> SetGuidance                     << 
722   ("Provide algorithm number, e.g., \"1\" (or  << 
723    "\nThen a unit of density, e.g., \"g/cm3\". << 
724    "\nThen parameters for the algorithm assume << 
725   fpCommand -> SetGuidance                     << 
726   ("Algorithm 1: Simple algorithm takes 3 para << 
727    "\n  Volumes with density < d0 are invisibl << 
728    "\n  Volumes with d0 <= density < d1 have c << 
729    "\n  Volumes with d1 <= density < d2 have c << 
730    "\n  Volumes with density > d2 are blue."); << 
731   G4UIparameter* parameter;                    << 
732   parameter  =  new G4UIparameter("n",'i',omit << 
733   parameter  -> SetGuidance      ("Algorithm n << 
734   parameter  -> SetDefaultValue  (1);          << 
735   fpCommand->SetParameter(parameter);          << 
736   parameter  =  new G4UIparameter("unit",'s',o << 
737   parameter  -> SetGuidance      ("Unit of fol << 
738   parameter  -> SetDefaultValue  ("g/cm3");    << 
739   fpCommand->SetParameter(parameter);          << 
740   parameter  =  new G4UIparameter("d0",'d',omi << 
741   parameter  -> SetGuidance      ("Density par << 
742   parameter  -> SetDefaultValue  (0.5);        << 
743   fpCommand->SetParameter(parameter);          << 
744   parameter  =  new G4UIparameter("d1",'d',omi << 
745   parameter  -> SetGuidance      ("Density par << 
746   parameter  -> SetDefaultValue  (3.0);        << 
747   fpCommand->SetParameter(parameter);          << 
748   parameter  =  new G4UIparameter("d2",'d',omi << 
749   parameter  -> SetGuidance      ("Density par << 
750   parameter  -> SetDefaultValue  (10.0);       << 
751   fpCommand->SetParameter(parameter);          << 
752 }                                              << 
753                                                << 
754 G4VisCommandViewerColourByDensity::~G4VisComma << 
755   delete fpCommand;                            << 
756 }                                              << 
757                                                << 
758 G4String G4VisCommandViewerColourByDensity::Ge << 
759   return "";                                   << 
760 }                                              << 
761                                                << 
762 void G4VisCommandViewerColourByDensity::SetNew << 
763                                                << 
764   G4VisManager::Verbosity verbosity = fpVisMan << 
765                                                << 
766   G4VViewer* viewer = fpVisManager -> GetCurre << 
767   if (!viewer) {                               << 
768     if (verbosity >= G4VisManager::errors) {   << 
769       G4warn <<                                << 
770       "ERROR: No current viewer - \"/vis/viewe << 
771       << G4endl;                               << 
772     }                                          << 
773     return;                                    << 
774   }                                            << 
775   G4ViewParameters vp = viewer->GetViewParamet << 
776                                                << 
777   G4int algorithmNumber;                       << 
778   G4double d0, d1, d2;                         << 
779   G4String unit;                               << 
780   std::istringstream is (newValue);            << 
781   is >> algorithmNumber >> unit >> d0 >> d1 >> << 
782                                                << 
783   if (algorithmNumber < 0 || algorithmNumber > << 
784     if (verbosity >= G4VisManager::errors) {   << 
785       G4warn <<                                << 
786       "ERROR: Unrecognised algorithm number: " << 
787       << G4endl;                               << 
788     }                                          << 
789     return;                                    << 
790   }                                            << 
791                                                << 
792   std::vector<G4double> parameters;            << 
793   if (algorithmNumber > 0) {                   << 
794     const G4String where = "G4VisCommandViewer << 
795     G4double valueOfUnit;                      << 
796     // "Volumic Mass" is Michel's phrase for " << 
797     if (ProvideValueOfUnit(where,unit,"Volumic << 
798       // Successful outcome of unit search     << 
799       d0 *= valueOfUnit; d1 *= valueOfUnit; d2 << 
800     } else {                                   << 
801       if (verbosity >= G4VisManager::errors) { << 
802         G4warn <<                              << 
803         "ERROR: Unrecognised or inappropriate  << 
804         << G4endl;                             << 
805       }                                        << 
806       return;                                  << 
807     }                                          << 
808     parameters.push_back(d0);                  << 
809     parameters.push_back(d1);                  << 
810     parameters.push_back(d2);                  << 
811   }                                            << 
812   vp.SetCBDAlgorithmNumber(algorithmNumber);   << 
813   vp.SetCBDParameters(parameters);             << 
814                                                << 
815   if (verbosity >= G4VisManager::confirmations << 
816     if (vp.GetCBDAlgorithmNumber() == 0) {     << 
817       G4cout << "Colour by density deactivated << 
818     } else {                                   << 
819       G4cout << "Colour by density algorithm " << 
820       << " selected for viewer \"" << viewer-> << 
821       << "\n  Parameters:";                    << 
822       for (auto p: vp.GetCBDParameters()) {    << 
823         G4cout << ' ' << G4BestUnit(p,"Volumic << 
824       }                                        << 
825       G4cout << G4endl;                        << 
826     }                                          << 
827   }                                            << 
828                                                << 
829   SetViewParameters(viewer, vp);               << 
830 }                                              << 
831                                                << 
832 ////////////// /vis/viewer/copyViewFrom ////// << 
833                                                << 
834 G4VisCommandViewerCopyViewFrom::G4VisCommandVi << 
835   G4bool omitable;                             << 
836   fpCommand = new G4UIcmdWithAString ("/vis/vi << 
837   fpCommand -> SetGuidance                     << 
838   ("Copy the camera-specific parameters from t << 
839   fpCommand -> SetGuidance                     << 
840   ("Note: To copy ALL view parameters, includi << 
841    "\nuse \"/vis/viewer/set/all\"");           << 
842   fpCommand -> SetParameterName ("from-viewer- << 
843 }                                              << 
844                                                << 
845 G4VisCommandViewerCopyViewFrom::~G4VisCommandV << 
846   delete fpCommand;                            << 
847 }                                              << 
848                                                << 
849 G4String G4VisCommandViewerCopyViewFrom::GetCu << 
850   return "";                                   << 
851 }                                              << 
852                                                << 
853 void G4VisCommandViewerCopyViewFrom::SetNewVal << 
854                                                << 
855   G4VisManager::Verbosity verbosity = fpVisMan << 
856                                                << 
857   G4VViewer* currentViewer = fpVisManager->Get << 
858   if (!currentViewer) {                        << 
859     if (verbosity >= G4VisManager::errors) {   << 
860       G4warn <<                                << 
861   "ERROR: G4VisCommandsViewerCopyViewFrom::Set << 
862              << G4endl;                        << 
863     }                                          << 
864     return;                                    << 
865   }                                            << 
866                                                << 
867   const G4String& fromViewerName = newValue;   << 
868   G4VViewer* fromViewer = fpVisManager -> GetV << 
869   if (!fromViewer) {                           << 
870     if (verbosity >= G4VisManager::errors) {   << 
871       G4warn << "ERROR: Viewer \"" << fromView << 
872        << "\" not found - \"/vis/viewer/list\" << 
873        << G4endl;                              << 
874     }                                          << 
875     return;                                    << 
876   }                                            << 
877                                                << 
878   if (fromViewer == currentViewer) {           << 
879     if (verbosity >= G4VisManager::warnings) { << 
880       G4warn <<                                << 
881         "WARNING: G4VisCommandsViewerSet::SetN << 
882         "\n  from-viewer and current viewer ar << 
883              << G4endl;                        << 
884     }                                          << 
885     return;                                    << 
886   }                                            << 
887                                                << 
888   // Copy camera-specific view parameters      << 
889   G4ViewParameters vp = currentViewer->GetView << 
890   CopyCameraParameters(vp, fromViewer->GetView << 
891   SetViewParameters(currentViewer, vp);        << 
892                                                << 
893   if (verbosity >= G4VisManager::confirmations << 
894     G4cout << "Camera parameters of viewer \"" << 
895      << "\"\n  set to those of viewer \"" << f << 
896      << "\"."                                  << 
897      << G4endl;                                << 
898   }                                            << 
899 }                                              << 
900                                                << 
901 ////////////// /vis/viewer/create ////////////    139 ////////////// /vis/viewer/create ///////////////////////////////////////
902                                                   140 
903 G4VisCommandViewerCreate::G4VisCommandViewerCr    141 G4VisCommandViewerCreate::G4VisCommandViewerCreate (): fId (0) {
904   G4bool omitable;                                142   G4bool omitable;
905   fpCommand = new G4UIcommand ("/vis/viewer/cr    143   fpCommand = new G4UIcommand ("/vis/viewer/create", this);
906   fpCommand -> SetGuidance                        144   fpCommand -> SetGuidance
907     ("Creates a viewer. If the scene handler n << 145     ("/vis/viewer/create  [<scene-handler>] [<viewer-name>] [<pixels>]");
908      "\nviewer of that scene handler is create << 
909      "\nof the current scene handler is create << 
910   fpCommand -> SetGuidance                        146   fpCommand -> SetGuidance
911     ("If the viewer name is not specified a na << 147     ("Creates an viewer for a specific scene handler.");
912      "\nof the scene handler and a serial numb << 
913   fpCommand -> SetGuidance("The scene handler  << 
914   fpCommand -> SetGuidance                        148   fpCommand -> SetGuidance
915     ("(Note: the system adds the graphics syst << 149     ("Default scene handler is the current scene handler.");
916      "\nfor identification, but for selecting, << 
917      "\nup to the first blank are used. For ex << 
918      "\n\"viewer-0 (G4OpenGLStoredQt)\", it ma << 
919      "\nfor example in \"/vis/viewer/select vi << 
920   fpCommand -> SetGuidance                        150   fpCommand -> SetGuidance
921   ("Window size and placement hints, e.g. 600x << 151     ("Invents a name if not supplied.  (Note: the system adds information");
922   fpCommand -> SetGuidance                        152   fpCommand -> SetGuidance
923   ("- single number, e.g., \"600\": square win << 153     ("to the name for identification - only the characters up to the first");
924   fpCommand -> SetGuidance                        154   fpCommand -> SetGuidance
925   ("- two numbers, e.g., \"800x600\": rectangl << 155     ("blank are used for removing, selecting, etc.)");
926   fpCommand -> SetGuidance                        156   fpCommand -> SetGuidance
927   ("- two numbers plus placement hint, e.g., \ << 157     ("The 3rd parameter is a window size hint.");
928    "\n  600x600 100 pixels left and 100 pixels << 158   fpCommand -> SetGuidance ("This scene handler and viewer become current.");
929   fpCommand -> SetGuidance                     << 
930   ("- If not specified, the default is \"600\" << 
931    "\n  at the window manager's discretion...o << 
932   fpCommand -> SetGuidance                     << 
933   ("- This is an X-Windows-type geometry strin << 
934    "\n  https://en.wikibooks.org/wiki/Guide_to << 
935    "\n  \"Specifying window geometry\".");     << 
936   G4UIparameter* parameter;                       159   G4UIparameter* parameter;
937   parameter = new G4UIparameter ("scene-handle    160   parameter = new G4UIparameter ("scene-handler", 's', omitable = true);
938   parameter -> SetCurrentAsDefault (true);        161   parameter -> SetCurrentAsDefault (true);
939   fpCommand -> SetParameter (parameter);          162   fpCommand -> SetParameter (parameter);
940   parameter = new G4UIparameter ("viewer-name"    163   parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
941   parameter -> SetCurrentAsDefault (true);        164   parameter -> SetCurrentAsDefault (true);
942   fpCommand -> SetParameter (parameter);          165   fpCommand -> SetParameter (parameter);
943   parameter = new G4UIparameter ("window-size- << 166   parameter = new G4UIparameter ("pixels", 'd', omitable = true);
944   parameter -> SetCurrentAsDefault (true);        167   parameter -> SetCurrentAsDefault (true);
945   fpCommand -> SetParameter (parameter);          168   fpCommand -> SetParameter (parameter);
                                                   >> 169   viewerNameCommands.push_back (fpCommand);
946 }                                                 170 }
947                                                   171 
948 G4VisCommandViewerCreate::~G4VisCommandViewerC    172 G4VisCommandViewerCreate::~G4VisCommandViewerCreate () {
949   delete fpCommand;                               173   delete fpCommand;
950 }                                                 174 }
951                                                   175 
952 G4String G4VisCommandViewerCreate::NextName ()    176 G4String G4VisCommandViewerCreate::NextName () {
953   std::ostringstream oss;                      << 177   const int charLength = 100;
                                                   >> 178   char nextName [charLength];
                                                   >> 179   std::ostrstream ost (nextName, charLength);
954   G4VSceneHandler* sceneHandler = fpVisManager    180   G4VSceneHandler* sceneHandler = fpVisManager -> GetCurrentSceneHandler ();
955   oss << "viewer-" << fId << " (";             << 181   ost << "viewer-" << fId << " (";
956   if (sceneHandler) {                             182   if (sceneHandler) {
957     oss << sceneHandler -> GetGraphicsSystem ( << 183     ost << sceneHandler -> GetGraphicsSystem () -> GetName ();
958   }                                               184   }
959   else {                                          185   else {
960     oss << "no_scene_handlers";                << 186     ost << "no_scene_handlers";
961   }                                               187   }
962   oss << ")";                                  << 188   ost << ")" << std::ends;
963   return oss.str();                            << 189   return nextName;
964 }                                                 190 }
965                                                   191 
966 G4String G4VisCommandViewerCreate::GetCurrentV << 192 G4String G4VisCommandViewerCreate::GetCurrentValue (G4UIcommand*) {
967 {                                              << 193   G4String currentValue;
968   G4String sceneHandlerName;                   << 194   G4VSceneHandler* currentSceneHandler =
969   auto currentSceneHandler = fpVisManager->Get << 195     fpVisManager -> GetCurrentSceneHandler ();
970   if (currentSceneHandler) {  // Get name of l << 196   if (currentSceneHandler) {
971     sceneHandlerName = currentSceneHandler->Ge << 197     currentValue = currentSceneHandler -> GetName ();
972   }                                               198   }
973   else {  // No scene handler - ensure a warni << 199   else {
974     sceneHandlerName = "none";                 << 200     currentValue = "none";
975   }                                               201   }
                                                   >> 202   currentValue += ' ';
                                                   >> 203   currentValue += '"';
                                                   >> 204   currentValue += NextName ();
                                                   >> 205   currentValue += '"';
976                                                   206 
977   // Default name                              << 207   currentValue += " 600";  // Default number of pixels for window size hint.
978   const auto& viewerName = NextName();         << 
979                                                   208 
980   // Size hint                                 << 209   return currentValue;
981   G4String windowSizeHint;                     << 
982   auto currentViewer = fpVisManager->GetCurren << 
983   if (currentViewer) {  // Get hint from last  << 
984     windowSizeHint = currentViewer->GetViewPar << 
985   }                                            << 
986   else {  // No viewer - must be first time    << 
987     windowSizeHint = fpVisManager->GetDefaultX << 
988   }                                            << 
989                                                << 
990   // Add quotes around viewer name             << 
991   return sceneHandlerName + " \"" + viewerName << 
992 }                                                 210 }
993                                                   211 
994 void G4VisCommandViewerCreate::SetNewValue (G4 << 212 void G4VisCommandViewerCreate::SetNewValue (G4UIcommand*, G4String newValue) {
995                                                   213 
996   G4VisManager::Verbosity verbosity = fpVisMan    214   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
997                                                   215 
998   G4String sceneHandlerName, newName;             216   G4String sceneHandlerName, newName;
999   G4String windowSizeHintString;               << 217   G4int windowSizeHint;
1000   std::istringstream is (newValue);           << 218   std::istrstream is ((char*)newValue.data());
1001   is >> sceneHandlerName;                        219   is >> sceneHandlerName;
1002                                                  220 
1003   // Now need to handle the possibility that     221   // Now need to handle the possibility that the second string
1004   // contains embedded blanks within quotatio    222   // contains embedded blanks within quotation marks...
1005   char c = ' ';                               << 223   char c;
1006   while (is.get(c) && c == ' '){}             << 224   while (is.get(c) && c == ' ');
1007   if (c == '"') {                                225   if (c == '"') {
1008     while (is.get(c) && c != '"') {newName += << 226     while (is.get(c) && c != '"') newName += c;
1009   }                                              227   }
1010   else {                                         228   else {
1011     newName += c;                                229     newName += c;
1012     while (is.get(c) && c != ' ') {newName += << 230     while (is.get(c) && c != ' ') newName += c;
1013   }                                              231   }
1014   G4StrUtil::strip(newName, ' ');             << 232   newName = newName.strip (G4String::both, ' ');
1015   G4StrUtil::strip(newName, '"');             << 233   newName = newName.strip (G4String::both, '"');
1016                                                  234 
1017   // Now get window size hint...              << 235   // Now get number of pixels...
1018   is >> windowSizeHintString;                 << 236   is >> windowSizeHint;
1019                                                  237 
1020   const G4SceneHandlerList& sceneHandlerList     238   const G4SceneHandlerList& sceneHandlerList =
1021     fpVisManager -> GetAvailableSceneHandlers    239     fpVisManager -> GetAvailableSceneHandlers ();
1022   std::size_t nHandlers = sceneHandlerList.si << 240   G4int nHandlers = sceneHandlerList.size ();
1023   if (nHandlers == 0) {                       << 241   if (nHandlers <= 0) {
1024     G4ExceptionDescription ed;                << 242     if (verbosity >= G4VisManager::errors) {
1025     ed <<                                     << 243       G4cout <<
1026     "ERROR: G4VisCommandViewerCreate::SetNewV << 244   "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
1027     "\n  Create a scene handler with \"/vis/s << 245   "\n  Create a scene handler with \"/vis/sceneHandler/create\""
1028     command->CommandFailed(ed);               << 246        << G4endl;
                                                   >> 247     }
1029     return;                                      248     return;
1030   }                                              249   }
1031                                                  250 
1032   std::size_t iHandler;                       << 251   G4int iHandler;
1033   for (iHandler = 0; iHandler < nHandlers; ++ << 252   for (iHandler = 0; iHandler < nHandlers; iHandler++) {
1034     if (sceneHandlerList [iHandler] -> GetNam    253     if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName) break;
1035   }                                              254   }
1036                                                  255 
1037   if (iHandler >= nHandlers) {                << 256   if (iHandler < 0 || iHandler >= nHandlers) {
1038     // Invalid command line argument or none. << 257     // Invalid command line argument or non.
1039     // This shouldn't happen!!!!!!               258     // This shouldn't happen!!!!!!
1040     G4ExceptionDescription ed;                << 259     if (verbosity >= G4VisManager::errors) {
1041     ed <<                                     << 260       G4cout << "G4VisCommandViewerCreate::SetNewValue:"
1042     "G4VisCommandViewerCreate::SetNewValue: i << 261   " invalid scene handler specified."
1043     command->CommandFailed(ed);               << 262       << G4endl;
                                                   >> 263     }
1044     return;                                      264     return;
1045   }                                              265   }
1046                                                  266 
1047   // Valid index.  Set current scene handler     267   // Valid index.  Set current scene handler and graphics system in
1048   // preparation for creating viewer.            268   // preparation for creating viewer.
1049   G4VSceneHandler* sceneHandler = sceneHandle    269   G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
1050   if (sceneHandler != fpVisManager -> GetCurr    270   if (sceneHandler != fpVisManager -> GetCurrentSceneHandler ()) {
1051     fpVisManager -> SetCurrentSceneHandler (s    271     fpVisManager -> SetCurrentSceneHandler (sceneHandler);
1052   }                                              272   }
1053                                                  273 
1054   // Now deal with name of viewer.               274   // Now deal with name of viewer.
1055   G4String nextName = NextName ();               275   G4String nextName = NextName ();
1056   if (newName == "") {                           276   if (newName == "") {
1057     newName = nextName;                          277     newName = nextName;
1058   }                                              278   }
1059   if (newName == nextName) fId++;                279   if (newName == nextName) fId++;
1060   G4String newShortName = fpVisManager -> Vie    280   G4String newShortName = fpVisManager -> ViewerShortName (newName);
1061                                                  281 
1062   for (std::size_t ih = 0; ih < nHandlers; ++ << 282   for (iHandler = 0; iHandler < nHandlers; iHandler++) {
1063     G4VSceneHandler* sh = sceneHandlerList [i << 283     G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
1064     const G4ViewerList& viewerList = sh -> Ge << 284     const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
1065     for (std::size_t iViewer = 0; iViewer < v << 285     for (size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
1066       if (viewerList [iViewer] -> GetShortNam    286       if (viewerList [iViewer] -> GetShortName () == newShortName ) {
1067   G4ExceptionDescription ed;                  << 287   if (verbosity >= G4VisManager::errors) {
1068   ed <<                                       << 288     G4cout << "ERROR: Viewer \"" << newShortName << "\" already exists."
1069   "ERROR: Viewer \"" << newShortName << "\" a << 289      << G4endl;
1070   command->CommandFailed(ed);                 << 290   }
1071   return;                                        291   return;
1072       }                                          292       }
1073     }                                            293     }
1074   }                                              294   }
1075                                                  295 
1076   if (fThereWasAViewer && windowSizeHintStrin << 296   fpVisManager->SetWindowSizeHint (windowSizeHint, windowSizeHint);
1077     // The user did not specify a window size << 297   // These are picked up in the G4VViewer constructor.  The problem is
1078     windowSizeHintString = fExistingVP.GetXGe << 298   // these have to be set *before* construction, i.e., before we have
1079   }                                           << 299   // a viewer.
1080                                               << 
1081   fpVisManager -> CreateViewer (newName,windo << 
1082                                                  300 
1083   // Now we have a new viewer                 << 301   // Create viewer.
                                                   >> 302   fpVisManager -> CreateViewer (newName);
1084   G4VViewer* newViewer = fpVisManager -> GetC    303   G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
1085                                               << 304   if (newViewer -> GetName () == newName) {
1086   if (newViewer && newViewer -> GetName () == << 
1087     if (fThereWasAViewer) {                   << 
1088       G4ViewParameters vp = newViewer->GetVie << 
1089       // Copy view parameters from existing v << 
1090       fExistingVP.SetAutoRefresh(vp.IsAutoRef << 
1091       fExistingVP.SetBackgroundColour(vp.GetB << 
1092       fExistingVP.SetGlobalMarkerScale(vp.Get << 
1093       // ...including window hint paramaters  << 
1094       fExistingVP.SetXGeometryString(vp.GetXG << 
1095       vp = fExistingVP;                       << 
1096       newViewer->SetViewParameters(vp);       << 
1097       newViewer->AccessSceneTree() = fExistin << 
1098     }                                         << 
1099     if (verbosity >= G4VisManager::confirmati    305     if (verbosity >= G4VisManager::confirmations) {
1100       G4cout << "New viewer \"" << newName <<    306       G4cout << "New viewer \"" << newName << "\" created." << G4endl;
1101     }                                            307     }
1102     // Keep for next time...                  << 308     UpdateCandidateLists ();
1103     fThereWasAViewer = true;                  << 
1104     auto viewer = fpVisManager->GetCurrentVie << 
1105     fExistingVP = viewer->GetViewParameters() << 
1106     fExistingSceneTree = viewer->GetSceneTree << 
1107   } else {                                    << 
1108     G4ExceptionDescription ed;                << 
1109     if (newViewer) {                          << 
1110       ed << "ERROR: New viewer doesn\'t match << 
1111     } else {                                  << 
1112       ed << "WARNING: No viewer created.";    << 
1113     }                                         << 
1114     command->CommandFailed(ed);               << 
1115     return;                                   << 
1116   }                                              309   }
1117   // Refresh if appropriate...                << 310   else {
1118   if (newViewer) {                            << 311     if (verbosity >= G4VisManager::errors) {
1119     if (newViewer->GetViewParameters().IsAuto << 312       G4cout << "ERROR: New viewer doesn\'t match!!!  Curious!!" << G4endl;
1120       G4UImanager::GetUIpointer()->ApplyComma << 
1121     }                                         << 
1122     else {                                    << 
1123       if (verbosity >= G4VisManager::warnings << 
1124   G4warn << "Issue /vis/viewer/refresh or flu << 
1125          << G4endl;                           << 
1126       }                                       << 
1127     }                                            313     }
1128   }                                              314   }
                                                   >> 315   // Refresh if appropriate...
                                                   >> 316   SetViewParameters(newViewer, newViewer->GetViewParameters());
1129 }                                                317 }
1130                                                  318 
1131 ////////////// /vis/viewer/dolly and dollyTo     319 ////////////// /vis/viewer/dolly and dollyTo ////////////////////////////
1132                                                  320 
1133 G4VisCommandViewerDolly::G4VisCommandViewerDo    321 G4VisCommandViewerDolly::G4VisCommandViewerDolly ():
1134   fDollyIncrement  (0.),                         322   fDollyIncrement  (0.),
1135   fDollyTo (0.)                                  323   fDollyTo (0.)
1136 {                                                324 {
1137   G4bool omitable, currentAsDefault;             325   G4bool omitable, currentAsDefault;
1138                                                  326 
1139   fpCommandDolly = new G4UIcmdWithADoubleAndU    327   fpCommandDolly = new G4UIcmdWithADoubleAndUnit
1140     ("/vis/viewer/dolly", this);                 328     ("/vis/viewer/dolly", this);
1141   fpCommandDolly -> SetGuidance                  329   fpCommandDolly -> SetGuidance
1142     ("Incremental dolly.");                   << 330     ("/vis/viewer/dolly [<increment>] [<unit>]");
1143   fpCommandDolly -> SetGuidance                  331   fpCommandDolly -> SetGuidance
1144     ("Moves the camera incrementally towards  << 332     ("Moves the camera incrementally in by this distance.");
1145   fpCommandDolly -> SetParameterName("increme    333   fpCommandDolly -> SetParameterName("increment",
1146              omitable=true,                      334              omitable=true,
1147              currentAsDefault=true);             335              currentAsDefault=true);
1148   fpCommandDolly -> SetDefaultUnit("m");         336   fpCommandDolly -> SetDefaultUnit("m");
1149                                                  337 
1150   fpCommandDollyTo = new G4UIcmdWithADoubleAn    338   fpCommandDollyTo = new G4UIcmdWithADoubleAndUnit
1151     ("/vis/viewer/dollyTo", this);               339     ("/vis/viewer/dollyTo", this);
1152   fpCommandDollyTo -> SetGuidance                340   fpCommandDollyTo -> SetGuidance
1153     ("Dolly to specific coordinate.");        << 341     ("/vis/viewer/dollyTo [<distance>] [<unit>]");
1154   fpCommandDollyTo -> SetGuidance                342   fpCommandDollyTo -> SetGuidance
1155  ("Places the camera towards target point rel << 343     ("Moves the camera in this distance relative to standard target point.");
1156   fpCommandDollyTo -> SetParameterName("dista    344   fpCommandDollyTo -> SetParameterName("distance",
1157                omitable=true,                    345                omitable=true,
1158                currentAsDefault=true);           346                currentAsDefault=true);
1159   fpCommandDollyTo -> SetDefaultUnit("m");       347   fpCommandDollyTo -> SetDefaultUnit("m");
1160 }                                                348 }
1161                                                  349 
1162 G4VisCommandViewerDolly::~G4VisCommandViewerD    350 G4VisCommandViewerDolly::~G4VisCommandViewerDolly () {
1163   delete fpCommandDolly;                         351   delete fpCommandDolly;
1164   delete fpCommandDollyTo;                       352   delete fpCommandDollyTo;
1165 }                                                353 }
1166                                                  354 
1167 G4String G4VisCommandViewerDolly::GetCurrentV    355 G4String G4VisCommandViewerDolly::GetCurrentValue (G4UIcommand* command) {
1168   G4String currentValue;                         356   G4String currentValue;
1169   if (command == fpCommandDolly) {               357   if (command == fpCommandDolly) {
1170     currentValue = fpCommandDolly->ConvertToS    358     currentValue = fpCommandDolly->ConvertToString(fDollyIncrement, "m");
1171   }                                              359   }
1172   else if (command == fpCommandDollyTo) {        360   else if (command == fpCommandDollyTo) {
1173     currentValue = fpCommandDollyTo->ConvertT    361     currentValue = fpCommandDollyTo->ConvertToString(fDollyTo, "m");
1174   }                                              362   }
1175   return currentValue;                           363   return currentValue;
1176 }                                                364 }
1177                                                  365 
1178 void G4VisCommandViewerDolly::SetNewValue (G4    366 void G4VisCommandViewerDolly::SetNewValue (G4UIcommand* command,
1179              G4String newValue) {                367              G4String newValue) {
1180                                                  368 
1181                                                  369 
1182   G4VisManager::Verbosity verbosity = fpVisMa    370   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1183                                                  371 
1184   G4VViewer* currentViewer = fpVisManager->Ge    372   G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1185   if (!currentViewer) {                          373   if (!currentViewer) {
1186     if (verbosity >= G4VisManager::errors) {     374     if (verbosity >= G4VisManager::errors) {
1187       G4warn <<                               << 375       G4cout <<
1188   "ERROR: G4VisCommandsViewerDolly::SetNewVal    376   "ERROR: G4VisCommandsViewerDolly::SetNewValue: no current viewer."
1189        << G4endl;                                377        << G4endl;
1190     }                                            378     }
1191     return;                                      379     return;
1192   }                                              380   }
1193                                                  381 
1194   G4ViewParameters vp = currentViewer->GetVie    382   G4ViewParameters vp = currentViewer->GetViewParameters();
1195                                                  383 
1196   if (command == fpCommandDolly) {               384   if (command == fpCommandDolly) {
1197     fDollyIncrement = fpCommandDolly->GetNewD    385     fDollyIncrement = fpCommandDolly->GetNewDoubleValue(newValue);
1198     vp.IncrementDolly(fDollyIncrement);          386     vp.IncrementDolly(fDollyIncrement);
1199   }                                              387   }
1200   else if (command == fpCommandDollyTo) {        388   else if (command == fpCommandDollyTo) {
1201     fDollyTo = fpCommandDolly->GetNewDoubleVa    389     fDollyTo = fpCommandDolly->GetNewDoubleValue(newValue);
1202     vp.SetDolly(fDollyTo);                       390     vp.SetDolly(fDollyTo);
1203   }                                              391   }
1204                                                  392 
1205   if (verbosity >= G4VisManager::confirmation    393   if (verbosity >= G4VisManager::confirmations) {
1206     G4cout << "Dolly distance changed to " <<    394     G4cout << "Dolly distance changed to " << vp.GetDolly() << G4endl;
1207   }                                              395   }
1208                                                  396 
1209   SetViewParameters(currentViewer, vp);          397   SetViewParameters(currentViewer, vp);
1210 }                                                398 }
1211                                                  399 
1212 ////////////// /vis/viewer/flush ////////////    400 ////////////// /vis/viewer/flush ///////////////////////////////////////
1213                                                  401 
1214 G4VisCommandViewerFlush::G4VisCommandViewerFl    402 G4VisCommandViewerFlush::G4VisCommandViewerFlush () {
1215   G4bool omitable, currentAsDefault;             403   G4bool omitable, currentAsDefault;
1216   fpCommand = new G4UIcmdWithAString ("/vis/v    404   fpCommand = new G4UIcmdWithAString ("/vis/viewer/flush", this);
                                                   >> 405   fpCommand -> SetGuidance ("/vis/viewer/flush [<viewer-name>]");
1217   fpCommand -> SetGuidance                       406   fpCommand -> SetGuidance
1218     ("Compound command: \"/vis/viewer/refresh << 407     ("Compound command: /vis/viewer/refresh + /vis/viewer/update.");
1219   fpCommand -> SetGuidance                       408   fpCommand -> SetGuidance
1220     ("Useful for refreshing and initiating po    409     ("Useful for refreshing and initiating post-processing for graphics"
1221      "\nsystems which need post-processing.   << 410      "\n  systems which need post-processing.  Viewer becomes current.");
1222      "\nviewer.  \"/vis/viewer/list\" to see  << 411   fpCommand -> SetGuidance
1223      "\nbecomes current.");                   << 412     ("Specify viewer by name (\"/vis/viewer/list\""
                                                   >> 413      "\n  to see possibilities).");
1224   fpCommand -> SetParameterName ("viewer-name    414   fpCommand -> SetParameterName ("viewer-name",
1225          omitable = true,                        415          omitable = true,
1226          currentAsDefault = true);               416          currentAsDefault = true);
                                                   >> 417   viewerNameCommands.push_back (fpCommand);
1227 }                                                418 }
1228                                                  419 
1229 G4VisCommandViewerFlush::~G4VisCommandViewerF    420 G4VisCommandViewerFlush::~G4VisCommandViewerFlush () {
1230   delete fpCommand;                              421   delete fpCommand;
1231 }                                                422 }
1232                                                  423 
1233 G4String G4VisCommandViewerFlush::GetCurrentV    424 G4String G4VisCommandViewerFlush::GetCurrentValue 
1234 (G4UIcommand*) {                                 425 (G4UIcommand*) {
1235   G4VViewer* viewer = fpVisManager -> GetCurr    426   G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1236   return viewer ? viewer -> GetName () : G4St << 427   if (viewer) {
                                                   >> 428     return viewer -> GetName ();
                                                   >> 429   }
                                                   >> 430   else {
                                                   >> 431     return "none";
                                                   >> 432   }
1237 }                                                433 }
1238                                                  434 
1239 void G4VisCommandViewerFlush::SetNewValue (G4    435 void G4VisCommandViewerFlush::SetNewValue (G4UIcommand*, G4String newValue) {
1240                                                  436 
1241   G4VisManager::Verbosity verbosity = fpVisMa    437   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1242                                                  438 
1243   G4String& flushName = newValue;                439   G4String& flushName = newValue;
1244   G4VViewer* viewer = fpVisManager -> GetView    440   G4VViewer* viewer = fpVisManager -> GetViewer (flushName);
1245   if (!viewer) {                                 441   if (!viewer) {
1246     if (verbosity >= G4VisManager::errors) {     442     if (verbosity >= G4VisManager::errors) {
1247       G4warn << "ERROR: Viewer \"" << flushNa << 443       G4cout << "ERROR: Viewer \"" << flushName << "\"" <<
1248   " not found - \"/vis/viewer/list\"\n  to se    444   " not found - \"/vis/viewer/list\"\n  to see possibilities."
1249        << G4endl;                                445        << G4endl;
1250     }                                            446     }
1251     return;                                      447     return;
1252   }                                              448   }
1253                                                  449 
1254   G4UImanager* ui = G4UImanager::GetUIpointer    450   G4UImanager* ui = G4UImanager::GetUIpointer();
                                                   >> 451   G4int keepVerbose = ui->GetVerboseLevel();
                                                   >> 452   G4int newVerbose(0);
                                                   >> 453   if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
                                                   >> 454     newVerbose = 2;
                                                   >> 455   ui->SetVerboseLevel(newVerbose);
1255   ui->ApplyCommand(G4String("/vis/viewer/refr    456   ui->ApplyCommand(G4String("/vis/viewer/refresh " + flushName));
1256   ui->ApplyCommand(G4String("/vis/viewer/upda    457   ui->ApplyCommand(G4String("/vis/viewer/update " + flushName));
                                                   >> 458   ui->SetVerboseLevel(keepVerbose);
1257   if (verbosity >= G4VisManager::confirmation    459   if (verbosity >= G4VisManager::confirmations) {
1258     G4cout << "Viewer \"" << viewer -> GetNam    460     G4cout << "Viewer \"" << viewer -> GetName () << "\""
1259      << " flushed." << G4endl;                   461      << " flushed." << G4endl;
1260   }                                              462   }
1261 }                                                463 }
1262                                                  464 
1263 ////////////// /vis/viewer/interpolate ////// << 465 //////// /vis/viewer/lightsThetaPhi and lightsVector /////////////
1264                                                  466 
1265 G4VisCommandViewerInterpolate::G4VisCommandVi << 467 G4VisCommandViewerLights::G4VisCommandViewerLights ():
                                                   >> 468   fLightsVector (G4ThreeVector(0.,0.,1.))
                                                   >> 469 {
1266   G4bool omitable;                               470   G4bool omitable;
1267   fpCommand = new G4UIcommand ("/vis/viewer/i << 471 
1268   fpCommand -> SetGuidance                    << 472   fpCommandLightsThetaPhi = new G4UIcommand
1269   ("Interpolate views defined by the first ar << 473     ("/vis/viewer/lightsThetaPhi", this);
1270    "Unix-shell-style pattern matching charact << 474   fpCommandLightsThetaPhi -> SetGuidance
1271    "- see \"man sh\" and look for \"Pattern M << 475     ("/vis/viewer/lightsThetaPhi  [<theta>] [<phi>] [deg|rad]");
1272    "of each file are assumed to be \"/vis/vie << 476   fpCommandLightsThetaPhi -> SetGuidance
1273    "that specify a particular view. The files << 477     ("Set direction from target to lights.");
1274    "order of filename. The files may be writt << 
1275    "\"/vis/viewer/save\" command.");          << 
1276   fpCommand -> SetGuidance                    << 
1277   ("The default is to search the working dire << 
1278    "extension. Another procedure is to assemb << 
1279    "e.g., \"myviews\"; then they can be inter << 
1280    "\"/vis/viewer/interpolate myviews\".");   << 
1281   fpCommand -> SetGuidance                    << 
1282   ("To export interpolated views to file for  << 
1283    "write \"export\" as 5th parameter (OpenGL << 
1284   G4UIparameter* parameter;                      478   G4UIparameter* parameter;
1285   parameter = new G4UIparameter("pattern", 's << 479   parameter = new G4UIparameter("theta", 'd', omitable = true);
1286   parameter -> SetGuidance("Pattern that defi << 480   parameter -> SetCurrentAsDefault (true);
1287   parameter -> SetDefaultValue("*.g4view");   << 481   fpCommandLightsThetaPhi -> SetParameter (parameter);
1288   fpCommand -> SetParameter(parameter);       << 482   parameter = new G4UIparameter("phi", 'd', omitable = true);
1289   parameter = new G4UIparameter("no-of-points << 483   parameter -> SetCurrentAsDefault (true);
1290   parameter -> SetGuidance ("Number of interp << 484   fpCommandLightsThetaPhi -> SetParameter (parameter);
1291   parameter -> SetDefaultValue(50);           << 485   parameter = new G4UIparameter ("unit", 's', omitable = true);
1292   fpCommand -> SetParameter(parameter);       << 486   parameter -> SetDefaultValue ("deg");
1293   parameter = new G4UIparameter("wait-time",  << 487   fpCommandLightsThetaPhi -> SetParameter (parameter);
1294   parameter -> SetGuidance("Wait time per int << 
1295   parameter -> SetDefaultValue("20.");        << 
1296   fpCommand -> SetParameter(parameter);       << 
1297   parameter = new G4UIparameter("time-unit",  << 
1298   parameter -> SetDefaultValue("millisecond") << 
1299   fpCommand -> SetParameter (parameter);      << 
1300   parameter = new G4UIparameter("export", 's' << 
1301   parameter -> SetDefaultValue("no");         << 
1302   fpCommand -> SetParameter (parameter);      << 
1303 }                                             << 
1304                                                  488 
1305 G4VisCommandViewerInterpolate::~G4VisCommandV << 489   fpCommandLightsVector = new G4UIcommand
1306   delete fpCommand;                           << 490     ("/vis/viewer/lightsVector", this);
                                                   >> 491   fpCommandLightsVector -> SetGuidance
                                                   >> 492     ("/vis/viewer/lightsVector  [<x>] [<y>] [<z>]");
                                                   >> 493   fpCommandLightsVector -> SetGuidance
                                                   >> 494     ("Set direction from target to lights.");
                                                   >> 495   parameter = new G4UIparameter("x", 'd', omitable = true);
                                                   >> 496   parameter -> SetCurrentAsDefault (true);
                                                   >> 497   fpCommandLightsVector -> SetParameter (parameter);
                                                   >> 498   parameter = new G4UIparameter("y", 'd', omitable = true);
                                                   >> 499   parameter -> SetCurrentAsDefault (true);
                                                   >> 500   fpCommandLightsVector -> SetParameter (parameter);
                                                   >> 501   parameter = new G4UIparameter ("z", 'd', omitable = true);
                                                   >> 502   parameter -> SetCurrentAsDefault (true);
                                                   >> 503   fpCommandLightsVector -> SetParameter (parameter);
1307 }                                                504 }
1308                                                  505 
1309 G4String G4VisCommandViewerInterpolate::GetCu << 506 G4VisCommandViewerLights::~G4VisCommandViewerLights () {
1310   return "";                                  << 507   delete fpCommandLightsThetaPhi;
                                                   >> 508   delete fpCommandLightsVector;
1311 }                                                509 }
1312                                                  510 
1313 void G4VisCommandViewerInterpolate::SetNewVal << 511 G4String G4VisCommandViewerLights::GetCurrentValue (G4UIcommand* command) {
                                                   >> 512   G4String currentValue;
                                                   >> 513   if (command == fpCommandLightsThetaPhi) {
                                                   >> 514     currentValue = ConvertToString(fLightsVector.theta(),
                                                   >> 515          fLightsVector.phi(), "deg");
                                                   >> 516   }
                                                   >> 517   else if (command == fpCommandLightsVector) {
                                                   >> 518     currentValue = ConvertToString(fLightsVector);
                                                   >> 519   }
                                                   >> 520   return currentValue;
                                                   >> 521 }
1314                                                  522 
                                                   >> 523 void G4VisCommandViewerLights::SetNewValue (G4UIcommand* command,
                                                   >> 524               G4String newValue) {
1315   G4VisManager::Verbosity verbosity = fpVisMa    525   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1316                                               << 526   if (command == fpCommandLightsThetaPhi) {
1317   G4VViewer* currentViewer = fpVisManager->Ge << 527     if (verbosity >= G4VisManager::warnings) {
1318   if (!currentViewer) {                       << 528       G4cout <<
1319     if (verbosity >= G4VisManager::errors) {  << 529   "WARNING: DEPRECATED: use \"/vis/viewer/set/LightsThetaPhi\"."
1320       G4warn <<                               << 
1321       "ERROR: G4VisCommandViewerInterpolate:: << 
1322        << G4endl;                                530        << G4endl;
1323     }                                            531     }
1324     return;                                   << 532     G4UImanager::GetUIpointer()->ApplyCommand(
1325   }                                           << 533       G4String("/vis/viewer/set/LightsThetaPhi " + newValue));
1326                                               << 
1327   G4String pattern;                           << 
1328   G4int nInterpolationPoints;                 << 
1329   G4String waitTimePerPointString;            << 
1330   G4String timeUnit;                          << 
1331   G4String exportString;                      << 
1332                                               << 
1333   std::istringstream iss (newValue);          << 
1334   iss                                         << 
1335   >> pattern                                  << 
1336   >> nInterpolationPoints                     << 
1337   >> waitTimePerPointString                   << 
1338   >> timeUnit                                 << 
1339   >> exportString;                            << 
1340   G4String waitTimePerPointDimString(waitTime << 
1341   const G4double waitTimePerPoint =           << 
1342   G4UIcommand::ConvertToDimensionedDouble(wai << 
1343   G4int waitTimePerPointmilliseconds = waitTi << 
1344   if (waitTimePerPointmilliseconds < 0) waitT << 
1345                                               << 
1346   G4UImanager* uiManager = G4UImanager::GetUI << 
1347                                               << 
1348   // Save current view parameters             << 
1349   G4ViewParameters saveVP = currentViewer->Ge << 
1350                                               << 
1351   // Save current verbosities                 << 
1352   G4VisManager::Verbosity keepVisVerbosity =  << 
1353   G4int keepUIVerbosity = uiManager->GetVerbo << 
1354                                               << 
1355   // Set verbosities for this operation       << 
1356   fpVisManager->SetVerboseLevel(G4VisManager: << 
1357   uiManager->SetVerboseLevel(0);              << 
1358                                               << 
1359   // Switch off auto-refresh while we read in << 
1360   // restored later).  Note: the view files d << 
1361   G4ViewParameters non_auto = saveVP;         << 
1362   non_auto.SetAutoRefresh(false);             << 
1363   currentViewer->SetViewParameters(non_auto); << 
1364                                               << 
1365   const G4int safety = 99;                    << 
1366   G4int safetyCount = 0;                      << 
1367   G4fs::path pathPattern = pattern.c_str();   << 
1368                                               << 
1369   // Parent path - add "./" for empty directo << 
1370   G4String parentPathString                   << 
1371   (pathPattern.parent_path().string().length( << 
1372    pathPattern.parent_path().string() :       << 
1373    std::string("./"));                        << 
1374   G4fs::path parentPath = parentPathString.c_ << 
1375                                               << 
1376   // Fill selected paths                      << 
1377   std::set<G4fs::path> paths;  // Use std::se << 
1378                                               << 
1379   if (G4fs::is_directory(pathPattern)) {      << 
1380                                               << 
1381     // The user has specified a directory. Fi << 
1382     for (const auto& path: G4fs::directory_it << 
1383       if (safetyCount++ >= safety) break;     << 
1384       paths.insert(path);                     << 
1385     }                                         << 
1386                                               << 
1387   } else {                                    << 
1388                                               << 
1389     // Assume user has specified a Unix "glob << 
1390     // Default pattern is *.g4view, which tra << 
1391     // Convert pattern into a regexp          << 
1392     G4String regexp_pattern("^");             << 
1393     for (G4int i = 0; i < (G4int)pattern.leng << 
1394       if (pattern[i] == '.') {                << 
1395   regexp_pattern += "\\.";                    << 
1396       } else if (pattern[i] == '*') {         << 
1397   regexp_pattern += ".*";                     << 
1398       } else if (pattern[i] == '?') {         << 
1399   regexp_pattern += "(.{1,1})";               << 
1400       } else {                                << 
1401   regexp_pattern += pattern[i];               << 
1402       }                                       << 
1403     }                                         << 
1404     std::regex regexp(regexp_pattern, std::re << 
1405                                               << 
1406     for (const auto& path: G4fs::directory_it << 
1407       const auto& pathname = path.path().rela << 
1408       if (std::regex_match(pathname, regexp)) << 
1409   if (safetyCount++ >= safety) break;         << 
1410   paths.insert(path);                         << 
1411       }                                       << 
1412     }                                         << 
1413   }                                              534   }
1414                                               << 535   else if (command == fpCommandLightsVector) {
1415   if (safetyCount > safety) {                 << 536     if (verbosity >= G4VisManager::warnings) {
1416     if (verbosity >= G4VisManager::errors) {  << 537       G4cout <<
1417       G4warn <<                               << 538   "WARNING: DEPRECATED: use \"/vis/viewer/set/LightsVector\"."
1418       "/vis/viewer/interpolate:"              << 539        << G4endl;
1419       "\n  the number of way points has been  << 
1420       << safety << G4endl;                    << 
1421     }                                            540     }
1422   }                                           << 541     G4UImanager::GetUIpointer()->ApplyCommand(
1423                                               << 542       G4String("/vis/viewer/set/LightsVector " + newValue));
1424   // Fill view vector of way points           << 
1425   std::vector<G4ViewParameters> viewVector;   << 
1426   for (const auto& path: paths) {             << 
1427     uiManager->ApplyCommand("/control/execute << 
1428     G4ViewParameters vp = currentViewer->GetV << 
1429     // Set original auto-refresh status.      << 
1430     vp.SetAutoRefresh(saveVP.IsAutoRefresh()) << 
1431     viewVector.push_back(vp);                 << 
1432   }                                           << 
1433                                               << 
1434   InterpolateViews                            << 
1435   (currentViewer,viewVector,                  << 
1436    nInterpolationPoints,waitTimePerPointmilli << 
1437                                               << 
1438   // Restore original verbosities             << 
1439   uiManager->SetVerboseLevel(keepUIVerbosity) << 
1440   fpVisManager->SetVerboseLevel(keepVisVerbos << 
1441                                               << 
1442   // Restore original view parameters         << 
1443   currentViewer->SetViewParameters(saveVP);   << 
1444   currentViewer->RefreshView();               << 
1445   if (verbosity >= G4VisManager::confirmation << 
1446     G4cout << "Viewer \"" << currentViewer -> << 
1447     << " restored." << G4endl;                << 
1448   }                                              543   }
1449 }                                                544 }
1450                                                  545 
1451 ////////////// /vis/viewer/list /////////////    546 ////////////// /vis/viewer/list ///////////////////////////////////////
1452                                                  547 
1453 G4VisCommandViewerList::G4VisCommandViewerLis    548 G4VisCommandViewerList::G4VisCommandViewerList () {
1454   G4bool omitable;                               549   G4bool omitable;
1455   fpCommand = new G4UIcommand ("/vis/viewer/l    550   fpCommand = new G4UIcommand ("/vis/viewer/list", this);
                                                   >> 551   fpCommand -> SetGuidance
                                                   >> 552     ("/vis/viewer/list [<viewer-name>] [<verbosity>]");
1456   fpCommand -> SetGuidance ("Lists viewers(s)    553   fpCommand -> SetGuidance ("Lists viewers(s).");
                                                   >> 554   fpCommand -> SetGuidance ("<viewer-name> default is \"all\"");
1457   fpCommand -> SetGuidance                       555   fpCommand -> SetGuidance
1458     ("See \"/vis/verbose\" for definition of  << 556     ("See /vis/verbose for definition of verbosity.");
1459   G4UIparameter* parameter;                      557   G4UIparameter* parameter;
1460   parameter = new G4UIparameter("viewer-name"    558   parameter = new G4UIparameter("viewer-name", 's',
1461         omitable = true);                        559         omitable = true);
                                                   >> 560   parameter -> SetCurrentAsDefault (false);
1462   parameter -> SetDefaultValue ("all");          561   parameter -> SetDefaultValue ("all");
1463   fpCommand -> SetParameter (parameter);         562   fpCommand -> SetParameter (parameter);
1464   parameter = new G4UIparameter ("verbosity",    563   parameter = new G4UIparameter ("verbosity", 's',
1465          omitable = true);                       564          omitable = true);
1466   parameter -> SetDefaultValue ("warnings");  << 565   parameter -> SetCurrentAsDefault (false);
                                                   >> 566   parameter -> SetDefaultValue (0);
1467   fpCommand -> SetParameter (parameter);         567   fpCommand -> SetParameter (parameter);
1468 }                                                568 }
1469                                                  569 
1470 G4VisCommandViewerList::~G4VisCommandViewerLi    570 G4VisCommandViewerList::~G4VisCommandViewerList () {
1471   delete fpCommand;                              571   delete fpCommand;
1472 }                                                572 }
1473                                                  573 
1474 G4String G4VisCommandViewerList::GetCurrentVa    574 G4String G4VisCommandViewerList::GetCurrentValue (G4UIcommand*) {
1475   return "";                                     575   return "";
1476 }                                                576 }
1477                                                  577 
1478 void G4VisCommandViewerList::SetNewValue (G4U    578 void G4VisCommandViewerList::SetNewValue (G4UIcommand*, G4String newValue) {
1479   G4String name, verbosityString;                579   G4String name, verbosityString;
1480   std::istringstream is (newValue);           << 580   std::istrstream is ((char*)newValue.data());
1481   is >> name >> verbosityString;                 581   is >> name >> verbosityString;
1482   G4String shortName = fpVisManager -> Viewer    582   G4String shortName = fpVisManager -> ViewerShortName (name);
1483   G4VisManager::Verbosity verbosity =            583   G4VisManager::Verbosity verbosity =
1484     fpVisManager->GetVerbosityValue(verbosity    584     fpVisManager->GetVerbosityValue(verbosityString);
1485                                                  585 
1486   const G4VViewer* currentViewer = fpVisManag    586   const G4VViewer* currentViewer = fpVisManager -> GetCurrentViewer ();
1487   G4String currentViewerShortName;               587   G4String currentViewerShortName;
1488   if (currentViewer) {                           588   if (currentViewer) {
1489     currentViewerShortName = currentViewer ->    589     currentViewerShortName = currentViewer -> GetShortName ();
1490   }                                              590   }
1491   else {                                         591   else {
1492     currentViewerShortName = "none";             592     currentViewerShortName = "none";
1493   }                                              593   }
1494                                                  594 
1495   const G4SceneHandlerList& sceneHandlerList  << 595   const G4SceneHandlerList& sceneHandlerList = fpVisManager -> GetAvailableSceneHandlers ();
1496     fpVisManager -> GetAvailableSceneHandlers << 596   G4int nHandlers = sceneHandlerList.size ();
1497   std::size_t nHandlers = sceneHandlerList.si << 
1498   G4bool found = false;                          597   G4bool found = false;
1499   G4bool foundCurrent = false;                   598   G4bool foundCurrent = false;
1500   for (std::size_t iHandler = 0; iHandler < n << 599   for (int iHandler = 0; iHandler < nHandlers; iHandler++) {
1501     G4VSceneHandler* sceneHandler = sceneHand    600     G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
1502     const G4ViewerList& viewerList = sceneHan    601     const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
1503     G4cout                                    << 602     G4cout << "Scene handler \"" << sceneHandler -> GetName ();
1504     << "Scene handler \"" << sceneHandler ->  << 
1505     << sceneHandler->GetGraphicsSystem()->Get << 
1506     const G4Scene* pScene = sceneHandler -> G    603     const G4Scene* pScene = sceneHandler -> GetScene ();
1507     if (pScene) {                                604     if (pScene) {
1508       G4cout << ", scene \"" << pScene -> Get << 605       G4cout << "\", scene \"" << pScene -> GetName () << "\":";
1509     }                                            606     }
1510     G4cout << ':';                            << 607     G4int nViewers = viewerList.size ();
1511     std::size_t nViewers = viewerList.size () << 
1512     if (nViewers == 0) {                         608     if (nViewers == 0) {
1513       G4cout << "\n            No viewers for    609       G4cout << "\n            No viewers for this scene handler." << G4endl;
1514     }                                            610     }
1515     else {                                       611     else {
1516       for (std::size_t iViewer = 0; iViewer < << 612       for (int iViewer = 0; iViewer < nViewers; iViewer++) {
1517   const G4VViewer* thisViewer = viewerList [i    613   const G4VViewer* thisViewer = viewerList [iViewer];
1518   G4String thisName = thisViewer -> GetName (    614   G4String thisName = thisViewer -> GetName ();
1519   G4String thisShortName = thisViewer -> GetS    615   G4String thisShortName = thisViewer -> GetShortName ();
1520   if (name != "all") {                           616   if (name != "all") {
1521     if (thisShortName != shortName) continue;    617     if (thisShortName != shortName) continue;
1522   }                                              618   }
1523   found = true;                                  619   found = true;
1524   G4cout << "\n  ";                              620   G4cout << "\n  ";
1525   if (thisShortName == currentViewerShortName    621   if (thisShortName == currentViewerShortName) {
1526     foundCurrent = true;                         622     foundCurrent = true;
1527     G4cout << "(current)";                       623     G4cout << "(current)";
1528   }                                              624   }
1529   else {                                         625   else {
1530     G4cout << "         ";                       626     G4cout << "         ";
1531   }                                              627   }
1532   G4cout << " viewer \"" << thisName << "\"";    628   G4cout << " viewer \"" << thisName << "\"";
1533   if (verbosity >= G4VisManager::parameters)     629   if (verbosity >= G4VisManager::parameters) {
1534     G4cout << "\n  " << *thisViewer;             630     G4cout << "\n  " << *thisViewer;
1535   }                                              631   }
1536       }                                          632       }
1537     }                                            633     }
1538     G4cout << G4endl;                            634     G4cout << G4endl;
1539   }                                              635   }
1540                                                  636 
1541   if (!foundCurrent) {                           637   if (!foundCurrent) {
1542     G4cout << "No valid current viewer - plea    638     G4cout << "No valid current viewer - please create or select one."
1543      << G4endl;                                  639      << G4endl;
1544   }                                              640   }
1545                                                  641 
1546   if (!found) {                                  642   if (!found) {
1547     G4cout << "No viewers";                      643     G4cout << "No viewers";
1548     if (name != "all") {                         644     if (name != "all") {
1549       G4cout << " of name \"" << name << "\""    645       G4cout << " of name \"" << name << "\"";
1550     }                                            646     }
1551     G4cout << " found." << G4endl;               647     G4cout << " found." << G4endl;
1552   }                                              648   }
1553 }                                                649 }
1554                                                  650 
1555 ////////////// /vis/viewer/pan and panTo ////    651 ////////////// /vis/viewer/pan and panTo ////////////////////////////
1556                                                  652 
1557 G4VisCommandViewerPan::G4VisCommandViewerPan     653 G4VisCommandViewerPan::G4VisCommandViewerPan ():
1558   fPanIncrementRight  (0.),                      654   fPanIncrementRight  (0.),
1559   fPanIncrementUp  (0.),                         655   fPanIncrementUp  (0.),
1560   fPanToRight (0.),                              656   fPanToRight (0.),
1561   fPanToUp (0.)                                  657   fPanToUp (0.)
1562 {                                                658 {
1563   G4bool omitable;                               659   G4bool omitable;
1564                                                  660 
1565   fpCommandPan = new G4UIcommand                 661   fpCommandPan = new G4UIcommand
1566     ("/vis/viewer/pan", this);                   662     ("/vis/viewer/pan", this);
1567   fpCommandPan -> SetGuidance                    663   fpCommandPan -> SetGuidance
1568     ("Incremental pan.");                     << 664     ("/vis/viewer/pan [<right-increment>] [<up-increment>] [<unit>]");
1569   fpCommandPan -> SetGuidance                    665   fpCommandPan -> SetGuidance
1570     ("Moves the camera incrementally right an << 666     ("Moves the camera incrementally right and up by these amounts.");
1571      "\nfrom viewpoint direction).");         << 
1572   G4UIparameter* parameter;                      667   G4UIparameter* parameter;
1573   parameter = new G4UIparameter("right-increm    668   parameter = new G4UIparameter("right-increment", 'd', omitable = true);
1574   parameter -> SetCurrentAsDefault (true);       669   parameter -> SetCurrentAsDefault (true);
1575   fpCommandPan -> SetParameter (parameter);      670   fpCommandPan -> SetParameter (parameter);
1576   parameter = new G4UIparameter("up-increment    671   parameter = new G4UIparameter("up-increment", 'd', omitable = true);
1577   parameter -> SetCurrentAsDefault (true);       672   parameter -> SetCurrentAsDefault (true);
1578   fpCommandPan -> SetParameter (parameter);      673   fpCommandPan -> SetParameter (parameter);
1579   parameter = new G4UIparameter ("unit", 's',    674   parameter = new G4UIparameter ("unit", 's', omitable = true);
1580   parameter -> SetDefaultValue ("m");            675   parameter -> SetDefaultValue ("m");
1581   fpCommandPan -> SetParameter (parameter);      676   fpCommandPan -> SetParameter (parameter);
1582                                                  677 
1583   fpCommandPanTo = new G4UIcommand               678   fpCommandPanTo = new G4UIcommand
1584     ("/vis/viewer/panTo", this);                 679     ("/vis/viewer/panTo", this);
1585   fpCommandPanTo -> SetGuidance                  680   fpCommandPanTo -> SetGuidance
1586     ("Pan to specific coordinate.");          << 681     ("/vis/viewer/panTo [<right>] [<up>] [<unit>]");
1587   fpCommandPanTo -> SetGuidance                  682   fpCommandPanTo -> SetGuidance
1588     ("Places the camera in this position righ << 683     ("Moves the camera to this position right and up relative to standard"
1589      "\ntarget point (as seen from viewpoint  << 684      "target point (as seen from viewpoint direction).");
1590   parameter = new G4UIparameter("right", 'd',    685   parameter = new G4UIparameter("right", 'd', omitable = true);
1591   parameter -> SetCurrentAsDefault (true);       686   parameter -> SetCurrentAsDefault (true);
1592   fpCommandPanTo -> SetParameter (parameter);    687   fpCommandPanTo -> SetParameter (parameter);
1593   parameter = new G4UIparameter("up", 'd', om    688   parameter = new G4UIparameter("up", 'd', omitable = true);
1594   parameter -> SetCurrentAsDefault (true);       689   parameter -> SetCurrentAsDefault (true);
1595   fpCommandPanTo -> SetParameter (parameter);    690   fpCommandPanTo -> SetParameter (parameter);
1596   parameter = new G4UIparameter ("unit", 's',    691   parameter = new G4UIparameter ("unit", 's', omitable = true);
1597   parameter -> SetDefaultValue ("m");            692   parameter -> SetDefaultValue ("m");
1598   fpCommandPanTo -> SetParameter (parameter);    693   fpCommandPanTo -> SetParameter (parameter);
1599 }                                                694 }
1600                                                  695 
1601 G4VisCommandViewerPan::~G4VisCommandViewerPan    696 G4VisCommandViewerPan::~G4VisCommandViewerPan () {
1602   delete fpCommandPan;                           697   delete fpCommandPan;
1603   delete fpCommandPanTo;                         698   delete fpCommandPanTo;
1604 }                                                699 }
1605                                                  700 
1606 G4String G4VisCommandViewerPan::GetCurrentVal    701 G4String G4VisCommandViewerPan::GetCurrentValue (G4UIcommand* command) {
1607   G4String currentValue;                         702   G4String currentValue;
1608   if (command == fpCommandPan) {                 703   if (command == fpCommandPan) {
1609     currentValue = ConvertToString(fPanIncrem    704     currentValue = ConvertToString(fPanIncrementRight, fPanIncrementUp, "m");
1610   }                                              705   }
1611   else if (command == fpCommandPanTo) {          706   else if (command == fpCommandPanTo) {
1612     currentValue = ConvertToString(fPanToRigh    707     currentValue = ConvertToString(fPanToRight, fPanToUp, "m");
1613   }                                              708   }
1614   return currentValue;                           709   return currentValue;
1615 }                                                710 }
1616                                                  711 
1617 void G4VisCommandViewerPan::SetNewValue (G4UI    712 void G4VisCommandViewerPan::SetNewValue (G4UIcommand* command,
1618            G4String newValue) {                  713            G4String newValue) {
1619                                                  714 
1620                                                  715 
1621   G4VisManager::Verbosity verbosity = fpVisMa    716   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1622                                                  717 
1623   G4VViewer* currentViewer = fpVisManager->Ge    718   G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1624   if (!currentViewer) {                          719   if (!currentViewer) {
1625     if (verbosity >= G4VisManager::errors) {     720     if (verbosity >= G4VisManager::errors) {
1626       G4warn <<                               << 721       G4cout <<
1627   "ERROR: G4VisCommandsViewerPan::SetNewValue    722   "ERROR: G4VisCommandsViewerPan::SetNewValue: no current viewer."
1628        << G4endl;                                723        << G4endl;
1629     }                                            724     }
1630     return;                                      725     return;
1631   }                                              726   }
1632                                                  727 
1633   G4ViewParameters vp = currentViewer->GetVie    728   G4ViewParameters vp = currentViewer->GetViewParameters();
1634                                                  729 
1635   if (command == fpCommandPan) {                 730   if (command == fpCommandPan) {
1636     ConvertToDoublePair(newValue, fPanIncreme << 731     GetNewDoublePairValue(newValue, fPanIncrementRight, fPanIncrementUp);
1637     vp.IncrementPan(fPanIncrementRight, fPanI    732     vp.IncrementPan(fPanIncrementRight, fPanIncrementUp);
1638   }                                              733   }
1639   else if (command == fpCommandPanTo) {          734   else if (command == fpCommandPanTo) {
1640     ConvertToDoublePair(newValue, fPanToRight << 735     GetNewDoublePairValue(newValue, fPanToRight, fPanToUp);
1641     vp.SetPan(fPanToRight, fPanToUp);            736     vp.SetPan(fPanToRight, fPanToUp);
1642   }                                              737   }
1643                                                  738 
1644   if (verbosity >= G4VisManager::confirmation    739   if (verbosity >= G4VisManager::confirmations) {
1645     G4cout << "Current target point now " <<     740     G4cout << "Current target point now " << vp.GetCurrentTargetPoint()
1646      << G4endl;                                  741      << G4endl;
1647   }                                              742   }
1648                                                  743 
1649   SetViewParameters(currentViewer, vp);          744   SetViewParameters(currentViewer, vp);
1650 }                                                745 }
1651                                                  746 
1652 ////////////// /vis/viewer/rebuild ////////// << 
1653                                               << 
1654 G4VisCommandViewerRebuild::G4VisCommandViewer << 
1655   G4bool omitable, currentAsDefault;          << 
1656   fpCommand = new G4UIcmdWithAString ("/vis/v << 
1657   fpCommand -> SetGuidance ("Forces rebuild o << 
1658   fpCommand -> SetGuidance                    << 
1659     ("By default, acts on current viewer.  \" << 
1660      "\nto see possible viewers.  Viewer beco << 
1661   fpCommand -> SetParameterName ("viewer-name << 
1662          omitable = true,                     << 
1663          currentAsDefault = true);            << 
1664 }                                             << 
1665                                               << 
1666 G4VisCommandViewerRebuild::~G4VisCommandViewe << 
1667   delete fpCommand;                           << 
1668 }                                             << 
1669                                               << 
1670 G4String G4VisCommandViewerRebuild::GetCurren << 
1671   G4VViewer* viewer = fpVisManager -> GetCurr << 
1672   if (viewer) {                               << 
1673     return viewer -> GetName ();              << 
1674   }                                           << 
1675   else {                                      << 
1676     return "none";                            << 
1677   }                                           << 
1678 }                                             << 
1679                                               << 
1680 void G4VisCommandViewerRebuild::SetNewValue ( << 
1681                                               << 
1682   G4VisManager::Verbosity verbosity = fpVisMa << 
1683                                               << 
1684   G4String& rebuildName = newValue;           << 
1685                                               << 
1686   G4VViewer* viewer = fpVisManager -> GetView << 
1687   if (!viewer) {                              << 
1688     if (verbosity >= G4VisManager::errors) {  << 
1689       G4warn << "ERROR: Viewer \"" << rebuild << 
1690        << "\" not found - \"/vis/viewer/list\ << 
1691        << G4endl;                             << 
1692     }                                         << 
1693     return;                                   << 
1694   }                                           << 
1695                                               << 
1696   G4VSceneHandler* sceneHandler = viewer->Get << 
1697   if (!sceneHandler) {                        << 
1698     if (verbosity >= G4VisManager::errors) {  << 
1699       G4warn << "ERROR: Viewer \"" << viewer- << 
1700   " has no scene handler - report serious bug << 
1701        << G4endl;                             << 
1702     }                                         << 
1703     return;                                   << 
1704   }                                           << 
1705                                               << 
1706   sceneHandler->ClearTransientStore();        << 
1707   viewer->NeedKernelVisit();                  << 
1708   viewer->SetView();                          << 
1709   viewer->ClearView();                        << 
1710   viewer->DrawView();                         << 
1711                                               << 
1712   // Check auto-refresh and print confirmatio << 
1713   RefreshIfRequired(viewer);                  << 
1714 }                                             << 
1715                                               << 
1716 ////////////// /vis/viewer/refresh //////////    747 ////////////// /vis/viewer/refresh ///////////////////////////////////////
1717                                                  748 
1718 G4VisCommandViewerRefresh::G4VisCommandViewer    749 G4VisCommandViewerRefresh::G4VisCommandViewerRefresh () {
1719   G4bool omitable, currentAsDefault;             750   G4bool omitable, currentAsDefault;
1720   fpCommand = new G4UIcmdWithAString ("/vis/v    751   fpCommand = new G4UIcmdWithAString ("/vis/viewer/refresh", this);
                                                   >> 752   fpCommand -> SetGuidance ("/vis/viewer/refresh [<viewer-name>]");
1721   fpCommand -> SetGuidance                       753   fpCommand -> SetGuidance
1722     ("Refreshes viewer.");                       754     ("Refreshes viewer.");
1723   fpCommand -> SetGuidance                    << 755   fpCommand -> SetGuidance ("Viewer becomes current.");
1724     ("By default, acts on current viewer.  \" << 756   fpCommand -> SetGuidance
1725      "\nto see possible viewers.  Viewer beco << 757     ("Specify viewer by name (\"/vis/viewer/list\""
                                                   >> 758      "\n  to see possibilities).");
1726   fpCommand -> SetParameterName ("viewer-name    759   fpCommand -> SetParameterName ("viewer-name",
1727          omitable = true,                        760          omitable = true,
1728          currentAsDefault = true);               761          currentAsDefault = true);
                                                   >> 762   viewerNameCommands.push_back (fpCommand);
1729 }                                                763 }
1730                                                  764 
1731 G4VisCommandViewerRefresh::~G4VisCommandViewe    765 G4VisCommandViewerRefresh::~G4VisCommandViewerRefresh () {
1732   delete fpCommand;                              766   delete fpCommand;
1733 }                                                767 }
1734                                                  768 
1735 G4String G4VisCommandViewerRefresh::GetCurren    769 G4String G4VisCommandViewerRefresh::GetCurrentValue (G4UIcommand*) {
1736   G4VViewer* viewer = fpVisManager -> GetCurr    770   G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1737   return viewer ? viewer -> GetName () : G4St << 771   if (viewer) {
                                                   >> 772     return viewer -> GetName ();
                                                   >> 773   }
                                                   >> 774   else {
                                                   >> 775     return "none";
                                                   >> 776   }
1738 }                                                777 }
1739                                                  778 
1740 void G4VisCommandViewerRefresh::SetNewValue (    779 void G4VisCommandViewerRefresh::SetNewValue (G4UIcommand*, G4String newValue) {
1741                                                  780 
1742   G4VisManager::Verbosity verbosity = fpVisMa    781   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1743   G4bool warn(verbosity >= G4VisManager::warn    782   G4bool warn(verbosity >= G4VisManager::warnings);
1744                                                  783 
1745   G4String& refreshName = newValue;              784   G4String& refreshName = newValue;
1746   G4VViewer* viewer = fpVisManager -> GetView    785   G4VViewer* viewer = fpVisManager -> GetViewer (refreshName);
1747   if (!viewer) {                                 786   if (!viewer) {
1748     if (verbosity >= G4VisManager::errors) {     787     if (verbosity >= G4VisManager::errors) {
1749       G4warn << "ERROR: Viewer \"" << refresh << 788       G4cout << "ERROR: Viewer \"" << refreshName << "\"" <<
1750   " not found - \"/vis/viewer/list\"\n  to se    789   " not found - \"/vis/viewer/list\"\n  to see possibilities."
1751        << G4endl;                                790        << G4endl;
1752     }                                            791     }
1753     return;                                      792     return;
1754   }                                              793   }
1755                                                  794 
1756   G4VSceneHandler* sceneHandler = viewer->Get    795   G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
1757   if (!sceneHandler) {                           796   if (!sceneHandler) {
1758     if (verbosity >= G4VisManager::errors) {     797     if (verbosity >= G4VisManager::errors) {
1759       G4warn << "ERROR: Viewer \"" << refresh << 798       G4cout << "ERROR: Viewer \"" << refreshName << "\"" <<
1760   " has no scene handler - report serious bug    799   " has no scene handler - report serious bug."
1761        << G4endl;                                800        << G4endl;
1762     }                                            801     }
1763     return;                                      802     return;
1764   }                                              803   }
1765                                                  804 
1766   G4Scene* scene = sceneHandler->GetScene();     805   G4Scene* scene = sceneHandler->GetScene();
1767   if (!scene) {                                  806   if (!scene) {
1768     if (verbosity >= G4VisManager::confirmati << 807     if (verbosity >= G4VisManager::warnings) {
1769       G4cout << "NOTE: SceneHandler \"" << sc << 808       G4cout << "WARNING: SceneHandler \"" << sceneHandler->GetName()
1770        << "\", to which viewer \"" << refresh    809        << "\", to which viewer \"" << refreshName << "\"" <<
1771   "\n  is attached, has no scene - \"/vis/sce    810   "\n  is attached, has no scene - \"/vis/scene/create\" and"
1772   " \"/vis/sceneHandler/attach\""             << 811   "\"/vis/sceneHandler/attach\""
1773   "\n  (or use compound command \"/vis/drawVo    812   "\n  (or use compound command \"/vis/drawVolume\")."
1774        << G4endl;                                813        << G4endl;
1775     }                                            814     }
1776     return;                                      815     return;
1777   }                                              816   }
1778   if (scene->GetRunDurationModelList().empty( << 817   G4bool successful = scene -> AddWorldIfEmpty (warn);
1779     G4bool successful = scene -> AddWorldIfEm << 818   if (!successful) {
1780     if (!successful) {                        << 819     if (verbosity >= G4VisManager::warnings) {
1781       if (verbosity >= G4VisManager::warnings << 820       G4cout <<
1782   G4warn <<                                   << 821   "WARNING: Scene is empty.  Perhaps no geometry exists."
1783     "WARNING: Scene is empty.  Perhaps no geo << 822   "\n  Try /run/initialize."
1784     "\n  Try /run/initialize."                << 823        << G4endl;
1785          << G4endl;                           << 824    }
1786       }                                       << 825     return;
1787       return;                                 << 826   }
1788     }                                         << 827 
1789     // Scene has changed.  CheckSceneAndNotif << 828   if (verbosity >= G4VisManager::confirmations) {
1790     // /vis/scene/notifyHandlers, which does  << 829     G4cout << "Refreshing viewer \"" << viewer -> GetName () << "\"..."
1791     // ordinary refresh becomes part of the e << 830      << G4endl;
1792     CheckSceneAndNotifyHandlers(scene);       << 831   }
1793   } else {                                    << 832   viewer -> SetView ();
1794     if (verbosity >= G4VisManager::confirmati << 833   viewer -> ClearView ();
1795       G4cout << "Refreshing viewer \"" << vie << 834   viewer -> DrawView ();
1796        << G4endl;                             << 835   if (verbosity >= G4VisManager::confirmations) {
1797     }                                         << 836     G4cout << "Viewer \"" << viewer -> GetName () << "\"" << " refreshed."
1798     viewer -> SetView ();                     << 837       "\n  (You might also need \"/vis/viewer/update\".)" << G4endl;
1799     viewer -> ClearView ();                   << 
1800     viewer -> DrawView ();                    << 
1801     if (verbosity >= G4VisManager::confirmati << 
1802       G4cout << "Viewer \"" << viewer -> GetN << 
1803   "\n  (You might also need \"/vis/viewer/upd << 
1804     }                                         << 
1805   }                                              838   }
1806 }                                                839 }
1807                                                  840 
1808 ////////////// /vis/viewer/reset //////////// << 841 ////////////// /vis/viewer/remove ///////////////////////////////////////
1809                                                  842 
1810 G4VisCommandViewerReset::G4VisCommandViewerRe << 843 G4VisCommandViewerRemove::G4VisCommandViewerRemove () {
1811   G4bool omitable, currentAsDefault;             844   G4bool omitable, currentAsDefault;
1812   fpCommand = new G4UIcmdWithAString ("/vis/v << 845   fpCommand = new G4UIcmdWithAString ("/vis/viewer/remove", this);
1813   fpCommand -> SetGuidance ("Resets viewer.") << 846   fpCommand -> SetGuidance ("/vis/viewer/remove <viewer-name>");
1814   fpCommand -> SetGuidance                    << 847   fpCommand -> SetGuidance ("Removes viewer.");
1815     ("By default, acts on current viewer.  \" << 848   fpCommand -> SetGuidance
1816      "\nto see possible viewers.  Viewer beco << 849     ("Specify viewer by name (\"/vis/viewer/list\""
                                                   >> 850      "\n  to see possibilities).");
1817   fpCommand -> SetParameterName ("viewer-name    851   fpCommand -> SetParameterName ("viewer-name",
1818          omitable = true,                     << 852          omitable = false,
1819          currentAsDefault = true);               853          currentAsDefault = true);
                                                   >> 854   viewerNameCommands.push_back (fpCommand);
1820 }                                                855 }
1821                                                  856 
1822 G4VisCommandViewerReset::~G4VisCommandViewerR << 857 G4VisCommandViewerRemove::~G4VisCommandViewerRemove () {
1823   delete fpCommand;                              858   delete fpCommand;
1824 }                                                859 }
1825                                                  860 
1826 G4String G4VisCommandViewerReset::GetCurrentV << 861 G4String G4VisCommandViewerRemove::GetCurrentValue (G4UIcommand*) {
1827   G4VViewer* viewer = fpVisManager -> GetCurr    862   G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1828   if (viewer) {                                  863   if (viewer) {
1829     return viewer -> GetName ();                 864     return viewer -> GetName ();
1830   }                                              865   }
1831   else {                                         866   else {
1832     return "none";                               867     return "none";
1833   }                                              868   }
1834 }                                                869 }
1835                                                  870 
1836 void G4VisCommandViewerReset::SetNewValue (G4 << 871 void G4VisCommandViewerRemove::SetNewValue (G4UIcommand*, G4String newValue) {
1837                                                  872 
1838   G4VisManager::Verbosity verbosity = fpVisMa    873   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1839                                                  874 
1840   G4String& resetName = newValue;             << 875   G4String& removeName = newValue;
1841   G4VViewer* viewer = fpVisManager -> GetView << 876 
                                                   >> 877   G4VViewer* currentViewer = fpVisManager -> GetCurrentViewer ();
                                                   >> 878   G4String currentShortName;
                                                   >> 879   if (currentViewer) {
                                                   >> 880     currentShortName = currentViewer -> GetShortName ();
                                                   >> 881   }
                                                   >> 882   else {
                                                   >> 883     currentShortName = "none";
                                                   >> 884   }
                                                   >> 885 
                                                   >> 886   G4VViewer* viewer = fpVisManager -> GetViewer (removeName);
1842   if (!viewer) {                                 887   if (!viewer) {
1843     if (verbosity >= G4VisManager::errors) {     888     if (verbosity >= G4VisManager::errors) {
1844       G4warn << "ERROR: Viewer \"" << resetNa << 889       G4cout << "ERROR: Viewer \"" << removeName
1845        << "\" not found - \"/vis/viewer/list\    890        << "\" not found - \"/vis/viewer/list\" to see possibilities."
1846        << G4endl;                                891        << G4endl;
1847     }                                            892     }
1848     return;                                      893     return;
1849   }                                              894   }
1850                                                  895 
1851   viewer->ResetView();                        << 896   if (verbosity >= G4VisManager::confirmations) {
1852   RefreshIfRequired(viewer);                  << 897     G4cout << "Viewer \"" << viewer -> GetName () << "\" removed." << G4endl;
                                                   >> 898   }
                                                   >> 899   if (viewer -> GetShortName () == currentShortName) {
                                                   >> 900     fpVisManager -> DeleteCurrentViewer ();
                                                   >> 901   }
                                                   >> 902   else {
                                                   >> 903     G4VSceneHandler* sceneHandler = viewer -> GetSceneHandler ();
                                                   >> 904     G4ViewerList& viewerList = sceneHandler -> SetViewerList ();
                                                   >> 905     viewerList.remove (viewer);
                                                   >> 906     if (verbosity >= G4VisManager::confirmations) {
                                                   >> 907       G4cout << "Current viewer is unchanged (\""
                                                   >> 908        << currentViewer -> GetName () << "\")." << G4endl;
                                                   >> 909     }
                                                   >> 910   }
                                                   >> 911 
                                                   >> 912   UpdateCandidateLists ();
1853 }                                                913 }
1854                                                  914 
1855 ////////////// /vis/viewer/resetCameraParamet << 915 ////////////// /vis/viewer/reset ///////////////////////////////////////
1856                                                  916 
1857 G4VisCommandViewerResetCameraParameters::G4Vi << 917 G4VisCommandViewerReset::G4VisCommandViewerReset () {
1858   G4bool omitable, currentAsDefault;             918   G4bool omitable, currentAsDefault;
1859   fpCommand = new G4UIcmdWithAString ("/vis/v << 919   fpCommand = new G4UIcmdWithAString ("/vis/viewer/reset", this);
1860   fpCommand -> SetGuidance ("Resets only the  << 920   fpCommand -> SetGuidance ("/vis/viewer/reset [<viewer-name>]");
                                                   >> 921   fpCommand -> SetGuidance ("Resets viewer.");
                                                   >> 922   fpCommand -> SetGuidance ("Viewer becomes current.");
1861   fpCommand -> SetGuidance                       923   fpCommand -> SetGuidance
1862   ("By default, acts on current viewer.  \"/v << 924     ("Specify viewer by name (\"/vis/viewer/list\""
1863    "\nto see possible viewers.  Viewer become << 925      "\n  to see possibilities).");
1864   fpCommand -> SetParameterName ("viewer-name    926   fpCommand -> SetParameterName ("viewer-name",
1865                                  omitable = t << 927          omitable = true,
1866                                  currentAsDef << 928          currentAsDefault = true);
                                                   >> 929   viewerNameCommands.push_back (fpCommand);
1867 }                                                930 }
1868                                                  931 
1869 G4VisCommandViewerResetCameraParameters::~G4V << 932 G4VisCommandViewerReset::~G4VisCommandViewerReset () {
1870   delete fpCommand;                              933   delete fpCommand;
1871 }                                                934 }
1872                                                  935 
1873 G4String G4VisCommandViewerResetCameraParamet << 936 G4String G4VisCommandViewerReset::GetCurrentValue (G4UIcommand*) {
1874   G4VViewer* viewer = fpVisManager -> GetCurr    937   G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1875   if (viewer) {                                  938   if (viewer) {
1876     return viewer -> GetName ();                 939     return viewer -> GetName ();
1877   }                                              940   }
1878   else {                                         941   else {
1879     return "none";                               942     return "none";
1880   }                                              943   }
1881 }                                                944 }
1882                                                  945 
1883 void G4VisCommandViewerResetCameraParameters: << 946 void G4VisCommandViewerReset::SetNewValue (G4UIcommand*, G4String newValue) {
1884                                                  947 
1885   G4VisManager::Verbosity verbosity = fpVisMa    948   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1886                                                  949 
1887   G4String& resetName = newValue;                950   G4String& resetName = newValue;
1888   G4VViewer* viewer = fpVisManager -> GetView    951   G4VViewer* viewer = fpVisManager -> GetViewer (resetName);
1889   if (!viewer) {                                 952   if (!viewer) {
1890     if (verbosity >= G4VisManager::errors) {     953     if (verbosity >= G4VisManager::errors) {
1891       G4warn << "ERROR: Viewer \"" << resetNa << 954       G4cout << "ERROR: Viewer \"" << resetName
1892       << "\" not found - \"/vis/viewer/list\" << 955        << "\" not found - \"/vis/viewer/list\" to see possibilities."
1893       << G4endl;                              << 
1894     }                                         << 
1895     return;                                   << 
1896   }                                           << 
1897                                               << 
1898   G4ViewParameters newVP = viewer->GetViewPar << 
1899   CopyCameraParameters(newVP,viewer->GetDefau << 
1900   viewer->SetViewParameters(newVP);           << 
1901   RefreshIfRequired(viewer);                  << 
1902 }                                             << 
1903                                               << 
1904 ////////////// /vis/viewer/save ///////////// << 
1905                                               << 
1906 G4VisCommandViewerSave::G4VisCommandViewerSav << 
1907   G4bool omitable;                            << 
1908   fpCommand = new G4UIcmdWithAString ("/vis/v << 
1909   fpCommand -> SetGuidance                    << 
1910   ("Write commands that define the current vi << 
1911   fpCommand -> SetGuidance                    << 
1912   ("Read them back into the same or any viewe << 
1913   fpCommand -> SetGuidance                    << 
1914   ("If the filename is omitted the view is sa << 
1915    "\"g4_nn.g4view\", where nn is a sequentia << 
1916   fpCommand -> SetGuidance                    << 
1917   ("If the filename is \"-\", the data are wr << 
1918   fpCommand -> SetGuidance                    << 
1919   ("If you are wanting to save views for futu << 
1920    "procedure is: save views to \"g4_nn.g4vie << 
1921    "into a sub-directory, say, \"views\", the << 
1922    "\"/vis/viewer/interpolate views\"");      << 
1923   fpCommand -> SetParameterName ("filename",  << 
1924   fpCommand -> SetDefaultValue ("");          << 
1925 }                                             << 
1926                                               << 
1927 G4VisCommandViewerSave::~G4VisCommandViewerSa << 
1928   delete fpCommand;                           << 
1929 }                                             << 
1930                                               << 
1931 G4String G4VisCommandViewerSave::GetCurrentVa << 
1932 (G4UIcommand*) {                              << 
1933   return "";                                  << 
1934 }                                             << 
1935                                               << 
1936 namespace {                                   << 
1937   void WriteCommands                          << 
1938   (std::ostream& os,                          << 
1939    const G4ViewParameters& vp,                << 
1940    const G4Point3D& stp)  // Standard Target  << 
1941   {                                           << 
1942     os                                        << 
1943     << vp.CameraAndLightingCommands(stp)      << 
1944     << vp.DrawingStyleCommands()              << 
1945     << vp.SceneModifyingCommands()            << 
1946     << vp.TouchableCommands()                 << 
1947     << vp.TimeWindowCommands()                << 
1948     << std::endl;                             << 
1949   }                                           << 
1950 }                                             << 
1951                                               << 
1952 void G4VisCommandViewerSave::SetNewValue (G4U << 
1953                                               << 
1954   G4VisManager::Verbosity verbosity = fpVisMa << 
1955                                               << 
1956   const G4VViewer* currentViewer = fpVisManag << 
1957   if (!currentViewer) {                       << 
1958     if (verbosity >= G4VisManager::errors) {  << 
1959       G4warn <<                               << 
1960       "ERROR: G4VisCommandsViewerSave::SetNew << 
1961       << G4endl;                              << 
1962     }                                         << 
1963     return;                                   << 
1964   }                                           << 
1965                                               << 
1966   const G4Scene* currentScene = currentViewer << 
1967   if (!currentScene) {                        << 
1968     if (verbosity >= G4VisManager::errors) {  << 
1969       G4warn <<                               << 
1970       "ERROR: G4VisCommandsViewerSave::SetNew << 
1971       << G4endl;                              << 
1972     }                                         << 
1973     return;                                   << 
1974   }                                           << 
1975                                               << 
1976   // Get view parameters and ther relevant in << 
1977   G4ViewParameters vp = currentViewer->GetVie << 
1978   // Concatenate any private vis attributes m << 
1979   const std::vector<G4ModelingParameters::Vis << 
1980   privateVAMs = currentViewer->GetPrivateVisA << 
1981   if (privateVAMs) {                          << 
1982     std::vector<G4ModelingParameters::VisAttr << 
1983     for (i = privateVAMs->begin(); i != priva << 
1984       vp.AddVisAttributesModifier(*i);        << 
1985     }                                         << 
1986   }                                           << 
1987   const G4Point3D& stp = currentScene->GetSta << 
1988                                               << 
1989   G4String filename = newValue;               << 
1990                                               << 
1991   if (newValue.length() == 0) {               << 
1992     // Null filename - generate a filename    << 
1993     const G4int maxNoOfFiles = 100;           << 
1994     static G4int sequenceNumber = 0;          << 
1995     if (sequenceNumber >= maxNoOfFiles) {     << 
1996       if (verbosity >= G4VisManager::errors)  << 
1997         G4warn                                << 
1998         << "ERROR: G4VisCommandsViewerSave::S << 
1999         << maxNoOfFiles                       << 
2000         << ", of files exceeded."             << 
2001         << G4endl;                            << 
2002       }                                       << 
2003       return;                                 << 
2004     }                                         << 
2005     std::ostringstream oss;                   << 
2006     oss << std::setw(2) << std::setfill('0')  << 
2007     filename = "g4_" + oss.str() + ".g4view"; << 
2008   }                                           << 
2009                                               << 
2010   if (filename == "-") {                      << 
2011     // Write to standard output               << 
2012     WriteCommands(G4cout,vp,stp);             << 
2013   } else {                                    << 
2014     // Write to file - but add extension if n << 
2015     if (!G4StrUtil::contains(filename, '.'))  << 
2016       // No extension supplied - add .g4view  << 
2017       filename += ".g4view";                  << 
2018     }                                         << 
2019     std::ofstream ofs(filename);              << 
2020     if (!ofs) {                               << 
2021       if (verbosity >= G4VisManager::errors)  << 
2022         G4warn <<                             << 
2023         "ERROR: G4VisCommandsViewerSave::SetN << 
2024         << filename << "\"."                  << 
2025         << G4endl;                            << 
2026       }                                       << 
2027       ofs.close();                            << 
2028       return;                                 << 
2029     }                                         << 
2030     WriteCommands(ofs,vp,stp);                << 
2031     ofs.close();                              << 
2032   }                                           << 
2033                                               << 
2034   if (verbosity >= G4VisManager::warnings) {  << 
2035     G4warn << "Viewer \"" << currentViewer -> << 
2036     << "\"" << " saved to ";                  << 
2037     if (filename == "-") {                    << 
2038       G4warn << "G4cout.";                    << 
2039     } else {                                  << 
2040       G4warn << "file \'" << filename << "\". << 
2041       "\n  Read the view back into this or an << 
2042       "\n  \"/control/execute " << filename < << 
2043       "\n  \"/vis/viewer/interpolate\" if you << 
2044       "\n  see \"help /vis/viewer/interpolate << 
2045     }                                         << 
2046     G4warn << G4endl;                         << 
2047   }                                           << 
2048 }                                             << 
2049                                               << 
2050 ////////////// /vis/viewer/scale and scaleTo  << 
2051                                               << 
2052 G4VisCommandViewerScale::G4VisCommandViewerSc << 
2053   fScaleMultiplier (G4Vector3D (1., 1., 1.)), << 
2054   fScaleTo         (G4Vector3D (1., 1., 1.))  << 
2055 {                                             << 
2056   G4bool omitable, currentAsDefault;          << 
2057                                               << 
2058   fpCommandScale = new G4UIcmdWith3Vector     << 
2059     ("/vis/viewer/scale", this);              << 
2060   fpCommandScale -> SetGuidance ("Incremental << 
2061   fpCommandScale -> SetGuidance               << 
2062     ("Multiplies components of current scalin << 
2063      "\n Scales (x,y,z) by corresponding comp << 
2064   fpCommandScale -> SetGuidance               << 
2065     ("");                                     << 
2066   fpCommandScale -> SetParameterName          << 
2067     ("x-scale-multiplier","y-scale-multiplier << 
2068      omitable=true, currentAsDefault=true);   << 
2069                                               << 
2070   fpCommandScaleTo = new G4UIcmdWith3Vector   << 
2071     ("/vis/viewer/scaleTo", this);            << 
2072   fpCommandScaleTo -> SetGuidance ("Absolute  << 
2073   fpCommandScaleTo -> SetGuidance             << 
2074     ("Scales (x,y,z) by corresponding compone << 
2075   fpCommandScaleTo -> SetParameterName        << 
2076     ("x-scale-factor","y-scale-factor","z-sca << 
2077      omitable=true, currentAsDefault=true);   << 
2078 }                                             << 
2079                                               << 
2080 G4VisCommandViewerScale::~G4VisCommandViewerS << 
2081   delete fpCommandScale;                      << 
2082   delete fpCommandScaleTo;                    << 
2083 }                                             << 
2084                                               << 
2085 G4String G4VisCommandViewerScale::GetCurrentV << 
2086   G4String currentValue;                      << 
2087   if (command == fpCommandScale) {            << 
2088     currentValue = fpCommandScale->ConvertToS << 
2089   }                                           << 
2090   else if (command == fpCommandScaleTo) {     << 
2091     currentValue = fpCommandScaleTo->ConvertT << 
2092   }                                           << 
2093   return currentValue;                        << 
2094 }                                             << 
2095                                               << 
2096 void G4VisCommandViewerScale::SetNewValue (G4 << 
2097              G4String newValue) {             << 
2098                                               << 
2099                                               << 
2100   G4VisManager::Verbosity verbosity = fpVisMa << 
2101                                               << 
2102   G4VViewer* currentViewer = fpVisManager->Ge << 
2103   if (!currentViewer) {                       << 
2104     if (verbosity >= G4VisManager::errors) {  << 
2105       G4warn <<                               << 
2106   "ERROR: G4VisCommandsViewerScale::SetNewVal << 
2107        << G4endl;                                956        << G4endl;
2108     }                                            957     }
2109     return;                                      958     return;
2110   }                                              959   }
2111                                                  960 
2112   G4ViewParameters vp = currentViewer->GetVie << 961   SetViewParameters(viewer, viewer->GetDefaultViewParameters());
2113                                               << 
2114   if (command == fpCommandScale) {            << 
2115     fScaleMultiplier = fpCommandScale->GetNew << 
2116     vp.MultiplyScaleFactor(fScaleMultiplier); << 
2117   }                                           << 
2118   else if (command == fpCommandScaleTo) {     << 
2119     fScaleTo = fpCommandScale->GetNew3VectorV << 
2120     vp.SetScaleFactor(fScaleTo);              << 
2121   }                                           << 
2122                                               << 
2123   if (verbosity >= G4VisManager::confirmation << 
2124     G4cout << "Scale factor changed to " << v << 
2125   }                                           << 
2126                                               << 
2127   SetViewParameters(currentViewer, vp);       << 
2128 }                                                962 }
2129                                                  963 
2130 ////////////// /vis/viewer/select ///////////    964 ////////////// /vis/viewer/select ///////////////////////////////////////
2131                                                  965 
2132 G4VisCommandViewerSelect::G4VisCommandViewerS    966 G4VisCommandViewerSelect::G4VisCommandViewerSelect () {
2133   G4bool omitable;                            << 967   G4bool omitable, currentAsDefault;
2134   fpCommand = new G4UIcmdWithAString ("/vis/v    968   fpCommand = new G4UIcmdWithAString ("/vis/viewer/select", this);
2135   fpCommand -> SetGuidance ("Selects viewer." << 969   fpCommand -> SetGuidance ("/vis/viewer/select <viewer-name>");
                                                   >> 970   fpCommand -> SetGuidance ("Selects current viewer.");
2136   fpCommand -> SetGuidance                       971   fpCommand -> SetGuidance
2137     ("Specify viewer by name.  \"/vis/viewer/ << 972     ("Specify viewer by name (\"/vis/viewer/list\""
2138   fpCommand -> SetParameterName ("viewer-name << 973      "\n  to see possibilities).");
                                                   >> 974   fpCommand -> SetParameterName ("viewer-name",
                                                   >> 975          omitable = false,
                                                   >> 976          currentAsDefault = true);
                                                   >> 977   viewerNameCommands.push_back (fpCommand);
2139 }                                                978 }
2140                                                  979 
2141 G4VisCommandViewerSelect::~G4VisCommandViewer    980 G4VisCommandViewerSelect::~G4VisCommandViewerSelect () {
2142   delete fpCommand;                              981   delete fpCommand;
2143 }                                                982 }
2144                                                  983 
2145 G4String G4VisCommandViewerSelect::GetCurrent    984 G4String G4VisCommandViewerSelect::GetCurrentValue (G4UIcommand*) {
2146   return "";                                  << 985   G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
                                                   >> 986   if (viewer) {
                                                   >> 987     return viewer -> GetName ();
                                                   >> 988   }
                                                   >> 989   else {
                                                   >> 990     return "none";
                                                   >> 991   }
2147 }                                                992 }
2148                                                  993 
2149 void G4VisCommandViewerSelect::SetNewValue (G    994 void G4VisCommandViewerSelect::SetNewValue (G4UIcommand*, G4String newValue) {
2150                                                  995 
2151   G4VisManager::Verbosity verbosity = fpVisMa    996   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2152                                                  997 
2153   G4String& selectName = newValue;               998   G4String& selectName = newValue;
2154   G4VViewer* viewer = fpVisManager -> GetView    999   G4VViewer* viewer = fpVisManager -> GetViewer (selectName);
2155                                                  1000 
2156   if (!viewer) {                                 1001   if (!viewer) {
2157     if (verbosity >= G4VisManager::errors) {     1002     if (verbosity >= G4VisManager::errors) {
2158       G4warn << "ERROR: Viewer \"" << selectN << 1003       G4cout << "ERROR: Viewer \"" << selectName << "\"";
2159       G4warn << " not found - \"/vis/viewer/l << 1004       G4cout << " not found - \"/vis/viewer/list\""
2160   "\n  to see possibilities."                    1005   "\n  to see possibilities."
2161        << G4endl;                                1006        << G4endl;
2162     }                                            1007     }
2163     return;                                      1008     return;
2164   }                                              1009   }
2165                                                  1010 
2166   if (viewer == fpVisManager -> GetCurrentVie    1011   if (viewer == fpVisManager -> GetCurrentViewer ()) {
2167     if (verbosity >= G4VisManager::warnings)     1012     if (verbosity >= G4VisManager::warnings) {
2168       G4warn << "WARNING: Viewer \"" << viewe << 1013       G4cout << "WARNING: Viewer \"" << viewer -> GetName () << "\""
2169        << " already selected." << G4endl;        1014        << " already selected." << G4endl;
2170     }                                            1015     }
2171     return;                                      1016     return;
2172   }                                              1017   }
2173                                                  1018 
2174   // Set pointers, call SetView and print con << 1019   fpVisManager -> SetCurrentViewer (viewer);  // Prints confirmation.
2175   fpVisManager -> SetCurrentViewer (viewer);  << 
2176                                               << 
2177   RefreshIfRequired(viewer);                  << 
2178                                                  1020 
2179   // Update GUI scene tree (make sure it's in << 
2180   viewer->UpdateGUISceneTree();               << 
2181 }                                                1021 }
2182                                                  1022 
2183 ////////////// /vis/viewer/update ///////////    1023 ////////////// /vis/viewer/update ///////////////////////////////////////
                                                   >> 1024 // Synonym (deprecated): /vis/viewer/show ///////////////////////////
2184                                                  1025 
2185 G4VisCommandViewerUpdate::G4VisCommandViewerU    1026 G4VisCommandViewerUpdate::G4VisCommandViewerUpdate () {
2186   G4bool omitable, currentAsDefault;             1027   G4bool omitable, currentAsDefault;
2187   fpCommand = new G4UIcmdWithAString ("/vis/v    1028   fpCommand = new G4UIcmdWithAString ("/vis/viewer/update", this);
                                                   >> 1029   fpCommand -> SetGuidance ("/vis/viewer/update [<viewer-name>]");
2188   fpCommand -> SetGuidance                       1030   fpCommand -> SetGuidance
2189     ("Triggers graphical database post-proces    1031     ("Triggers graphical database post-processing for viewers"
2190      "\nusing that technique.");              << 1032      " using that technique.");
2191   fpCommand -> SetGuidance                       1033   fpCommand -> SetGuidance
2192     ("For such viewers the view only becomes  << 1034     ("For such viewers the view only becomes visible with this command.");
2193      "\nBy default, acts on current viewer.   << 1035   fpCommand -> SetGuidance ("Viewer becomes current.");
2194      "\nto see possible viewers.  Viewer beco << 1036   fpCommand -> SetGuidance
                                                   >> 1037     ("Specify viewer by name (\"/vis/viewer/list\""
                                                   >> 1038      "\n  to see possibilities).");
2195   fpCommand -> SetParameterName ("viewer-name    1039   fpCommand -> SetParameterName ("viewer-name",
2196          omitable = true,                        1040          omitable = true,
2197          currentAsDefault = true);               1041          currentAsDefault = true);
                                                   >> 1042   viewerNameCommands.push_back (fpCommand);
                                                   >> 1043   fpCommand1 = new G4UIcmdWithAString ("/vis/viewer/show", this);
                                                   >> 1044   fpCommand1 -> SetGuidance
                                                   >> 1045     ("Synonym for \"/vis/viewer/update\" - see that command for guidance.");
                                                   >> 1046   fpCommand1 -> SetParameterName ("viewer-name",
                                                   >> 1047           omitable = true,
                                                   >> 1048           currentAsDefault = true);
                                                   >> 1049   viewerNameCommands.push_back (fpCommand1);
2198 }                                                1050 }
2199                                                  1051 
2200 G4VisCommandViewerUpdate::~G4VisCommandViewer    1052 G4VisCommandViewerUpdate::~G4VisCommandViewerUpdate () {
2201   delete fpCommand;                              1053   delete fpCommand;
                                                   >> 1054   delete fpCommand1;
2202 }                                                1055 }
2203                                                  1056 
2204 G4String G4VisCommandViewerUpdate::GetCurrent    1057 G4String G4VisCommandViewerUpdate::GetCurrentValue (G4UIcommand*) {
2205   G4VViewer* viewer = fpVisManager -> GetCurr    1058   G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
2206   if (viewer) {                                  1059   if (viewer) {
2207     return viewer -> GetName ();                 1060     return viewer -> GetName ();
2208   }                                              1061   }
2209   else {                                         1062   else {
2210     return "none";                               1063     return "none";
2211   }                                              1064   }
2212 }                                                1065 }
2213                                                  1066 
2214 void G4VisCommandViewerUpdate::SetNewValue (G    1067 void G4VisCommandViewerUpdate::SetNewValue (G4UIcommand*, G4String newValue) {
2215                                                  1068 
2216   G4VisManager::Verbosity verbosity = fpVisMa    1069   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2217                                                  1070 
2218   G4String& updateName = newValue;               1071   G4String& updateName = newValue;
2219                                               << 
2220   G4VViewer* viewer = fpVisManager -> GetView    1072   G4VViewer* viewer = fpVisManager -> GetViewer (updateName);
2221   if (!viewer) {                              << 1073 
2222     if (verbosity >= G4VisManager::errors) {  << 1074   if (viewer) {
2223       G4warn <<                               << 1075     if (verbosity >= G4VisManager::confirmations) {
2224   "WARNING: command \"/vis/viewer/update\" co << 1076       G4cout << "Viewer \"" << viewer -> GetName () << "\"";
2225        << G4endl;                             << 1077       G4cout << " post-processing triggered." << G4endl;
2226     }                                            1078     }
2227     return;                                   << 1079     viewer -> ShowView ();
2228   }                                              1080   }
2229                                               << 1081   else {
2230   G4VSceneHandler* sceneHandler = viewer->Get << 
2231   if (!sceneHandler) {                        << 
2232     if (verbosity >= G4VisManager::errors) {     1082     if (verbosity >= G4VisManager::errors) {
2233       G4warn << "ERROR: Viewer \"" << updateN << 1083       G4cout << "ERROR: Viewer \"" << updateName << "\"";
2234   " has no scene handler - report serious bug << 1084       G4cout << " not found - \"/vis/viewer/list\""
2235        << G4endl;                             << 1085   "\n  to see possibilities." << G4endl;
2236     }                                            1086     }
2237     return;                                   << 
2238   }                                              1087   }
                                                   >> 1088 }
2239                                                  1089 
2240   G4Scene* scene = sceneHandler->GetScene();  << 1090 //////// /vis/viewer/viewpointThetaPhi and viewpointVector /////////////
2241   if (!scene) {                               << 1091 
2242     if (verbosity >= G4VisManager::confirmati << 1092 G4VisCommandViewerViewpoint::G4VisCommandViewerViewpoint ():
2243       G4cout << "NOTE: SceneHandler \"" << sc << 1093   fViewpointVector (G4ThreeVector(0.,0.,1.))
2244        << "\", to which viewer \"" << updateN << 1094 {
2245   "\n  is attached, has no scene - \"/vis/sce << 1095   G4bool omitable;
2246   " \"/vis/sceneHandler/attach\""             << 1096 
2247   "\n  (or use compound command \"/vis/drawVo << 1097   fpCommandViewpointThetaPhi = new G4UIcommand
                                                   >> 1098     ("/vis/viewer/viewpointThetaPhi", this);
                                                   >> 1099   fpCommandViewpointThetaPhi -> SetGuidance
                                                   >> 1100     ("/vis/viewer/viewpointThetaPhi  [<theta>] [<phi>] [deg|rad]");
                                                   >> 1101   fpCommandViewpointThetaPhi -> SetGuidance
                                                   >> 1102     ("Set direction from target to camera.  Also changes lightpoint direction"
                                                   >> 1103      "\nif lights are set to move with camera.");
                                                   >> 1104   G4UIparameter* parameter;
                                                   >> 1105   parameter = new G4UIparameter("theta", 'd', omitable = true);
                                                   >> 1106   parameter -> SetCurrentAsDefault (true);
                                                   >> 1107   fpCommandViewpointThetaPhi -> SetParameter (parameter);
                                                   >> 1108   parameter = new G4UIparameter("phi", 'd', omitable = true);
                                                   >> 1109   parameter -> SetCurrentAsDefault (true);
                                                   >> 1110   fpCommandViewpointThetaPhi -> SetParameter (parameter);
                                                   >> 1111   parameter = new G4UIparameter ("unit", 's', omitable = true);
                                                   >> 1112   parameter -> SetDefaultValue ("deg");
                                                   >> 1113   fpCommandViewpointThetaPhi -> SetParameter (parameter);
                                                   >> 1114 
                                                   >> 1115   fpCommandViewpointVector = new G4UIcommand
                                                   >> 1116     ("/vis/viewer/viewpointVector", this);
                                                   >> 1117   fpCommandViewpointVector -> SetGuidance
                                                   >> 1118     ("/vis/viewer/viewpointVector  [<x>] [<y>] [<z>]");
                                                   >> 1119   fpCommandViewpointVector -> SetGuidance
                                                   >> 1120     ("Set direction from target to camera.  Also changes lightpoint direction"
                                                   >> 1121      "\nif lights are set to move with camera.");
                                                   >> 1122   parameter = new G4UIparameter("x", 'd', omitable = true);
                                                   >> 1123   parameter -> SetCurrentAsDefault (true);
                                                   >> 1124   fpCommandViewpointVector -> SetParameter (parameter);
                                                   >> 1125   parameter = new G4UIparameter("y", 'd', omitable = true);
                                                   >> 1126   parameter -> SetCurrentAsDefault (true);
                                                   >> 1127   fpCommandViewpointVector -> SetParameter (parameter);
                                                   >> 1128   parameter = new G4UIparameter ("z", 'd', omitable = true);
                                                   >> 1129   parameter -> SetCurrentAsDefault (true);
                                                   >> 1130   fpCommandViewpointVector -> SetParameter (parameter);
                                                   >> 1131 }
                                                   >> 1132 
                                                   >> 1133 G4VisCommandViewerViewpoint::~G4VisCommandViewerViewpoint () {
                                                   >> 1134   delete fpCommandViewpointThetaPhi;
                                                   >> 1135   delete fpCommandViewpointVector;
                                                   >> 1136 }
                                                   >> 1137 
                                                   >> 1138 G4String G4VisCommandViewerViewpoint::GetCurrentValue (G4UIcommand* command) {
                                                   >> 1139   G4String currentValue;
                                                   >> 1140   if (command == fpCommandViewpointThetaPhi) {
                                                   >> 1141     currentValue = ConvertToString(fViewpointVector.theta(),
                                                   >> 1142          fViewpointVector.phi(), "deg");
                                                   >> 1143   }
                                                   >> 1144   else if (command == fpCommandViewpointVector) {
                                                   >> 1145     currentValue = ConvertToString(fViewpointVector);
                                                   >> 1146   }
                                                   >> 1147   return currentValue;
                                                   >> 1148 }
                                                   >> 1149 
                                                   >> 1150 void G4VisCommandViewerViewpoint::SetNewValue (G4UIcommand* command,
                                                   >> 1151                  G4String newValue) {
                                                   >> 1152 
                                                   >> 1153   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
                                                   >> 1154 
                                                   >> 1155   if (command == fpCommandViewpointThetaPhi) {
                                                   >> 1156     if (verbosity >= G4VisManager::warnings) {
                                                   >> 1157       G4cout <<
                                                   >> 1158   "WARNING: DEPRECATED: use \"/vis/viewer/set/viewpointThetaPhi\"."
2248        << G4endl;                                1159        << G4endl;
2249     }                                            1160     }
2250     return;                                   << 1161     G4UImanager::GetUIpointer()->ApplyCommand(
                                                   >> 1162       G4String("/vis/viewer/set/viewpointThetaPhi " + newValue));
2251   }                                              1163   }
2252                                               << 1164   else if (command == fpCommandViewpointVector) {
2253   if (verbosity >= G4VisManager::confirmation << 1165     if (verbosity >= G4VisManager::warnings) {
2254     G4cout << "Viewer \"" << viewer -> GetNam << 1166       G4cout <<
2255     G4cout << " post-processing triggered." < << 1167   "WARNING: DEPRECATED: use \"/vis/viewer/set/viewpointVector\"."
                                                   >> 1168        << G4endl;
                                                   >> 1169     }
                                                   >> 1170     G4UImanager::GetUIpointer()->ApplyCommand(
                                                   >> 1171       G4String("/vis/viewer/set/viewpointVector " + newValue));
2256   }                                              1172   }
2257   viewer -> ShowView ();                      << 
2258   // Assume future need to "refresh" transien << 
2259   sceneHandler -> SetMarkForClearingTransient << 
2260 }                                                1173 }
2261                                                  1174 
2262 ////////////// /vis/viewer/zoom and zoomTo //    1175 ////////////// /vis/viewer/zoom and zoomTo ////////////////////////////
2263                                                  1176 
2264 G4VisCommandViewerZoom::G4VisCommandViewerZoo    1177 G4VisCommandViewerZoom::G4VisCommandViewerZoom ():
2265   fZoomMultiplier (1.),                          1178   fZoomMultiplier (1.),
2266   fZoomTo         (1.)                           1179   fZoomTo         (1.)
2267 {                                                1180 {
2268   G4bool omitable, currentAsDefault;             1181   G4bool omitable, currentAsDefault;
2269                                                  1182 
2270   fpCommandZoom = new G4UIcmdWithADouble         1183   fpCommandZoom = new G4UIcmdWithADouble
2271     ("/vis/viewer/zoom", this);                  1184     ("/vis/viewer/zoom", this);
2272   fpCommandZoom -> SetGuidance ("Incremental  << 
2273   fpCommandZoom -> SetGuidance                   1185   fpCommandZoom -> SetGuidance
2274     ("Multiplies current magnification by thi << 1186     ("/vis/viewer/zoom [<multiplier>]");
                                                   >> 1187   fpCommandZoom -> SetGuidance
                                                   >> 1188     ("Multiplies magnification by this factor.");
2275   fpCommandZoom -> SetParameterName("multipli    1189   fpCommandZoom -> SetParameterName("multiplier",
2276              omitable=true,                      1190              omitable=true,
2277              currentAsDefault=true);             1191              currentAsDefault=true);
2278                                                  1192 
2279   fpCommandZoomTo = new G4UIcmdWithADouble       1193   fpCommandZoomTo = new G4UIcmdWithADouble
2280     ("/vis/viewer/zoomTo", this);                1194     ("/vis/viewer/zoomTo", this);
2281   fpCommandZoomTo -> SetGuidance ("Absolute z << 
2282   fpCommandZoomTo -> SetGuidance                 1195   fpCommandZoomTo -> SetGuidance
2283     ("Magnifies standard magnification by thi << 1196     ("/vis/viewer/zoomTo [<factor>]");
                                                   >> 1197   fpCommandZoomTo -> SetGuidance
                                                   >> 1198     ("Magnifies by this factor relative to standard view.");
2284   fpCommandZoomTo -> SetParameterName("factor    1199   fpCommandZoomTo -> SetParameterName("factor",
2285                omitable=true,                    1200                omitable=true,
2286                currentAsDefault=true);           1201                currentAsDefault=true);
2287 }                                                1202 }
2288                                                  1203 
2289 G4VisCommandViewerZoom::~G4VisCommandViewerZo    1204 G4VisCommandViewerZoom::~G4VisCommandViewerZoom () {
2290   delete fpCommandZoom;                          1205   delete fpCommandZoom;
2291   delete fpCommandZoomTo;                        1206   delete fpCommandZoomTo;
2292 }                                                1207 }
2293                                                  1208 
2294 G4String G4VisCommandViewerZoom::GetCurrentVa    1209 G4String G4VisCommandViewerZoom::GetCurrentValue (G4UIcommand* command) {
2295   G4String currentValue;                         1210   G4String currentValue;
2296   if (command == fpCommandZoom) {                1211   if (command == fpCommandZoom) {
2297     currentValue = fpCommandZoom->ConvertToSt    1212     currentValue = fpCommandZoom->ConvertToString(fZoomMultiplier);
2298   }                                              1213   }
2299   else if (command == fpCommandZoomTo) {         1214   else if (command == fpCommandZoomTo) {
2300     currentValue = fpCommandZoomTo->ConvertTo    1215     currentValue = fpCommandZoomTo->ConvertToString(fZoomTo);
2301   }                                              1216   }
2302   return currentValue;                           1217   return currentValue;
2303 }                                                1218 }
2304                                                  1219 
2305 void G4VisCommandViewerZoom::SetNewValue (G4U    1220 void G4VisCommandViewerZoom::SetNewValue (G4UIcommand* command,
2306             G4String newValue) {                 1221             G4String newValue) {
2307                                                  1222 
2308                                                  1223 
2309   G4VisManager::Verbosity verbosity = fpVisMa    1224   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2310                                                  1225 
2311   G4VViewer* currentViewer = fpVisManager->Ge    1226   G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
2312   if (!currentViewer) {                          1227   if (!currentViewer) {
2313     if (verbosity >= G4VisManager::errors) {     1228     if (verbosity >= G4VisManager::errors) {
2314       G4warn <<                               << 1229       G4cout <<
2315   "ERROR: G4VisCommandsViewerZoom::SetNewValu    1230   "ERROR: G4VisCommandsViewerZoom::SetNewValue: no current viewer."
2316        << G4endl;                                1231        << G4endl;
2317     }                                            1232     }
2318     return;                                      1233     return;
2319   }                                              1234   }
2320                                                  1235 
2321   G4ViewParameters vp = currentViewer->GetVie    1236   G4ViewParameters vp = currentViewer->GetViewParameters();
2322                                                  1237 
2323   if (command == fpCommandZoom) {                1238   if (command == fpCommandZoom) {
2324     fZoomMultiplier = fpCommandZoom->GetNewDo    1239     fZoomMultiplier = fpCommandZoom->GetNewDoubleValue(newValue);
2325     vp.MultiplyZoomFactor(fZoomMultiplier);      1240     vp.MultiplyZoomFactor(fZoomMultiplier);
2326   }                                              1241   }
2327   else if (command == fpCommandZoomTo) {         1242   else if (command == fpCommandZoomTo) {
2328     fZoomTo = fpCommandZoom->GetNewDoubleValu    1243     fZoomTo = fpCommandZoom->GetNewDoubleValue(newValue);
2329     vp.SetZoomFactor(fZoomTo);                   1244     vp.SetZoomFactor(fZoomTo);
2330   }                                              1245   }
2331                                                  1246 
2332   if (verbosity >= G4VisManager::confirmation    1247   if (verbosity >= G4VisManager::confirmations) {
2333     G4cout << "Zoom factor changed to " << vp    1248     G4cout << "Zoom factor changed to " << vp.GetZoomFactor() << G4endl;
2334   }                                              1249   }
2335                                                  1250 
2336   SetViewParameters(currentViewer, vp);          1251   SetViewParameters(currentViewer, vp);
2337 }                                                1252 }
2338                                                  1253