Geant4 Cross Reference

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


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 // /vis/scene/add commands - John Allison  9th     27 // /vis/scene/add commands - John Allison  9th August 1998
 28                                                    28 
 29 #include "G4VisCommandsSceneAdd.hh"                29 #include "G4VisCommandsSceneAdd.hh"
 30                                                    30 
 31 #include "G4TransportationManager.hh"              31 #include "G4TransportationManager.hh"
 32 #include "G4LogicalVolumeStore.hh"                 32 #include "G4LogicalVolumeStore.hh"
 33 #include "G4PhysicalVolumeModel.hh"                33 #include "G4PhysicalVolumeModel.hh"
 34 #include "G4LogicalVolumeModel.hh"                 34 #include "G4LogicalVolumeModel.hh"
 35 #include "G4ModelingParameters.hh"                 35 #include "G4ModelingParameters.hh"
 36 #include "G4HitsModel.hh"                          36 #include "G4HitsModel.hh"
 37 #include "G4DigiModel.hh"                          37 #include "G4DigiModel.hh"
 38 #include "G4GPSModel.hh"                           38 #include "G4GPSModel.hh"
 39 #include "G4ElectricFieldModel.hh"                 39 #include "G4ElectricFieldModel.hh"
 40 #include "G4MagneticFieldModel.hh"                 40 #include "G4MagneticFieldModel.hh"
 41 #include "G4PSHitsModel.hh"                        41 #include "G4PSHitsModel.hh"
 42 #include "G4TrajectoriesModel.hh"                  42 #include "G4TrajectoriesModel.hh"
 43 #include "G4TextModel.hh"                          43 #include "G4TextModel.hh"
 44 #include "G4ArrowModel.hh"                         44 #include "G4ArrowModel.hh"
 45 #include "G4AxesModel.hh"                          45 #include "G4AxesModel.hh"
 46 #include "G4PlotterModel.hh"                       46 #include "G4PlotterModel.hh"
 47 #include "G4PhysicalVolumesSearchScene.hh"         47 #include "G4PhysicalVolumesSearchScene.hh"
 48 #include "G4ParticleTable.hh"                      48 #include "G4ParticleTable.hh"
 49 #include "G4ParticleDefinition.hh"                 49 #include "G4ParticleDefinition.hh"
 50 #include "G4ApplicationState.hh"                   50 #include "G4ApplicationState.hh"
 51 #include "G4VUserVisAction.hh"                     51 #include "G4VUserVisAction.hh"
 52 #include "G4CallbackModel.hh"                      52 #include "G4CallbackModel.hh"
 53 #include "G4UnionSolid.hh"                         53 #include "G4UnionSolid.hh"
 54 #include "G4SubtractionSolid.hh"                   54 #include "G4SubtractionSolid.hh"
 55 #include "G4Polyhedron.hh"                         55 #include "G4Polyhedron.hh"
 56 #include "G4UImanager.hh"                          56 #include "G4UImanager.hh"
 57 #include "G4UIcommandTree.hh"                      57 #include "G4UIcommandTree.hh"
 58 #include "G4UIcommand.hh"                          58 #include "G4UIcommand.hh"
 59 #include "G4UIcmdWithAString.hh"                   59 #include "G4UIcmdWithAString.hh"
 60 #include "G4UIcmdWithoutParameter.hh"              60 #include "G4UIcmdWithoutParameter.hh"
 61 #include "G4UIcmdWithAnInteger.hh"                 61 #include "G4UIcmdWithAnInteger.hh"
 62 #include "G4Tokenizer.hh"                          62 #include "G4Tokenizer.hh"
 63 #include "G4RunManager.hh"                         63 #include "G4RunManager.hh"
 64 #include "G4RunManagerFactory.hh"                  64 #include "G4RunManagerFactory.hh"
 65 #include "G4StateManager.hh"                       65 #include "G4StateManager.hh"
 66 #include "G4Run.hh"                                66 #include "G4Run.hh"
 67 #include "G4Event.hh"                              67 #include "G4Event.hh"
 68 #include "G4Trajectory.hh"                         68 #include "G4Trajectory.hh"
 69 #include "G4TrajectoryPoint.hh"                    69 #include "G4TrajectoryPoint.hh"
 70 #include "G4RichTrajectory.hh"                     70 #include "G4RichTrajectory.hh"
 71 #include "G4RichTrajectoryPoint.hh"                71 #include "G4RichTrajectoryPoint.hh"
 72 #include "G4SmoothTrajectory.hh"                   72 #include "G4SmoothTrajectory.hh"
 73 #include "G4SmoothTrajectoryPoint.hh"              73 #include "G4SmoothTrajectoryPoint.hh"
 74 #include "G4AttDef.hh"                             74 #include "G4AttDef.hh"
 75 #include "G4AttCheck.hh"                           75 #include "G4AttCheck.hh"
 76 #include "G4Polyline.hh"                           76 #include "G4Polyline.hh"
 77 #include "G4UnitsTable.hh"                         77 #include "G4UnitsTable.hh"
 78 #include "G4PhysicalConstants.hh"                  78 #include "G4PhysicalConstants.hh"
 79 #include "G4SystemOfUnits.hh"                      79 #include "G4SystemOfUnits.hh"
 80 #include "G4GeneralParticleSourceData.hh"          80 #include "G4GeneralParticleSourceData.hh"
 81 #include "G4PlotterManager.hh"                     81 #include "G4PlotterManager.hh"
 82                                                    82 
 83 #include <sstream>                                 83 #include <sstream>
 84                                                    84 
 85 #define G4warn G4cout                          << 
 86                                                << 
 87 ////////////// /vis/scene/add/arrow //////////     85 ////////////// /vis/scene/add/arrow ///////////////////////////////////////
 88                                                    86 
 89 G4VisCommandSceneAddArrow::G4VisCommandSceneAd     87 G4VisCommandSceneAddArrow::G4VisCommandSceneAddArrow () {
 90   fpCommand = new G4UIcommand("/vis/scene/add/     88   fpCommand = new G4UIcommand("/vis/scene/add/arrow", this);
 91   fpCommand -> SetGuidance ("Adds arrow to cur     89   fpCommand -> SetGuidance ("Adds arrow to current scene.");
 92   G4bool omitable;                                 90   G4bool omitable;
 93   G4UIparameter* parameter;                        91   G4UIparameter* parameter;
 94   parameter = new G4UIparameter ("x1", 'd', om     92   parameter = new G4UIparameter ("x1", 'd', omitable = false);
 95   fpCommand -> SetParameter (parameter);           93   fpCommand -> SetParameter (parameter);
 96   parameter = new G4UIparameter ("y1", 'd', om     94   parameter = new G4UIparameter ("y1", 'd', omitable = false);
 97   fpCommand -> SetParameter (parameter);           95   fpCommand -> SetParameter (parameter);
 98   parameter = new G4UIparameter ("z1", 'd', om     96   parameter = new G4UIparameter ("z1", 'd', omitable = false);
 99   fpCommand -> SetParameter (parameter);           97   fpCommand -> SetParameter (parameter);
100   parameter = new G4UIparameter ("x2", 'd', om     98   parameter = new G4UIparameter ("x2", 'd', omitable = false);
101   fpCommand -> SetParameter (parameter);           99   fpCommand -> SetParameter (parameter);
102   parameter = new G4UIparameter ("y2", 'd', om    100   parameter = new G4UIparameter ("y2", 'd', omitable = false);
103   fpCommand -> SetParameter (parameter);          101   fpCommand -> SetParameter (parameter);
104   parameter = new G4UIparameter ("z2", 'd', om    102   parameter = new G4UIparameter ("z2", 'd', omitable = false);
105   fpCommand -> SetParameter (parameter);          103   fpCommand -> SetParameter (parameter);
106   parameter =  new G4UIparameter ("unit", 's',    104   parameter =  new G4UIparameter ("unit", 's', omitable = true);
107   parameter->SetDefaultValue ("m");               105   parameter->SetDefaultValue ("m");
108   fpCommand->SetParameter    (parameter);         106   fpCommand->SetParameter    (parameter);
109 }                                                 107 }
110                                                   108 
111 G4VisCommandSceneAddArrow::~G4VisCommandSceneA    109 G4VisCommandSceneAddArrow::~G4VisCommandSceneAddArrow () {
112   delete fpCommand;                               110   delete fpCommand;
113 }                                                 111 }
114                                                   112 
115 G4String G4VisCommandSceneAddArrow::GetCurrent    113 G4String G4VisCommandSceneAddArrow::GetCurrentValue (G4UIcommand*) {
116   return "";                                      114   return "";
117 }                                                 115 }
118                                                   116 
119 void G4VisCommandSceneAddArrow::SetNewValue (G    117 void G4VisCommandSceneAddArrow::SetNewValue (G4UIcommand*, G4String newValue)
120 {                                                 118 {
121   G4VisManager::Verbosity verbosity = fpVisMan    119   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
122   G4bool warn(verbosity >= G4VisManager::warni    120   G4bool warn(verbosity >= G4VisManager::warnings);
123                                                   121 
124   G4Scene* pScene = fpVisManager->GetCurrentSc    122   G4Scene* pScene = fpVisManager->GetCurrentScene();
125   if (!pScene) {                                  123   if (!pScene) {
126     if (verbosity >= G4VisManager::errors) {      124     if (verbosity >= G4VisManager::errors) {
127       G4warn << "ERROR: No current scene.  Ple << 125       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
128     }                                             126     }
129     return;                                       127     return;
130   }                                               128   }
131                                                   129 
132   G4String unitString;                            130   G4String unitString;
133   G4double x1, y1, z1, x2, y2, z2;                131   G4double x1, y1, z1, x2, y2, z2;
134   std::istringstream is(newValue);                132   std::istringstream is(newValue);
135   is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> un    133   is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> unitString;
136   G4double unit = G4UIcommand::ValueOf(unitStr    134   G4double unit = G4UIcommand::ValueOf(unitString);
137   x1 *= unit; y1 *= unit; z1 *= unit;             135   x1 *= unit; y1 *= unit; z1 *= unit;
138   x2 *= unit; y2 *= unit; z2 *= unit;             136   x2 *= unit; y2 *= unit; z2 *= unit;
139                                                   137 
140   // Consult scene for arrow width.               138   // Consult scene for arrow width.
141   const G4VisExtent& sceneExtent = pScene->Get    139   const G4VisExtent& sceneExtent = pScene->GetExtent();
142   G4double arrowWidth =                           140   G4double arrowWidth =
143     0.005 * fCurrentLineWidth * sceneExtent.Ge    141     0.005 * fCurrentLineWidth * sceneExtent.GetExtentRadius();
144                                                   142 
145   G4VModel* model = new G4ArrowModel              143   G4VModel* model = new G4ArrowModel
146     (x1, y1, z1, x2, y2, z2,                      144     (x1, y1, z1, x2, y2, z2,
147      arrowWidth, fCurrentColour, newValue,        145      arrowWidth, fCurrentColour, newValue,
148      fCurrentArrow3DLineSegmentsPerCircle);       146      fCurrentArrow3DLineSegmentsPerCircle);
149                                                   147 
150   const G4String& currentSceneName = pScene ->    148   const G4String& currentSceneName = pScene -> GetName ();
151   G4bool successful = pScene -> AddRunDuration    149   G4bool successful = pScene -> AddRunDurationModel (model, warn);
152   if (successful) {                               150   if (successful) {
153     if (verbosity >= G4VisManager::confirmatio    151     if (verbosity >= G4VisManager::confirmations) {
154       G4cout << "Arrow has been added to scene    152       G4cout << "Arrow has been added to scene \""
155        << currentSceneName << "\"."               153        << currentSceneName << "\"."
156        << G4endl;                                 154        << G4endl;
157     }                                             155     }
158   }                                               156   }
159   else G4VisCommandsSceneAddUnsuccessful(verbo    157   else G4VisCommandsSceneAddUnsuccessful(verbosity);
160                                                   158 
161   CheckSceneAndNotifyHandlers (pScene);           159   CheckSceneAndNotifyHandlers (pScene);
162 }                                                 160 }
163                                                   161 
164 ////////////// /vis/scene/add/arrow2D ////////    162 ////////////// /vis/scene/add/arrow2D ///////////////////////////////////////
165                                                   163 
166 G4VisCommandSceneAddArrow2D::G4VisCommandScene    164 G4VisCommandSceneAddArrow2D::G4VisCommandSceneAddArrow2D () {
167   fpCommand = new G4UIcommand("/vis/scene/add/    165   fpCommand = new G4UIcommand("/vis/scene/add/arrow2D", this);
168   fpCommand -> SetGuidance ("Adds 2D arrow to     166   fpCommand -> SetGuidance ("Adds 2D arrow to current scene.");
169   fpCommand -> SetGuidance ("x,y in range [-1, << 
170   G4bool omitable;                                167   G4bool omitable;
171   G4UIparameter* parameter;                       168   G4UIparameter* parameter;
172   parameter = new G4UIparameter ("x1", 'd', om    169   parameter = new G4UIparameter ("x1", 'd', omitable = false);
173   fpCommand -> SetParameter (parameter);          170   fpCommand -> SetParameter (parameter);
174   parameter = new G4UIparameter ("y1", 'd', om    171   parameter = new G4UIparameter ("y1", 'd', omitable = false);
175   fpCommand -> SetParameter (parameter);          172   fpCommand -> SetParameter (parameter);
176   parameter = new G4UIparameter ("x2", 'd', om    173   parameter = new G4UIparameter ("x2", 'd', omitable = false);
177   fpCommand -> SetParameter (parameter);          174   fpCommand -> SetParameter (parameter);
178   parameter = new G4UIparameter ("y2", 'd', om    175   parameter = new G4UIparameter ("y2", 'd', omitable = false);
179   fpCommand -> SetParameter (parameter);          176   fpCommand -> SetParameter (parameter);
180 }                                                 177 }
181                                                   178 
182 G4VisCommandSceneAddArrow2D::~G4VisCommandScen    179 G4VisCommandSceneAddArrow2D::~G4VisCommandSceneAddArrow2D () {
183   delete fpCommand;                               180   delete fpCommand;
184 }                                                 181 }
185                                                   182 
186 G4String G4VisCommandSceneAddArrow2D::GetCurre    183 G4String G4VisCommandSceneAddArrow2D::GetCurrentValue (G4UIcommand*) {
187   return "";                                      184   return "";
188 }                                                 185 }
189                                                   186 
190 void G4VisCommandSceneAddArrow2D::SetNewValue     187 void G4VisCommandSceneAddArrow2D::SetNewValue (G4UIcommand*, G4String newValue)
191 {                                                 188 {
192   G4VisManager::Verbosity verbosity = fpVisMan    189   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
193   G4bool warn(verbosity >= G4VisManager::warni    190   G4bool warn(verbosity >= G4VisManager::warnings);
194                                                   191 
195   G4Scene* pScene = fpVisManager->GetCurrentSc    192   G4Scene* pScene = fpVisManager->GetCurrentScene();
196   if (!pScene) {                                  193   if (!pScene) {
197     if (verbosity >= G4VisManager::errors) {      194     if (verbosity >= G4VisManager::errors) {
198       G4warn << "ERROR: No current scene.  Ple << 195       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
199     }                                             196     }
200     return;                                       197     return;
201   }                                               198   }
202                                                   199 
203   G4double x1, y1, x2, y2;                        200   G4double x1, y1, x2, y2;
204   std::istringstream is(newValue);                201   std::istringstream is(newValue);
205   is >> x1 >> y1 >> x2 >> y2;                     202   is >> x1 >> y1 >> x2 >> y2;
206                                                   203 
207   Arrow2D* arrow2D = new Arrow2D                  204   Arrow2D* arrow2D = new Arrow2D
208     (x1, y1, x2, y2, fCurrentLineWidth, fCurre    205     (x1, y1, x2, y2, fCurrentLineWidth, fCurrentColour);
209   G4VModel* model =                               206   G4VModel* model =
210     new G4CallbackModel<G4VisCommandSceneAddAr    207     new G4CallbackModel<G4VisCommandSceneAddArrow2D::Arrow2D>(arrow2D);
211   model->SetType("Arrow2D");                      208   model->SetType("Arrow2D");
212   model->SetGlobalTag("Arrow2D");                 209   model->SetGlobalTag("Arrow2D");
213   model->SetGlobalDescription("Arrow2D: " + ne    210   model->SetGlobalDescription("Arrow2D: " + newValue);
214   const G4String& currentSceneName = pScene ->    211   const G4String& currentSceneName = pScene -> GetName ();
215   G4bool successful = pScene -> AddRunDuration    212   G4bool successful = pScene -> AddRunDurationModel (model, warn);
216   if (successful) {                               213   if (successful) {
217     if (verbosity >= G4VisManager::confirmatio    214     if (verbosity >= G4VisManager::confirmations) {
218       G4cout << "A 2D arrow has been added to     215       G4cout << "A 2D arrow has been added to scene \""
219        << currentSceneName << "\"."               216        << currentSceneName << "\"."
220        << G4endl;                                 217        << G4endl;
221     }                                             218     }
222   }                                               219   }
223   else G4VisCommandsSceneAddUnsuccessful(verbo    220   else G4VisCommandsSceneAddUnsuccessful(verbosity);
224                                                   221 
225   CheckSceneAndNotifyHandlers (pScene);           222   CheckSceneAndNotifyHandlers (pScene);
226 }                                                 223 }
227                                                   224 
228 G4VisCommandSceneAddArrow2D::Arrow2D::Arrow2D     225 G4VisCommandSceneAddArrow2D::Arrow2D::Arrow2D
229 (G4double x1, G4double y1,                        226 (G4double x1, G4double y1,
230  G4double x2, G4double y2,                        227  G4double x2, G4double y2,
231  G4double width, const G4Colour& colour):         228  G4double width, const G4Colour& colour):
232   fWidth(width), fColour(colour)                  229   fWidth(width), fColour(colour)
233 {                                                 230 {
234   fShaftPolyline.push_back(G4Point3D(x1,y1,0))    231   fShaftPolyline.push_back(G4Point3D(x1,y1,0));
235   fShaftPolyline.push_back(G4Point3D(x2,y2,0))    232   fShaftPolyline.push_back(G4Point3D(x2,y2,0));
236   G4Vector3D arrowDirection = G4Vector3D(x2-x1    233   G4Vector3D arrowDirection = G4Vector3D(x2-x1,y2-y1,0).unit();
237   G4Vector3D arrowPointLeftDirection(arrowDire    234   G4Vector3D arrowPointLeftDirection(arrowDirection);
238   arrowPointLeftDirection.rotateZ(150.*deg);      235   arrowPointLeftDirection.rotateZ(150.*deg);
239   G4Vector3D arrowPointRightDirection(arrowDir    236   G4Vector3D arrowPointRightDirection(arrowDirection);
240   arrowPointRightDirection.rotateZ(-150.*deg);    237   arrowPointRightDirection.rotateZ(-150.*deg);
241   fHeadPolyline.push_back(G4Point3D(x2,y2,0)+0    238   fHeadPolyline.push_back(G4Point3D(x2,y2,0)+0.04*arrowPointLeftDirection);
242   fHeadPolyline.push_back(G4Point3D(x2,y2,0));    239   fHeadPolyline.push_back(G4Point3D(x2,y2,0));
243   fHeadPolyline.push_back(G4Point3D(x2,y2,0)+0    240   fHeadPolyline.push_back(G4Point3D(x2,y2,0)+0.04*arrowPointRightDirection);
244   G4VisAttributes va;                             241   G4VisAttributes va;
245   va.SetLineWidth(fWidth);                        242   va.SetLineWidth(fWidth);
246   va.SetColour(fColour);                          243   va.SetColour(fColour);
247   fShaftPolyline.SetVisAttributes(va);            244   fShaftPolyline.SetVisAttributes(va);
248   fHeadPolyline.SetVisAttributes(va);             245   fHeadPolyline.SetVisAttributes(va);
249 }                                                 246 }
250                                                   247 
251 void G4VisCommandSceneAddArrow2D::Arrow2D::ope    248 void G4VisCommandSceneAddArrow2D::Arrow2D::operator()
252   (G4VGraphicsScene& sceneHandler, const G4Mod    249   (G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
253 {                                                 250 {
254   sceneHandler.BeginPrimitives2D();               251   sceneHandler.BeginPrimitives2D();
255   sceneHandler.AddPrimitive(fShaftPolyline);      252   sceneHandler.AddPrimitive(fShaftPolyline);
256   sceneHandler.AddPrimitive(fHeadPolyline);       253   sceneHandler.AddPrimitive(fHeadPolyline);
257   sceneHandler.EndPrimitives2D();                 254   sceneHandler.EndPrimitives2D();
258 }                                                 255 }
259                                                   256 
260 ////////////// /vis/scene/add/axes ///////////    257 ////////////// /vis/scene/add/axes //////////////////////////////////
261                                                   258 
262 G4VisCommandSceneAddAxes::G4VisCommandSceneAdd    259 G4VisCommandSceneAddAxes::G4VisCommandSceneAddAxes () {
263   G4bool omitable;                                260   G4bool omitable;
264   fpCommand = new G4UIcommand ("/vis/scene/add    261   fpCommand = new G4UIcommand ("/vis/scene/add/axes", this);
265   fpCommand -> SetGuidance ("Add axes.");         262   fpCommand -> SetGuidance ("Add axes.");
266   fpCommand -> SetGuidance                        263   fpCommand -> SetGuidance
267   ("Draws axes at (x0, y0, z0) of given length    264   ("Draws axes at (x0, y0, z0) of given length and colour.");
268   fpCommand -> SetGuidance                        265   fpCommand -> SetGuidance
269   ("If \"colour-string\" is \"auto\", x, y and    266   ("If \"colour-string\" is \"auto\", x, y and z will be red, green and blue"
270    "\n  respectively.  Otherwise it can be one    267    "\n  respectively.  Otherwise it can be one of the pre-defined text-specified"
271    "\n  colours - see information printed by t    268    "\n  colours - see information printed by the vis manager at start-up or"
272    "\n  use \"/vis/list\".");                     269    "\n  use \"/vis/list\".");
273   fpCommand -> SetGuidance                        270   fpCommand -> SetGuidance
274   ("If \"length\" is negative, it is set to ab    271   ("If \"length\" is negative, it is set to about 25% of scene extent.");
275   fpCommand -> SetGuidance                        272   fpCommand -> SetGuidance
276   ("If \"showtext\" is false, annotations are     273   ("If \"showtext\" is false, annotations are suppressed.");
277   G4UIparameter* parameter;                       274   G4UIparameter* parameter;
278   parameter =  new G4UIparameter ("x0", 'd', o    275   parameter =  new G4UIparameter ("x0", 'd', omitable = true);
279   parameter->SetDefaultValue (0.);                276   parameter->SetDefaultValue (0.);
280   fpCommand->SetParameter (parameter);            277   fpCommand->SetParameter (parameter);
281   parameter =  new G4UIparameter ("y0", 'd', o    278   parameter =  new G4UIparameter ("y0", 'd', omitable = true);
282   parameter->SetDefaultValue (0.);                279   parameter->SetDefaultValue (0.);
283   fpCommand->SetParameter (parameter);            280   fpCommand->SetParameter (parameter);
284   parameter =  new G4UIparameter ("z0", 'd', o    281   parameter =  new G4UIparameter ("z0", 'd', omitable = true);
285   parameter->SetDefaultValue (0.);                282   parameter->SetDefaultValue (0.);
286   fpCommand->SetParameter (parameter);            283   fpCommand->SetParameter (parameter);
287   parameter =  new G4UIparameter ("length", 'd    284   parameter =  new G4UIparameter ("length", 'd', omitable = true);
288   parameter->SetDefaultValue (-1.);               285   parameter->SetDefaultValue (-1.);
289   fpCommand->SetParameter (parameter);            286   fpCommand->SetParameter (parameter);
290   parameter =  new G4UIparameter ("unit", 's',    287   parameter =  new G4UIparameter ("unit", 's', omitable = true);
291   parameter->SetDefaultValue ("m");               288   parameter->SetDefaultValue ("m");
292   fpCommand->SetParameter (parameter);            289   fpCommand->SetParameter (parameter);
293   parameter =  new G4UIparameter ("colour-stri    290   parameter =  new G4UIparameter ("colour-string", 's', omitable = true);
294   parameter->SetDefaultValue  ("auto");           291   parameter->SetDefaultValue  ("auto");
295   fpCommand->SetParameter (parameter);            292   fpCommand->SetParameter (parameter);
296   parameter =  new G4UIparameter ("showtext",     293   parameter =  new G4UIparameter ("showtext", 'b', omitable = true);
297   parameter->SetDefaultValue  ("true");           294   parameter->SetDefaultValue  ("true");
298   fpCommand->SetParameter (parameter);            295   fpCommand->SetParameter (parameter);
299 }                                                 296 }
300                                                   297 
301 G4VisCommandSceneAddAxes::~G4VisCommandSceneAd    298 G4VisCommandSceneAddAxes::~G4VisCommandSceneAddAxes () {
302   delete fpCommand;                               299   delete fpCommand;
303 }                                                 300 }
304                                                   301 
305 G4String G4VisCommandSceneAddAxes::GetCurrentV    302 G4String G4VisCommandSceneAddAxes::GetCurrentValue (G4UIcommand*) {
306   return "";                                      303   return "";
307 }                                                 304 }
308                                                   305 
309 void G4VisCommandSceneAddAxes::SetNewValue (G4    306 void G4VisCommandSceneAddAxes::SetNewValue (G4UIcommand*, G4String newValue) {
310                                                   307 
311   G4VisManager::Verbosity verbosity = fpVisMan    308   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
312   G4bool warn(verbosity >= G4VisManager::warni    309   G4bool warn(verbosity >= G4VisManager::warnings);
313                                                   310 
314   G4Scene* pScene = fpVisManager->GetCurrentSc    311   G4Scene* pScene = fpVisManager->GetCurrentScene();
315   if (!pScene) {                                  312   if (!pScene) {
316     if (verbosity >= G4VisManager::errors) {      313     if (verbosity >= G4VisManager::errors) {
317       G4warn << "ERROR: No current scene.  Ple << 314       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
318     }                                             315     }
319     return;                                       316     return;
320   } else {                                        317   } else {
321     if (pScene->GetExtent().GetExtentRadius()     318     if (pScene->GetExtent().GetExtentRadius() <= 0.) {
322       if (verbosity >= G4VisManager::errors) {    319       if (verbosity >= G4VisManager::errors) {
323         G4warn                                 << 320         G4cerr
324   << "ERROR: Scene has no extent. Add volumes     321   << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
325         << G4endl;                                322         << G4endl;
326       }                                           323       }
327       return;                                     324       return;
328     }                                             325     }
329   }                                               326   }
330                                                   327 
331   G4String unitString, colourString, showTextS    328   G4String unitString, colourString, showTextString;
332   G4double x0, y0, z0, length;                    329   G4double x0, y0, z0, length;
333   std::istringstream is (newValue);               330   std::istringstream is (newValue);
334   is >> x0 >> y0 >> z0 >> length >> unitString    331   is >> x0 >> y0 >> z0 >> length >> unitString
335   >> colourString >> showTextString;              332   >> colourString >> showTextString;
336   G4bool showText = G4UIcommand::ConvertToBool    333   G4bool showText = G4UIcommand::ConvertToBool(showTextString);
337                                                   334 
338                                                   335 
339   G4double unit = G4UIcommand::ValueOf(unitStr    336   G4double unit = G4UIcommand::ValueOf(unitString);
340   x0 *= unit; y0 *= unit; z0 *= unit;             337   x0 *= unit; y0 *= unit; z0 *= unit;
341   const G4VisExtent& sceneExtent = pScene->Get    338   const G4VisExtent& sceneExtent = pScene->GetExtent();  // Existing extent.
342   if (length < 0.) {                              339   if (length < 0.) {
343     const G4double lengthMax = 0.5 * sceneExte    340     const G4double lengthMax = 0.5 * sceneExtent.GetExtentRadius();
344     const G4double intLog10Length = std::floor    341     const G4double intLog10Length = std::floor(std::log10(lengthMax));
345     length = std::pow(10,intLog10Length);         342     length = std::pow(10,intLog10Length);
346     if (5.*length < lengthMax) length *= 5.;      343     if (5.*length < lengthMax) length *= 5.;
347     else if (2.*length < lengthMax) length *=     344     else if (2.*length < lengthMax) length *= 2.;
348   } else {                                        345   } else {
349     length *= unit;                               346     length *= unit;
350   }                                               347   }
351                                                   348 
352   // Consult scene for arrow width...             349   // Consult scene for arrow width...
353   G4double arrowWidth =                           350   G4double arrowWidth =
354     0.05 * fCurrentLineWidth * sceneExtent.Get << 351     0.005 * fCurrentLineWidth * sceneExtent.GetExtentRadius();
355   // ...but limit it to length/30.             << 352   // ...but limit it to length/50.
356   if (arrowWidth > length/30.) arrowWidth = le << 353   if (arrowWidth > length/50.) arrowWidth = length/50.;
357                                                   354 
358   G4VModel* model = new G4AxesModel               355   G4VModel* model = new G4AxesModel
359     (x0, y0, z0, length, arrowWidth, colourStr    356     (x0, y0, z0, length, arrowWidth, colourString, newValue,
360      showText, fCurrentTextSize);                 357      showText, fCurrentTextSize);
361                                                   358 
362   G4bool successful = pScene -> AddRunDuration    359   G4bool successful = pScene -> AddRunDurationModel (model, warn);
363   const G4String& currentSceneName = pScene ->    360   const G4String& currentSceneName = pScene -> GetName ();
364   if (successful) {                               361   if (successful) {
365     if (verbosity >= G4VisManager::confirmatio    362     if (verbosity >= G4VisManager::confirmations) {
366       G4cout << "Axes of length " << G4BestUni    363       G4cout << "Axes of length " << G4BestUnit(length,"Length")
367       << "have been added to scene \"" << curr    364       << "have been added to scene \"" << currentSceneName << "\"."
368       << G4endl;                                  365       << G4endl;
369     }                                             366     }
370   }                                               367   }
371   else G4VisCommandsSceneAddUnsuccessful(verbo    368   else G4VisCommandsSceneAddUnsuccessful(verbosity);
372                                                   369 
373   CheckSceneAndNotifyHandlers (pScene);           370   CheckSceneAndNotifyHandlers (pScene);
374 }                                                 371 }
375                                                   372 
376 ////////////// /vis/scene/add/date ///////////    373 ////////////// /vis/scene/add/date ///////////////////////////////////////
377                                                   374 
378 G4VisCommandSceneAddDate::G4VisCommandSceneAdd    375 G4VisCommandSceneAddDate::G4VisCommandSceneAddDate () {
379   G4bool omitable;                                376   G4bool omitable;
380   fpCommand = new G4UIcommand ("/vis/scene/add    377   fpCommand = new G4UIcommand ("/vis/scene/add/date", this);
381   fpCommand -> SetGuidance ("Adds date to curr    378   fpCommand -> SetGuidance ("Adds date to current scene.");
382   fpCommand -> SetGuidance                        379   fpCommand -> SetGuidance
383   ("If \"date\"is omitted, the current date an    380   ("If \"date\"is omitted, the current date and time is drawn."
384    "\nOtherwise, the string, including the res    381    "\nOtherwise, the string, including the rest of the line, is drawn.");
385   G4UIparameter* parameter;                       382   G4UIparameter* parameter;
386   parameter = new G4UIparameter ("size", 'i',     383   parameter = new G4UIparameter ("size", 'i', omitable = true);
387   parameter -> SetGuidance ("Screen size of te    384   parameter -> SetGuidance ("Screen size of text in pixels.");
388   parameter -> SetDefaultValue (18);              385   parameter -> SetDefaultValue (18);
389   fpCommand -> SetParameter (parameter);          386   fpCommand -> SetParameter (parameter);
390   parameter = new G4UIparameter ("x-position",    387   parameter = new G4UIparameter ("x-position", 'd', omitable = true);
391   parameter -> SetGuidance ("x screen position    388   parameter -> SetGuidance ("x screen position in range -1 < x < 1.");
392   parameter -> SetDefaultValue (0.95);            389   parameter -> SetDefaultValue (0.95);
393   fpCommand -> SetParameter (parameter);          390   fpCommand -> SetParameter (parameter);
394   parameter = new G4UIparameter ("y-position",    391   parameter = new G4UIparameter ("y-position", 'd', omitable = true);
395   parameter -> SetGuidance ("y screen position    392   parameter -> SetGuidance ("y screen position in range -1 < y < 1.");
396   parameter -> SetDefaultValue (0.9);             393   parameter -> SetDefaultValue (0.9);
397   fpCommand -> SetParameter (parameter);          394   fpCommand -> SetParameter (parameter);
398   parameter = new G4UIparameter ("layout", 's'    395   parameter = new G4UIparameter ("layout", 's', omitable = true);
399   parameter -> SetGuidance ("Layout, i.e., adj    396   parameter -> SetGuidance ("Layout, i.e., adjustment: left|centre|right.");
400   parameter -> SetDefaultValue ("right");         397   parameter -> SetDefaultValue ("right");
401   fpCommand -> SetParameter (parameter);          398   fpCommand -> SetParameter (parameter);
402   parameter = new G4UIparameter ("date", 's',     399   parameter = new G4UIparameter ("date", 's', omitable = true);
403   parameter -> SetDefaultValue ("-");             400   parameter -> SetDefaultValue ("-");
404   fpCommand -> SetParameter (parameter);          401   fpCommand -> SetParameter (parameter);
405 }                                                 402 }
406                                                   403 
407 G4VisCommandSceneAddDate::~G4VisCommandSceneAd    404 G4VisCommandSceneAddDate::~G4VisCommandSceneAddDate () {
408   delete fpCommand;                               405   delete fpCommand;
409 }                                                 406 }
410                                                   407 
411 G4String G4VisCommandSceneAddDate::GetCurrentV    408 G4String G4VisCommandSceneAddDate::GetCurrentValue (G4UIcommand*) {
412   return "";                                      409   return "";
413 }                                                 410 }
414                                                   411 
415 void G4VisCommandSceneAddDate::SetNewValue (G4    412 void G4VisCommandSceneAddDate::SetNewValue (G4UIcommand*, G4String newValue)
416 {                                                 413 {
417   G4VisManager::Verbosity verbosity = fpVisMan    414   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
418   G4bool warn(verbosity >= G4VisManager::warni    415   G4bool warn(verbosity >= G4VisManager::warnings);
419                                                   416 
420   G4Scene* pScene = fpVisManager->GetCurrentSc    417   G4Scene* pScene = fpVisManager->GetCurrentScene();
421   if (!pScene) {                                  418   if (!pScene) {
422     if (verbosity >= G4VisManager::errors) {      419     if (verbosity >= G4VisManager::errors) {
423       G4warn << "ERROR: No current scene.  Ple << 420       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
424     }                                             421     }
425     return;                                       422     return;
426   }                                               423   }
427                                                   424 
428   G4int size;                                     425   G4int size;
429   G4double x, y;                                  426   G4double x, y;
430   G4String layoutString, dateString;              427   G4String layoutString, dateString;
431   std::istringstream is(newValue);                428   std::istringstream is(newValue);
432   is >> size >> x >> y >> layoutString >> date    429   is >> size >> x >> y >> layoutString >> dateString;
433   // Read rest of line, if any.                   430   // Read rest of line, if any.
434   const size_t NREMAINDER = 100;                  431   const size_t NREMAINDER = 100;
435   char remainder[NREMAINDER];                     432   char remainder[NREMAINDER];
436   remainder[0]='\0';  // In case there is noth    433   remainder[0]='\0';  // In case there is nothing remaining.
437   is.getline(remainder, NREMAINDER);              434   is.getline(remainder, NREMAINDER);
438   dateString += remainder;                        435   dateString += remainder;
439   G4Text::Layout layout = G4Text::right;          436   G4Text::Layout layout = G4Text::right;
440   if (layoutString[0] == 'l') layout = G4Text:    437   if (layoutString[0] == 'l') layout = G4Text::left;
441   else if (layoutString[0] == 'c') layout = G4    438   else if (layoutString[0] == 'c') layout = G4Text::centre;
442   else if (layoutString[0] == 'r') layout = G4    439   else if (layoutString[0] == 'r') layout = G4Text::right;
443                                                   440 
444   Date* date = new Date(fpVisManager, size, x,    441   Date* date = new Date(fpVisManager, size, x, y, layout, dateString);
445   G4VModel* model =                               442   G4VModel* model =
446     new G4CallbackModel<G4VisCommandSceneAddDa    443     new G4CallbackModel<G4VisCommandSceneAddDate::Date>(date);
447   model->SetType("Date");                         444   model->SetType("Date");
448   model->SetGlobalTag("Date");                    445   model->SetGlobalTag("Date");
449   model->SetGlobalDescription("Date: " + newVa    446   model->SetGlobalDescription("Date: " + newValue);
450   const G4String& currentSceneName = pScene ->    447   const G4String& currentSceneName = pScene -> GetName ();
451   G4bool successful = pScene -> AddEndOfEventM << 448   G4bool successful = pScene -> AddRunDurationModel (model, warn);
452   if (successful) {                               449   if (successful) {
453     if (verbosity >= G4VisManager::confirmatio    450     if (verbosity >= G4VisManager::confirmations) {
454       G4cout << "Date has been added to scene     451       G4cout << "Date has been added to scene \""
455        << currentSceneName << "\"."               452        << currentSceneName << "\"."
456        << G4endl;                                 453        << G4endl;
457     }                                             454     }
458   }                                               455   }
459   else G4VisCommandsSceneAddUnsuccessful(verbo    456   else G4VisCommandsSceneAddUnsuccessful(verbosity);
460                                                   457 
461   CheckSceneAndNotifyHandlers (pScene);           458   CheckSceneAndNotifyHandlers (pScene);
462 }                                                 459 }
463                                                   460 
464 void G4VisCommandSceneAddDate::Date::operator(    461 void G4VisCommandSceneAddDate::Date::operator()
465   (G4VGraphicsScene& sceneHandler, const G4Mod    462   (G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
466 {                                                 463 {
467   G4String time;                                  464   G4String time;
468   if (fDate == "-") {                             465   if (fDate == "-") {
469     time = fTimer.GetClockTime();                 466     time = fTimer.GetClockTime();
470   } else {                                        467   } else {
471     time = fDate;                                 468     time = fDate;
472   }                                               469   }
473   // Check for \n, starting from back, and era    470   // Check for \n, starting from back, and erase.
474   std::string::size_type i = time.rfind('\n');    471   std::string::size_type i = time.rfind('\n');
475   if (i != std::string::npos) time.erase(i);      472   if (i != std::string::npos) time.erase(i);
476   G4Text text(time, G4Point3D(fX, fY, 0.));       473   G4Text text(time, G4Point3D(fX, fY, 0.));
477   text.SetScreenSize(fSize);                      474   text.SetScreenSize(fSize);
478   text.SetLayout(fLayout);                        475   text.SetLayout(fLayout);
479   G4VisAttributes textAtts(G4Colour(0.,1.,1));    476   G4VisAttributes textAtts(G4Colour(0.,1.,1));
480   text.SetVisAttributes(textAtts);                477   text.SetVisAttributes(textAtts);
481   sceneHandler.BeginPrimitives2D();               478   sceneHandler.BeginPrimitives2D();
482   sceneHandler.AddPrimitive(text);                479   sceneHandler.AddPrimitive(text);
483   sceneHandler.EndPrimitives2D();                 480   sceneHandler.EndPrimitives2D();
484 }                                                 481 }
485                                                   482 
486 ////////////// /vis/scene/add/digis //////////    483 ////////////// /vis/scene/add/digis ///////////////////////////////////////
487                                                   484 
488 G4VisCommandSceneAddDigis::G4VisCommandSceneAd    485 G4VisCommandSceneAddDigis::G4VisCommandSceneAddDigis () {
489   fpCommand = new G4UIcmdWithoutParameter ("/v    486   fpCommand = new G4UIcmdWithoutParameter ("/vis/scene/add/digis", this);
490   fpCommand -> SetGuidance ("Adds digis to cur    487   fpCommand -> SetGuidance ("Adds digis to current scene.");
491   fpCommand -> SetGuidance                        488   fpCommand -> SetGuidance
492     ("Digis are drawn at end of event when the    489     ("Digis are drawn at end of event when the scene in which"
493      "\nthey are added is current.");             490      "\nthey are added is current.");
494 }                                                 491 }
495                                                   492 
496 G4VisCommandSceneAddDigis::~G4VisCommandSceneA    493 G4VisCommandSceneAddDigis::~G4VisCommandSceneAddDigis () {
497   delete fpCommand;                               494   delete fpCommand;
498 }                                                 495 }
499                                                   496 
500 G4String G4VisCommandSceneAddDigis::GetCurrent    497 G4String G4VisCommandSceneAddDigis::GetCurrentValue (G4UIcommand*) {
501   return "";                                      498   return "";
502 }                                                 499 }
503                                                   500 
504 void G4VisCommandSceneAddDigis::SetNewValue (G    501 void G4VisCommandSceneAddDigis::SetNewValue (G4UIcommand*, G4String) {
505                                                   502 
506   G4VisManager::Verbosity verbosity = fpVisMan    503   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
507   G4bool warn(verbosity >= G4VisManager::warni    504   G4bool warn(verbosity >= G4VisManager::warnings);
508                                                   505 
509   G4Scene* pScene = fpVisManager->GetCurrentSc    506   G4Scene* pScene = fpVisManager->GetCurrentScene();
510   if (!pScene) {                                  507   if (!pScene) {
511     if (verbosity >= G4VisManager::errors) {      508     if (verbosity >= G4VisManager::errors) {
512       G4warn << "ERROR: No current scene.  Ple << 509       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
513     }                                             510     }
514     return;                                       511     return;
515   }                                               512   }
516                                                   513 
517   G4VModel* model = new G4DigiModel;              514   G4VModel* model = new G4DigiModel;
518   const G4String& currentSceneName = pScene ->    515   const G4String& currentSceneName = pScene -> GetName ();
519   G4bool successful = pScene -> AddEndOfEventM    516   G4bool successful = pScene -> AddEndOfEventModel (model, warn);
520   if (successful) {                               517   if (successful) {
521     if (verbosity >= G4VisManager::confirmatio    518     if (verbosity >= G4VisManager::confirmations) {
522       G4cout << "Digis, if any, will be drawn     519       G4cout << "Digis, if any, will be drawn at end of run in scene \""
523        << currentSceneName << "\"."               520        << currentSceneName << "\"."
524        << G4endl;                                 521        << G4endl;
525     }                                             522     }
526   }                                               523   }
527   else G4VisCommandsSceneAddUnsuccessful(verbo    524   else G4VisCommandsSceneAddUnsuccessful(verbosity);
528                                                   525 
529   CheckSceneAndNotifyHandlers (pScene);           526   CheckSceneAndNotifyHandlers (pScene);
530 }                                                 527 }
531                                                   528 
532 ////////////// /vis/scene/add/electricField //    529 ////////////// /vis/scene/add/electricField ///////////////////////////////////////
533                                                   530 
534 G4VisCommandSceneAddElectricField::G4VisComman    531 G4VisCommandSceneAddElectricField::G4VisCommandSceneAddElectricField () {
535   G4bool omitable;                                532   G4bool omitable;
536   fpCommand = new G4UIcommand ("/vis/scene/add    533   fpCommand = new G4UIcommand ("/vis/scene/add/electricField", this);
537   fpCommand -> SetGuidance                        534   fpCommand -> SetGuidance
538   ("Adds electric field representation to curr    535   ("Adds electric field representation to current scene.");
539   fpCommand -> SetGuidance                        536   fpCommand -> SetGuidance
540   ("The first parameter is no. of data points     537   ("The first parameter is no. of data points per half extent.  So, possibly, at"
541    "\nmaximum, the number of data points sampl    538    "\nmaximum, the number of data points sampled is (2*n+1)^3, which can grow"
542    "\nlarge--be warned!"                          539    "\nlarge--be warned!"
543    "\nThe default value is 10, i.e., a 21x21x2    540    "\nThe default value is 10, i.e., a 21x21x21 array, i.e., 9,261 sampling points."
544    "\nThat may swamp your view, but usually, a    541    "\nThat may swamp your view, but usually, a field is limited to a small part of"
545    "\nthe extent, so it's not a problem. But i    542    "\nthe extent, so it's not a problem. But if it is, here are some of the things"
546    "\nyou can do:"                                543    "\nyou can do:"
547    "\n- reduce the number of data points per h    544    "\n- reduce the number of data points per half extent (first parameter);"
548    "\n- specify \"lightArrow\" (second paramet    545    "\n- specify \"lightArrow\" (second parameter);"
549    "\n- restrict the region sampled with \"/vi    546    "\n- restrict the region sampled with \"/vis/set/extentForField\";"
550    "\n- restrict the drawing to a specific vol    547    "\n- restrict the drawing to a specific volume with"
551    "\n    \"/vis/set/volumeForField\" or \"/vi    548    "\n    \"/vis/set/volumeForField\" or \"/vis/touchable/volumeForField\"."
552    "\nNote: you might have to deactivate exist    549    "\nNote: you might have to deactivate existing field models with"
553    "\n  \"/vis/scene/activateModel Field false    550    "\n  \"/vis/scene/activateModel Field false\" and re-issue"
554    "\n  \"/vis/scene/add/...Field\" command ag    551    "\n  \"/vis/scene/add/...Field\" command again.");
555   fpCommand -> SetGuidance                        552   fpCommand -> SetGuidance
556   ("In the arrow representation, the length of    553   ("In the arrow representation, the length of the arrow is proportional"
557    "\nto the magnitude of the field and the co    554    "\nto the magnitude of the field and the colour is mapped onto the range"
558    "\nas a fraction of the maximum magnitude:     555    "\nas a fraction of the maximum magnitude: 0->0.5->1 is red->green->blue.");
559   G4UIparameter* parameter;                       556   G4UIparameter* parameter;
560   parameter = new G4UIparameter ("nDataPointsP    557   parameter = new G4UIparameter ("nDataPointsPerHalfExtent", 'i', omitable = true);
561   parameter -> SetDefaultValue (10);              558   parameter -> SetDefaultValue (10);
562   fpCommand -> SetParameter (parameter);          559   fpCommand -> SetParameter (parameter);
563   parameter = new G4UIparameter ("representati    560   parameter = new G4UIparameter ("representation", 's', omitable = true);
564   parameter -> SetParameterCandidates("fullArr    561   parameter -> SetParameterCandidates("fullArrow lightArrow");
565   parameter -> SetDefaultValue ("fullArrow");     562   parameter -> SetDefaultValue ("fullArrow");
566   fpCommand -> SetParameter (parameter);          563   fpCommand -> SetParameter (parameter);
567 }                                                 564 }
568                                                   565 
569 G4VisCommandSceneAddElectricField::~G4VisComma    566 G4VisCommandSceneAddElectricField::~G4VisCommandSceneAddElectricField () {
570   delete fpCommand;                               567   delete fpCommand;
571 }                                                 568 }
572                                                   569 
573 G4String G4VisCommandSceneAddElectricField::Ge    570 G4String G4VisCommandSceneAddElectricField::GetCurrentValue (G4UIcommand*) {
574   return "";                                      571   return "";
575 }                                                 572 }
576                                                   573 
577 void G4VisCommandSceneAddElectricField::SetNew    574 void G4VisCommandSceneAddElectricField::SetNewValue
578 (G4UIcommand*, G4String newValue) {               575 (G4UIcommand*, G4String newValue) {
579                                                   576 
580   G4VisManager::Verbosity verbosity = fpVisMan    577   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
581   G4bool warn(verbosity >= G4VisManager::warni    578   G4bool warn(verbosity >= G4VisManager::warnings);
582                                                   579 
583   G4Scene* pScene = fpVisManager->GetCurrentSc    580   G4Scene* pScene = fpVisManager->GetCurrentScene();
584   if (!pScene) {                                  581   if (!pScene) {
585     if (verbosity >= G4VisManager::errors) {      582     if (verbosity >= G4VisManager::errors) {
586       G4warn <<  "ERROR: No current scene.  Pl << 583       G4cerr <<  "ERROR: No current scene.  Please create one." << G4endl;
587     }                                             584     }
588     return;                                       585     return;
589   }                                               586   }
590                                                   587 
591   G4int nDataPointsPerHalfExtent;                 588   G4int nDataPointsPerHalfExtent;
592   G4String representation;                        589   G4String representation;
593   std::istringstream iss(newValue);               590   std::istringstream iss(newValue);
594   iss >> nDataPointsPerHalfExtent >> represent    591   iss >> nDataPointsPerHalfExtent >> representation;
595   G4ElectricFieldModel::Representation            592   G4ElectricFieldModel::Representation
596   modelRepresentation = G4ElectricFieldModel::    593   modelRepresentation = G4ElectricFieldModel::fullArrow;
597   if (representation == "lightArrow") {           594   if (representation == "lightArrow") {
598     modelRepresentation = G4ElectricFieldModel    595     modelRepresentation = G4ElectricFieldModel::lightArrow;
599   }                                               596   }
600   G4VModel* model;                                597   G4VModel* model;
601   model = new G4ElectricFieldModel                598   model = new G4ElectricFieldModel
602   (nDataPointsPerHalfExtent,modelRepresentatio    599   (nDataPointsPerHalfExtent,modelRepresentation,
603    fCurrentArrow3DLineSegmentsPerCircle,          600    fCurrentArrow3DLineSegmentsPerCircle,
604    fCurrentExtentForField,                        601    fCurrentExtentForField,
605    fCurrrentPVFindingsForField);                  602    fCurrrentPVFindingsForField);
606   const G4String& currentSceneName = pScene ->    603   const G4String& currentSceneName = pScene -> GetName ();
607   G4bool successful = pScene -> AddRunDuration    604   G4bool successful = pScene -> AddRunDurationModel (model, warn);
608   if (successful) {                               605   if (successful) {
609     if (verbosity >= G4VisManager::confirmatio    606     if (verbosity >= G4VisManager::confirmations) {
610       G4cout                                      607       G4cout
611       << "Electric field, if any, will be draw    608       << "Electric field, if any, will be drawn in scene \""
612       << currentSceneName                         609       << currentSceneName
613       << "\"\n  with "                            610       << "\"\n  with "
614       << nDataPointsPerHalfExtent                 611       << nDataPointsPerHalfExtent
615       << " data points per half extent and wit    612       << " data points per half extent and with representation \""
616       << representation                           613       << representation
617       << '\"'                                     614       << '\"'
618       << G4endl;                                  615       << G4endl;
619     }                                             616     }
620   }                                               617   }
621   else G4VisCommandsSceneAddUnsuccessful(verbo    618   else G4VisCommandsSceneAddUnsuccessful(verbosity);
622                                                   619 
623   CheckSceneAndNotifyHandlers (pScene);           620   CheckSceneAndNotifyHandlers (pScene);
624 }                                                 621 }
625                                                   622 
626 ////////////// /vis/scene/add/eventID ////////    623 ////////////// /vis/scene/add/eventID ///////////////////////////////////////
627                                                   624 
628 G4VisCommandSceneAddEventID::G4VisCommandScene    625 G4VisCommandSceneAddEventID::G4VisCommandSceneAddEventID () {
629   G4bool omitable;                                626   G4bool omitable;
630   fpCommand = new G4UIcommand ("/vis/scene/add    627   fpCommand = new G4UIcommand ("/vis/scene/add/eventID", this);
631   fpCommand -> SetGuidance ("Adds eventID to c    628   fpCommand -> SetGuidance ("Adds eventID to current scene.");
632   fpCommand -> SetGuidance                        629   fpCommand -> SetGuidance
633     ("Run and event numbers are drawn at end o    630     ("Run and event numbers are drawn at end of event or run when"
634      "\n the scene in which they are added is     631      "\n the scene in which they are added is current.");
635   G4UIparameter* parameter;                       632   G4UIparameter* parameter;
636   parameter = new G4UIparameter ("size", 'i',     633   parameter = new G4UIparameter ("size", 'i', omitable = true);
637   parameter -> SetGuidance ("Screen size of te    634   parameter -> SetGuidance ("Screen size of text in pixels.");
638   parameter -> SetDefaultValue (18);              635   parameter -> SetDefaultValue (18);
639   fpCommand -> SetParameter (parameter);          636   fpCommand -> SetParameter (parameter);
640   parameter = new G4UIparameter ("x-position",    637   parameter = new G4UIparameter ("x-position", 'd', omitable = true);
641   parameter -> SetGuidance ("x screen position    638   parameter -> SetGuidance ("x screen position in range -1 < x < 1.");
642   parameter -> SetDefaultValue (-0.95);           639   parameter -> SetDefaultValue (-0.95);
643   fpCommand -> SetParameter (parameter);          640   fpCommand -> SetParameter (parameter);
644   parameter = new G4UIparameter ("y-position",    641   parameter = new G4UIparameter ("y-position", 'd', omitable = true);
645   parameter -> SetGuidance ("y screen position    642   parameter -> SetGuidance ("y screen position in range -1 < y < 1.");
646   parameter -> SetDefaultValue (0.9);             643   parameter -> SetDefaultValue (0.9);
647   fpCommand -> SetParameter (parameter);          644   fpCommand -> SetParameter (parameter);
648   parameter = new G4UIparameter ("layout", 's'    645   parameter = new G4UIparameter ("layout", 's', omitable = true);
649   parameter -> SetGuidance ("Layout, i.e., adj    646   parameter -> SetGuidance ("Layout, i.e., adjustment: left|centre|right.");
650   parameter -> SetDefaultValue ("left");          647   parameter -> SetDefaultValue ("left");
651   fpCommand -> SetParameter (parameter);          648   fpCommand -> SetParameter (parameter);
652 }                                                 649 }
653                                                   650 
654 G4VisCommandSceneAddEventID::~G4VisCommandScen    651 G4VisCommandSceneAddEventID::~G4VisCommandSceneAddEventID () {
655   delete fpCommand;                               652   delete fpCommand;
656 }                                                 653 }
657                                                   654 
658 G4String G4VisCommandSceneAddEventID::GetCurre    655 G4String G4VisCommandSceneAddEventID::GetCurrentValue (G4UIcommand*) {
659   return "";                                      656   return "";
660 }                                                 657 }
661                                                   658 
662 void G4VisCommandSceneAddEventID::SetNewValue     659 void G4VisCommandSceneAddEventID::SetNewValue (G4UIcommand*, G4String newValue)
663 {                                                 660 {
664   G4VisManager::Verbosity verbosity = fpVisMan    661   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
665   G4bool warn(verbosity >= G4VisManager::warni    662   G4bool warn(verbosity >= G4VisManager::warnings);
666                                                   663 
667   G4Scene* pScene = fpVisManager->GetCurrentSc    664   G4Scene* pScene = fpVisManager->GetCurrentScene();
668   if (!pScene) {                                  665   if (!pScene) {
669     if (verbosity >= G4VisManager::errors) {      666     if (verbosity >= G4VisManager::errors) {
670       G4warn << "ERROR: No current scene.  Ple << 667       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
671     }                                             668     }
672     return;                                       669     return;
673   }                                               670   }
674                                                   671 
675   G4int size;                                     672   G4int size;
676   G4double x, y;                                  673   G4double x, y;
677   G4String layoutString;                          674   G4String layoutString;
678   std::istringstream is(newValue);                675   std::istringstream is(newValue);
679   is >> size >> x >> y >> layoutString;           676   is >> size >> x >> y >> layoutString;
680                                                   677 
681   G4Text::Layout layout = G4Text::right;          678   G4Text::Layout layout = G4Text::right;
682   if (layoutString[0] == 'l') layout = G4Text:    679   if (layoutString[0] == 'l') layout = G4Text::left;
683   else if (layoutString[0] == 'c') layout = G4    680   else if (layoutString[0] == 'c') layout = G4Text::centre;
684   else if (layoutString[0] == 'r') layout = G4    681   else if (layoutString[0] == 'r') layout = G4Text::right;
685                                                   682 
686   // For End of Event (only for reviewing kept    683   // For End of Event (only for reviewing kept events one by one)
687   EventID* eoeEventID                             684   EventID* eoeEventID
688   = new EventID(forEndOfEvent, fpVisManager, s    685   = new EventID(forEndOfEvent, fpVisManager, size, x, y, layout);
689   G4VModel* eoeModel =                            686   G4VModel* eoeModel =
690     new G4CallbackModel<G4VisCommandSceneAddEv    687     new G4CallbackModel<G4VisCommandSceneAddEventID::EventID>(eoeEventID);
691   eoeModel->SetType("EoEEventID");                688   eoeModel->SetType("EoEEventID");
692   eoeModel->SetGlobalTag("EoEEventID");           689   eoeModel->SetGlobalTag("EoEEventID");
693   eoeModel->SetGlobalDescription("EoEEventID:     690   eoeModel->SetGlobalDescription("EoEEventID: " + newValue);
694   G4bool successfulEoE = pScene -> AddEndOfEve    691   G4bool successfulEoE = pScene -> AddEndOfEventModel (eoeModel, warn);
695                                                   692 
696   // For End of Run                               693   // For End of Run
697   EventID* eorEventID                             694   EventID* eorEventID
698   = new EventID(forEndOfRun, fpVisManager, siz    695   = new EventID(forEndOfRun, fpVisManager, size, x, y, layout);
699   G4VModel* eorModel =                            696   G4VModel* eorModel =
700   new G4CallbackModel<G4VisCommandSceneAddEven    697   new G4CallbackModel<G4VisCommandSceneAddEventID::EventID>(eorEventID);
701   eorModel->SetType("EoREventID");                698   eorModel->SetType("EoREventID");
702   eorModel->SetGlobalTag("EoREventID");           699   eorModel->SetGlobalTag("EoREventID");
703   eorModel->SetGlobalDescription("EoREventID:     700   eorModel->SetGlobalDescription("EoREventID: " + newValue);
704   G4bool successfulEoR = pScene -> AddEndOfRun    701   G4bool successfulEoR = pScene -> AddEndOfRunModel (eorModel, warn);
705                                                   702 
706   if (successfulEoE && successfulEoR) {           703   if (successfulEoE && successfulEoR) {
707     if (verbosity >= G4VisManager::confirmatio    704     if (verbosity >= G4VisManager::confirmations) {
708       const G4String& currentSceneName = pScen    705       const G4String& currentSceneName = pScene -> GetName ();
709       G4cout << "EventID has been added to sce    706       G4cout << "EventID has been added to scene \""
710       << currentSceneName << "\"."                707       << currentSceneName << "\"."
711       << G4endl;                                  708       << G4endl;
712     }                                             709     }
713   }                                               710   }
714   else G4VisCommandsSceneAddUnsuccessful(verbo    711   else G4VisCommandsSceneAddUnsuccessful(verbosity);
715                                                   712 
716   CheckSceneAndNotifyHandlers (pScene);           713   CheckSceneAndNotifyHandlers (pScene);
717 }                                                 714 }
718                                                   715 
719 void G4VisCommandSceneAddEventID::EventID::ope    716 void G4VisCommandSceneAddEventID::EventID::operator()
720 (G4VGraphicsScene& sceneHandler, const G4Model    717 (G4VGraphicsScene& sceneHandler, const G4ModelingParameters* mp)
721 {                                                 718 {
722   G4RunManager* runManager = G4RunManagerFacto    719   G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
723   if(!runManager)                                 720   if(!runManager)
724     return;                                       721     return;
725                                                   722 
726   const G4Run* currentRun = runManager->GetCur    723   const G4Run* currentRun = runManager->GetCurrentRun();
727   if (!currentRun) return;                        724   if (!currentRun) return;
728                                                   725 
729   const G4int currentRunID = currentRun->GetRu    726   const G4int currentRunID = currentRun->GetRunID();
730                                                   727 
731   std::ostringstream oss;                         728   std::ostringstream oss;
732   switch (fForWhat) {                             729   switch (fForWhat) {
733     case forEndOfEvent:                           730     case forEndOfEvent:
734     {                                             731     {
735       // Only use if reviewing kept events        732       // Only use if reviewing kept events
736       if (!fpVisManager->GetReviewingKeptEvent    733       if (!fpVisManager->GetReviewingKeptEvents()) return;
737       const G4Event* currentEvent = mp->GetEve    734       const G4Event* currentEvent = mp->GetEvent();
738       if (!currentEvent) return;                  735       if (!currentEvent) return;
739       G4int eventID = currentEvent->GetEventID    736       G4int eventID = currentEvent->GetEventID();
740       oss << "Run " << currentRunID << " Event    737       oss << "Run " << currentRunID << " Event " << eventID;
741       break;                                      738       break;
742     }                                             739     }
743     case forEndOfRun:                             740     case forEndOfRun:
744     {                                             741     {
745       // Only use if NOT reviewing kept events    742       // Only use if NOT reviewing kept events
746       if (fpVisManager->GetReviewingKeptEvents    743       if (fpVisManager->GetReviewingKeptEvents()) return;
747       const G4int nEvents = currentRun->GetNum    744       const G4int nEvents = currentRun->GetNumberOfEventToBeProcessed();
748       size_t nKeptEvents = (size_t)(currentRun << 745       const auto* events = currentRun->GetEventVector();
                                                   >> 746       size_t nKeptEvents = events? events->size(): 0;
749       oss << "Run " << currentRunID << " (" <<    747       oss << "Run " << currentRunID << " (" << nEvents << " event";
750       if (nEvents != 1) oss << 's';               748       if (nEvents != 1) oss << 's';
751       oss << ", " << nKeptEvents << " kept)";     749       oss << ", " << nKeptEvents << " kept)";
752       break;                                      750       break;
753     }                                             751     }
754     default:                                      752     default:
755       return;                                     753       return;
756   }                                               754   }
757                                                   755 
758   G4Text text(oss.str(), G4Point3D(fX, fY, 0.)    756   G4Text text(oss.str(), G4Point3D(fX, fY, 0.));
759   text.SetScreenSize(fSize);                      757   text.SetScreenSize(fSize);
760   text.SetLayout(fLayout);                        758   text.SetLayout(fLayout);
761   G4VisAttributes textAtts(G4Colour(0.,1.,1));    759   G4VisAttributes textAtts(G4Colour(0.,1.,1));
762   text.SetVisAttributes(textAtts);                760   text.SetVisAttributes(textAtts);
763   sceneHandler.BeginPrimitives2D();               761   sceneHandler.BeginPrimitives2D();
764   sceneHandler.AddPrimitive(text);                762   sceneHandler.AddPrimitive(text);
765   sceneHandler.EndPrimitives2D();                 763   sceneHandler.EndPrimitives2D();
766 }                                                 764 }
767                                                   765 
768 ////////////// /vis/scene/add/extent /////////    766 ////////////// /vis/scene/add/extent ///////////////////////////////////////
769                                                   767 
770 G4VisCommandSceneAddExtent::G4VisCommandSceneA    768 G4VisCommandSceneAddExtent::G4VisCommandSceneAddExtent () {
771   fpCommand = new G4UIcommand("/vis/scene/add/    769   fpCommand = new G4UIcommand("/vis/scene/add/extent", this);
772   fpCommand -> SetGuidance                        770   fpCommand -> SetGuidance
773   ("Adds a dummy model with given extent to th    771   ("Adds a dummy model with given extent to the current scene."
774    "\nRequires the limits: xmin, xmax, ymin, y    772    "\nRequires the limits: xmin, xmax, ymin, ymax, zmin, zmax unit."
775    "\nThis can be used to provide an extent to    773    "\nThis can be used to provide an extent to the scene even if"
776    "\nno other models with extent are availabl    774    "\nno other models with extent are available. For example,"
777    "\neven if there is no geometry.  In that c    775    "\neven if there is no geometry.  In that case, for example:"
778    "\n  /vis/open OGL"                            776    "\n  /vis/open OGL"
779    "\n  /vis/scene/create"                        777    "\n  /vis/scene/create"
780    "\n  /vis/scene/add/extent -300 300 -300 30    778    "\n  /vis/scene/add/extent -300 300 -300 300 -300 300 cm"
781    "\n  /vis/sceneHandler/attach");               779    "\n  /vis/sceneHandler/attach");
782   G4bool omitable;                                780   G4bool omitable;
783   G4UIparameter* parameter;                       781   G4UIparameter* parameter;
784   parameter = new G4UIparameter ("xmin", 'd',     782   parameter = new G4UIparameter ("xmin", 'd', omitable = true);
785   parameter -> SetDefaultValue (0.);              783   parameter -> SetDefaultValue (0.);
786   fpCommand -> SetParameter (parameter);          784   fpCommand -> SetParameter (parameter);
787   parameter = new G4UIparameter ("xmax", 'd',     785   parameter = new G4UIparameter ("xmax", 'd', omitable = true);
788   parameter -> SetDefaultValue (0.);              786   parameter -> SetDefaultValue (0.);
789   fpCommand -> SetParameter (parameter);          787   fpCommand -> SetParameter (parameter);
790   parameter = new G4UIparameter ("ymin", 'd',     788   parameter = new G4UIparameter ("ymin", 'd', omitable = true);
791   parameter -> SetDefaultValue (0.);              789   parameter -> SetDefaultValue (0.);
792   fpCommand -> SetParameter (parameter);          790   fpCommand -> SetParameter (parameter);
793   parameter = new G4UIparameter ("ymax", 'd',     791   parameter = new G4UIparameter ("ymax", 'd', omitable = true);
794   parameter -> SetDefaultValue (0.);              792   parameter -> SetDefaultValue (0.);
795   fpCommand -> SetParameter (parameter);          793   fpCommand -> SetParameter (parameter);
796   parameter = new G4UIparameter ("zmin", 'd',     794   parameter = new G4UIparameter ("zmin", 'd', omitable = true);
797   parameter -> SetDefaultValue (0.);              795   parameter -> SetDefaultValue (0.);
798   fpCommand -> SetParameter (parameter);          796   fpCommand -> SetParameter (parameter);
799   parameter = new G4UIparameter ("zmax", 'd',     797   parameter = new G4UIparameter ("zmax", 'd', omitable = true);
800   parameter -> SetDefaultValue (0.);              798   parameter -> SetDefaultValue (0.);
801   fpCommand -> SetParameter (parameter);          799   fpCommand -> SetParameter (parameter);
802   parameter =  new G4UIparameter ("unit", 's',    800   parameter =  new G4UIparameter ("unit", 's', omitable = true);
803   parameter -> SetDefaultValue ("m");             801   parameter -> SetDefaultValue ("m");
804   fpCommand -> SetParameter (parameter);          802   fpCommand -> SetParameter (parameter);
805 }                                                 803 }
806                                                   804 
807 G4VisCommandSceneAddExtent::~G4VisCommandScene    805 G4VisCommandSceneAddExtent::~G4VisCommandSceneAddExtent () {
808   delete fpCommand;                               806   delete fpCommand;
809 }                                                 807 }
810                                                   808 
811 G4String G4VisCommandSceneAddExtent::GetCurren    809 G4String G4VisCommandSceneAddExtent::GetCurrentValue (G4UIcommand*) {
812   return "";                                      810   return "";
813 }                                                 811 }
814                                                   812 
815 void G4VisCommandSceneAddExtent::SetNewValue (    813 void G4VisCommandSceneAddExtent::SetNewValue (G4UIcommand*, G4String newValue)
816 {                                                 814 {
817   G4VisManager::Verbosity verbosity = fpVisMan    815   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
818   G4bool warn(verbosity >= G4VisManager::warni    816   G4bool warn(verbosity >= G4VisManager::warnings);
819                                                   817 
820   G4Scene* pScene = fpVisManager->GetCurrentSc    818   G4Scene* pScene = fpVisManager->GetCurrentScene();
821   if (!pScene) {                                  819   if (!pScene) {
822     if (verbosity >= G4VisManager::errors) {      820     if (verbosity >= G4VisManager::errors) {
823       G4warn << "ERROR: No current scene.  Ple << 821       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
824     }                                             822     }
825     return;                                       823     return;
826   }                                               824   }
827                                                   825 
828   G4double xmin, xmax, ymin, ymax, zmin, zmax;    826   G4double xmin, xmax, ymin, ymax, zmin, zmax;
829   G4String unitString;                            827   G4String unitString;
830   std::istringstream is(newValue);                828   std::istringstream is(newValue);
831   is >> xmin >> xmax >> ymin >> ymax >> zmin >    829   is >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax >> unitString;
832   G4double unit = G4UIcommand::ValueOf(unitStr    830   G4double unit = G4UIcommand::ValueOf(unitString);
833   xmin *= unit; xmax *= unit;                     831   xmin *= unit; xmax *= unit;
834   ymin *= unit; ymax *= unit;                     832   ymin *= unit; ymax *= unit;
835   zmin *= unit; zmax *= unit;                     833   zmin *= unit; zmax *= unit;
836                                                   834 
837   G4VisExtent visExtent(xmin, xmax, ymin, ymax    835   G4VisExtent visExtent(xmin, xmax, ymin, ymax, zmin, zmax);
838   Extent* extent = new Extent(xmin, xmax, ymin    836   Extent* extent = new Extent(xmin, xmax, ymin, ymax, zmin, zmax);
839   G4VModel* model =                               837   G4VModel* model =
840   new G4CallbackModel<G4VisCommandSceneAddExte    838   new G4CallbackModel<G4VisCommandSceneAddExtent::Extent>(extent);
841   model->SetType("Extent");                       839   model->SetType("Extent");
842   model->SetGlobalTag("Extent");                  840   model->SetGlobalTag("Extent");
843   model->SetGlobalDescription("Extent: " + new    841   model->SetGlobalDescription("Extent: " + newValue);
844   model->SetExtent(visExtent);                    842   model->SetExtent(visExtent);
845   const G4String& currentSceneName = pScene ->    843   const G4String& currentSceneName = pScene -> GetName ();
846   G4bool successful = pScene -> AddRunDuration    844   G4bool successful = pScene -> AddRunDurationModel (model, warn);
847   if (successful) {                               845   if (successful) {
848     if (verbosity >= G4VisManager::confirmatio    846     if (verbosity >= G4VisManager::confirmations) {
849       G4cout << "A benign model with extent "     847       G4cout << "A benign model with extent "
850       << visExtent                                848       << visExtent
851       << " has been added to scene \""            849       << " has been added to scene \""
852        << currentSceneName << "\"."               850        << currentSceneName << "\"."
853        << G4endl;                                 851        << G4endl;
854     }                                             852     }
855   }                                               853   }
856   else G4VisCommandsSceneAddUnsuccessful(verbo    854   else G4VisCommandsSceneAddUnsuccessful(verbosity);
857                                                   855 
858   CheckSceneAndNotifyHandlers (pScene);           856   CheckSceneAndNotifyHandlers (pScene);
859 }                                                 857 }
860                                                   858 
861 G4VisCommandSceneAddExtent::Extent::Extent        859 G4VisCommandSceneAddExtent::Extent::Extent
862 (G4double xmin, G4double xmax,                    860 (G4double xmin, G4double xmax,
863  G4double ymin, G4double ymax,                    861  G4double ymin, G4double ymax,
864  G4double zmin, G4double zmax):                   862  G4double zmin, G4double zmax):
865 fExtent(xmin,xmax,ymin,ymax,zmin,zmax)            863 fExtent(xmin,xmax,ymin,ymax,zmin,zmax)
866 {}                                                864 {}
867                                                   865 
868 void G4VisCommandSceneAddExtent::Extent::opera    866 void G4VisCommandSceneAddExtent::Extent::operator()
869 (G4VGraphicsScene&, const G4ModelingParameters    867 (G4VGraphicsScene&, const G4ModelingParameters*)
870 {}                                                868 {}
871                                                   869 
872 ////////////// /vis/scene/add/frame //////////    870 ////////////// /vis/scene/add/frame ///////////////////////////////////////
873                                                   871 
874 G4VisCommandSceneAddFrame::G4VisCommandSceneAd    872 G4VisCommandSceneAddFrame::G4VisCommandSceneAddFrame () {
875   fpCommand = new G4UIcommand("/vis/scene/add/    873   fpCommand = new G4UIcommand("/vis/scene/add/frame", this);
876   fpCommand -> SetGuidance ("Add frame to curr    874   fpCommand -> SetGuidance ("Add frame to current scene.");
877   G4bool omitable;                                875   G4bool omitable;
878   G4UIparameter* parameter;                       876   G4UIparameter* parameter;
879   parameter = new G4UIparameter ("size", 'd',     877   parameter = new G4UIparameter ("size", 'd', omitable = true);
880   parameter -> SetGuidance ("Size of frame.  1    878   parameter -> SetGuidance ("Size of frame.  1 = full window.");
881   parameter -> SetParameterRange ("size > 0 &&    879   parameter -> SetParameterRange ("size > 0 && size <=1");
882   parameter -> SetDefaultValue (0.97);            880   parameter -> SetDefaultValue (0.97);
883   fpCommand -> SetParameter (parameter);          881   fpCommand -> SetParameter (parameter);
884 }                                                 882 }
885                                                   883 
886 G4VisCommandSceneAddFrame::~G4VisCommandSceneA    884 G4VisCommandSceneAddFrame::~G4VisCommandSceneAddFrame () {
887   delete fpCommand;                               885   delete fpCommand;
888 }                                                 886 }
889                                                   887 
890 G4String G4VisCommandSceneAddFrame::GetCurrent    888 G4String G4VisCommandSceneAddFrame::GetCurrentValue (G4UIcommand*) {
891   return "";                                      889   return "";
892 }                                                 890 }
893                                                   891 
894 void G4VisCommandSceneAddFrame::SetNewValue (G    892 void G4VisCommandSceneAddFrame::SetNewValue (G4UIcommand*, G4String newValue)
895 {                                                 893 {
896   G4VisManager::Verbosity verbosity = fpVisMan    894   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
897   G4bool warn(verbosity >= G4VisManager::warni    895   G4bool warn(verbosity >= G4VisManager::warnings);
898                                                   896 
899   G4Scene* pScene = fpVisManager->GetCurrentSc    897   G4Scene* pScene = fpVisManager->GetCurrentScene();
900   if (!pScene) {                                  898   if (!pScene) {
901     if (verbosity >= G4VisManager::errors) {      899     if (verbosity >= G4VisManager::errors) {
902       G4warn << "ERROR: No current scene.  Ple << 900       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
903     }                                             901     }
904     return;                                       902     return;
905   }                                               903   }
906                                                   904 
907   G4double size;                                  905   G4double size;
908   std::istringstream is(newValue);                906   std::istringstream is(newValue);
909   is >> size;                                     907   is >> size;
910                                                   908 
911   Frame* frame = new Frame(size, fCurrentLineW    909   Frame* frame = new Frame(size, fCurrentLineWidth, fCurrentColour);
912   G4VModel* model =                               910   G4VModel* model =
913     new G4CallbackModel<G4VisCommandSceneAddFr    911     new G4CallbackModel<G4VisCommandSceneAddFrame::Frame>(frame);
914   model->SetType("Frame");                        912   model->SetType("Frame");
915   model->SetGlobalTag("Frame");                   913   model->SetGlobalTag("Frame");
916   model->SetGlobalDescription("Frame: " + newV    914   model->SetGlobalDescription("Frame: " + newValue);
917   const G4String& currentSceneName = pScene ->    915   const G4String& currentSceneName = pScene -> GetName ();
918   G4bool successful = pScene -> AddRunDuration    916   G4bool successful = pScene -> AddRunDurationModel (model, warn);
919   if (successful) {                               917   if (successful) {
920     if (verbosity >= G4VisManager::confirmatio    918     if (verbosity >= G4VisManager::confirmations) {
921       G4cout << "Frame has been added to scene    919       G4cout << "Frame has been added to scene \""
922        << currentSceneName << "\"."               920        << currentSceneName << "\"."
923        << G4endl;                                 921        << G4endl;
924     }                                             922     }
925   }                                               923   }
926   else G4VisCommandsSceneAddUnsuccessful(verbo    924   else G4VisCommandsSceneAddUnsuccessful(verbosity);
927                                                   925 
928   CheckSceneAndNotifyHandlers (pScene);           926   CheckSceneAndNotifyHandlers (pScene);
929 }                                                 927 }
930                                                   928 
931 void G4VisCommandSceneAddFrame::Frame::operato    929 void G4VisCommandSceneAddFrame::Frame::operator()
932   (G4VGraphicsScene& sceneHandler, const G4Mod    930   (G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
933 {                                                 931 {
934   G4Polyline frame;                               932   G4Polyline frame;
935   frame.push_back(G4Point3D( fSize,  fSize, 0.    933   frame.push_back(G4Point3D( fSize,  fSize, 0.));
936   frame.push_back(G4Point3D(-fSize,  fSize, 0.    934   frame.push_back(G4Point3D(-fSize,  fSize, 0.));
937   frame.push_back(G4Point3D(-fSize, -fSize, 0.    935   frame.push_back(G4Point3D(-fSize, -fSize, 0.));
938   frame.push_back(G4Point3D( fSize, -fSize, 0.    936   frame.push_back(G4Point3D( fSize, -fSize, 0.));
939   frame.push_back(G4Point3D( fSize,  fSize, 0.    937   frame.push_back(G4Point3D( fSize,  fSize, 0.));
940   G4VisAttributes va;                             938   G4VisAttributes va;
941   va.SetLineWidth(fWidth);                        939   va.SetLineWidth(fWidth);
942   va.SetColour(fColour);                          940   va.SetColour(fColour);
943   frame.SetVisAttributes(va);                     941   frame.SetVisAttributes(va);
944   sceneHandler.BeginPrimitives2D();               942   sceneHandler.BeginPrimitives2D();
945   sceneHandler.AddPrimitive(frame);               943   sceneHandler.AddPrimitive(frame);
946   sceneHandler.EndPrimitives2D();                 944   sceneHandler.EndPrimitives2D();
947 }                                                 945 }
948                                                   946 
949 ////////////// /vis/scene/add/gps ////////////    947 ////////////// /vis/scene/add/gps ///////////////////////////////////////
950                                                   948 
951 G4VisCommandSceneAddGPS::G4VisCommandSceneAddG    949 G4VisCommandSceneAddGPS::G4VisCommandSceneAddGPS () {
952   G4bool omitable;                                950   G4bool omitable;
953   G4UIparameter* parameter;                       951   G4UIparameter* parameter;
954   fpCommand = new G4UIcommand ("/vis/scene/add    952   fpCommand = new G4UIcommand ("/vis/scene/add/gps", this);
955   fpCommand -> SetGuidance                        953   fpCommand -> SetGuidance
956   ("A representation of the source(s) of the G    954   ("A representation of the source(s) of the General Particle Source"
957    "\nwill be added to current scene and drawn    955    "\nwill be added to current scene and drawn, if applicable.");
958   fpCommand->SetGuidance(ConvertToColourGuidan    956   fpCommand->SetGuidance(ConvertToColourGuidance());
959   fpCommand->SetGuidance("Default: red and tra    957   fpCommand->SetGuidance("Default: red and transparent.");
960   parameter = new G4UIparameter("red_or_string    958   parameter = new G4UIparameter("red_or_string", 's', omitable = true);
961   parameter -> SetDefaultValue ("1.");            959   parameter -> SetDefaultValue ("1.");
962   fpCommand -> SetParameter (parameter);          960   fpCommand -> SetParameter (parameter);
963   parameter = new G4UIparameter("green", 'd',     961   parameter = new G4UIparameter("green", 'd', omitable = true);
964   parameter -> SetDefaultValue (0.);              962   parameter -> SetDefaultValue (0.);
965   fpCommand -> SetParameter (parameter);          963   fpCommand -> SetParameter (parameter);
966   parameter = new G4UIparameter ("blue", 'd',     964   parameter = new G4UIparameter ("blue", 'd', omitable = true);
967   parameter -> SetDefaultValue (0.);              965   parameter -> SetDefaultValue (0.);
968   fpCommand -> SetParameter (parameter);          966   fpCommand -> SetParameter (parameter);
969   parameter = new G4UIparameter ("opacity", 'd    967   parameter = new G4UIparameter ("opacity", 'd', omitable = true);
970   parameter -> SetDefaultValue (0.3);             968   parameter -> SetDefaultValue (0.3);
971   fpCommand -> SetParameter (parameter);          969   fpCommand -> SetParameter (parameter);
972 }                                                 970 }
973                                                   971 
974 G4VisCommandSceneAddGPS::~G4VisCommandSceneAdd    972 G4VisCommandSceneAddGPS::~G4VisCommandSceneAddGPS () {
975   delete fpCommand;                               973   delete fpCommand;
976 }                                                 974 }
977                                                   975 
978 G4String G4VisCommandSceneAddGPS::GetCurrentVa    976 G4String G4VisCommandSceneAddGPS::GetCurrentValue (G4UIcommand*) {
979   return "";                                      977   return "";
980 }                                                 978 }
981                                                   979 
982 void G4VisCommandSceneAddGPS::SetNewValue (G4U    980 void G4VisCommandSceneAddGPS::SetNewValue (G4UIcommand*, G4String newValue) {
983                                                   981 
984   G4VisManager::Verbosity verbosity = fpVisMan    982   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
985   G4bool warn(verbosity >= G4VisManager::warni    983   G4bool warn(verbosity >= G4VisManager::warnings);
986                                                   984 
987   G4Scene* pScene = fpVisManager->GetCurrentSc    985   G4Scene* pScene = fpVisManager->GetCurrentScene();
988   if (!pScene) {                                  986   if (!pScene) {
989     if (verbosity >= G4VisManager::errors) {      987     if (verbosity >= G4VisManager::errors) {
990       G4warn << "ERROR: No current scene.  Ple << 988       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
991     }                                             989     }
992     return;                                       990     return;
993   }                                               991   }
994                                                   992 
995   G4String redOrString;                           993   G4String redOrString;
996   G4double green, blue, opacity;                  994   G4double green, blue, opacity;
997   std::istringstream iss(newValue);               995   std::istringstream iss(newValue);
998   iss >> redOrString >> green >> blue >> opaci    996   iss >> redOrString >> green >> blue >> opacity;
999   G4Colour colour(1.,0.,0.,0.3);  // Default r    997   G4Colour colour(1.,0.,0.,0.3);  // Default red and transparent.
1000   ConvertToColour(colour, redOrString, green,    998   ConvertToColour(colour, redOrString, green, blue, opacity);
1001                                                  999 
1002   G4VModel* model = new G4GPSModel(colour);      1000   G4VModel* model = new G4GPSModel(colour);
1003   const G4String& currentSceneName = pScene -    1001   const G4String& currentSceneName = pScene -> GetName ();
1004   G4bool successful = pScene -> AddRunDuratio    1002   G4bool successful = pScene -> AddRunDurationModel (model, warn);
1005   if (successful) {                              1003   if (successful) {
1006     if (verbosity >= G4VisManager::confirmati    1004     if (verbosity >= G4VisManager::confirmations) {
1007       G4cout <<                                  1005       G4cout <<
1008       "A representation of the source(s) of t    1006       "A representation of the source(s) of the General Particle Source will be drawn"
1009       "\n  in colour " << colour << " for sce    1007       "\n  in colour " << colour << " for scene \""
1010       << currentSceneName << "\" if applicabl    1008       << currentSceneName << "\" if applicable."
1011       << G4endl;                                 1009       << G4endl;
1012     }                                            1010     }
1013   }                                              1011   }
1014   else G4VisCommandsSceneAddUnsuccessful(verb    1012   else G4VisCommandsSceneAddUnsuccessful(verbosity);
1015                                                  1013 
1016   CheckSceneAndNotifyHandlers (pScene);          1014   CheckSceneAndNotifyHandlers (pScene);
1017 }                                                1015 }
1018                                                  1016   
1019 ////////////// /vis/scene/add/hits //////////    1017 ////////////// /vis/scene/add/hits ///////////////////////////////////////
1020                                                  1018 
1021 G4VisCommandSceneAddHits::G4VisCommandSceneAd    1019 G4VisCommandSceneAddHits::G4VisCommandSceneAddHits () {
1022   fpCommand = new G4UIcmdWithoutParameter ("/    1020   fpCommand = new G4UIcmdWithoutParameter ("/vis/scene/add/hits", this);
1023   fpCommand -> SetGuidance ("Adds hits to cur    1021   fpCommand -> SetGuidance ("Adds hits to current scene.");
1024   fpCommand -> SetGuidance                       1022   fpCommand -> SetGuidance
1025     ("Hits are drawn at end of event when the    1023     ("Hits are drawn at end of event when the scene in which"
1026      "\nthey are added is current.");            1024      "\nthey are added is current.");
1027 }                                                1025 }
1028                                                  1026 
1029 G4VisCommandSceneAddHits::~G4VisCommandSceneA    1027 G4VisCommandSceneAddHits::~G4VisCommandSceneAddHits () {
1030   delete fpCommand;                              1028   delete fpCommand;
1031 }                                                1029 }
1032                                                  1030 
1033 G4String G4VisCommandSceneAddHits::GetCurrent    1031 G4String G4VisCommandSceneAddHits::GetCurrentValue (G4UIcommand*) {
1034   return "";                                     1032   return "";
1035 }                                                1033 }
1036                                                  1034 
1037 void G4VisCommandSceneAddHits::SetNewValue (G    1035 void G4VisCommandSceneAddHits::SetNewValue (G4UIcommand*, G4String) {
1038                                                  1036 
1039   G4VisManager::Verbosity verbosity = fpVisMa    1037   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1040   G4bool warn(verbosity >= G4VisManager::warn    1038   G4bool warn(verbosity >= G4VisManager::warnings);
1041                                                  1039 
1042   G4Scene* pScene = fpVisManager->GetCurrentS    1040   G4Scene* pScene = fpVisManager->GetCurrentScene();
1043   if (!pScene) {                                 1041   if (!pScene) {
1044     if (verbosity >= G4VisManager::errors) {     1042     if (verbosity >= G4VisManager::errors) {
1045       G4warn << "ERROR: No current scene.  Pl << 1043       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
1046     }                                            1044     }
1047     return;                                      1045     return;
1048   }                                              1046   }
1049                                                  1047 
1050   G4VModel* model = new G4HitsModel;             1048   G4VModel* model = new G4HitsModel;
1051   const G4String& currentSceneName = pScene -    1049   const G4String& currentSceneName = pScene -> GetName ();
1052   G4bool successful = pScene -> AddEndOfEvent    1050   G4bool successful = pScene -> AddEndOfEventModel (model, warn);
1053   if (successful) {                              1051   if (successful) {
1054     if (verbosity >= G4VisManager::confirmati    1052     if (verbosity >= G4VisManager::confirmations) {
1055       G4cout << "Hits, if any, will be drawn     1053       G4cout << "Hits, if any, will be drawn at end of run in scene \""
1056        << currentSceneName << "\"."              1054        << currentSceneName << "\"."
1057        << G4endl;                                1055        << G4endl;
1058     }                                            1056     }
1059   }                                              1057   }
1060   else G4VisCommandsSceneAddUnsuccessful(verb    1058   else G4VisCommandsSceneAddUnsuccessful(verbosity);
1061                                                  1059 
1062   CheckSceneAndNotifyHandlers (pScene);          1060   CheckSceneAndNotifyHandlers (pScene);
1063 }                                                1061 }
1064                                                  1062 
1065 ////////////// /vis/scene/add/line //////////    1063 ////////////// /vis/scene/add/line ///////////////////////////////////////
1066                                                  1064 
1067 G4VisCommandSceneAddLine::G4VisCommandSceneAd    1065 G4VisCommandSceneAddLine::G4VisCommandSceneAddLine () {
1068   fpCommand = new G4UIcommand("/vis/scene/add    1066   fpCommand = new G4UIcommand("/vis/scene/add/line", this);
1069   fpCommand -> SetGuidance ("Adds line to cur    1067   fpCommand -> SetGuidance ("Adds line to current scene.");
1070   G4bool omitable;                               1068   G4bool omitable;
1071   G4UIparameter* parameter;                      1069   G4UIparameter* parameter;
1072   parameter = new G4UIparameter ("x1", 'd', o    1070   parameter = new G4UIparameter ("x1", 'd', omitable = false);
1073   fpCommand -> SetParameter (parameter);         1071   fpCommand -> SetParameter (parameter);
1074   parameter = new G4UIparameter ("y1", 'd', o    1072   parameter = new G4UIparameter ("y1", 'd', omitable = false);
1075   fpCommand -> SetParameter (parameter);         1073   fpCommand -> SetParameter (parameter);
1076   parameter = new G4UIparameter ("z1", 'd', o    1074   parameter = new G4UIparameter ("z1", 'd', omitable = false);
1077   fpCommand -> SetParameter (parameter);         1075   fpCommand -> SetParameter (parameter);
1078   parameter = new G4UIparameter ("x2", 'd', o    1076   parameter = new G4UIparameter ("x2", 'd', omitable = false);
1079   fpCommand -> SetParameter (parameter);         1077   fpCommand -> SetParameter (parameter);
1080   parameter = new G4UIparameter ("y2", 'd', o    1078   parameter = new G4UIparameter ("y2", 'd', omitable = false);
1081   fpCommand -> SetParameter (parameter);         1079   fpCommand -> SetParameter (parameter);
1082   parameter = new G4UIparameter ("z2", 'd', o    1080   parameter = new G4UIparameter ("z2", 'd', omitable = false);
1083   fpCommand -> SetParameter (parameter);         1081   fpCommand -> SetParameter (parameter);
1084   parameter =  new G4UIparameter ("unit", 's'    1082   parameter =  new G4UIparameter ("unit", 's', omitable = true);
1085   parameter->SetDefaultValue ("m");              1083   parameter->SetDefaultValue ("m");
1086   fpCommand->SetParameter    (parameter);        1084   fpCommand->SetParameter    (parameter);
1087 }                                                1085 }
1088                                                  1086 
1089 G4VisCommandSceneAddLine::~G4VisCommandSceneA    1087 G4VisCommandSceneAddLine::~G4VisCommandSceneAddLine () {
1090   delete fpCommand;                              1088   delete fpCommand;
1091 }                                                1089 }
1092                                                  1090 
1093 G4String G4VisCommandSceneAddLine::GetCurrent    1091 G4String G4VisCommandSceneAddLine::GetCurrentValue (G4UIcommand*) {
1094   return "";                                     1092   return "";
1095 }                                                1093 }
1096                                                  1094 
1097 void G4VisCommandSceneAddLine::SetNewValue (G    1095 void G4VisCommandSceneAddLine::SetNewValue (G4UIcommand*, G4String newValue)
1098 {                                                1096 {
1099   G4VisManager::Verbosity verbosity = fpVisMa    1097   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1100   G4bool warn(verbosity >= G4VisManager::warn    1098   G4bool warn(verbosity >= G4VisManager::warnings);
1101                                                  1099 
1102   G4Scene* pScene = fpVisManager->GetCurrentS    1100   G4Scene* pScene = fpVisManager->GetCurrentScene();
1103   if (!pScene) {                                 1101   if (!pScene) {
1104     if (verbosity >= G4VisManager::errors) {     1102     if (verbosity >= G4VisManager::errors) {
1105       G4warn << "ERROR: No current scene.  Pl << 1103       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
1106     }                                            1104     }
1107     return;                                      1105     return;
1108   }                                              1106   }
1109                                                  1107 
1110   G4String unitString;                           1108   G4String unitString;
1111   G4double x1, y1, z1, x2, y2, z2;               1109   G4double x1, y1, z1, x2, y2, z2;
1112   std::istringstream is(newValue);               1110   std::istringstream is(newValue);
1113   is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> u    1111   is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> unitString;
1114   G4double unit = G4UIcommand::ValueOf(unitSt    1112   G4double unit = G4UIcommand::ValueOf(unitString);
1115   x1 *= unit; y1 *= unit; z1 *= unit;            1113   x1 *= unit; y1 *= unit; z1 *= unit;
1116   x2 *= unit; y2 *= unit; z2 *= unit;            1114   x2 *= unit; y2 *= unit; z2 *= unit;
1117                                                  1115 
1118   Line* line = new Line(x1, y1, z1, x2, y2, z    1116   Line* line = new Line(x1, y1, z1, x2, y2, z2,
1119       fCurrentLineWidth, fCurrentColour);        1117       fCurrentLineWidth, fCurrentColour);
1120   G4VModel* model =                              1118   G4VModel* model =
1121     new G4CallbackModel<G4VisCommandSceneAddL    1119     new G4CallbackModel<G4VisCommandSceneAddLine::Line>(line);
1122   model->SetType("Line");                        1120   model->SetType("Line");
1123   model->SetGlobalTag("Line");                   1121   model->SetGlobalTag("Line");
1124   model->SetGlobalDescription("Line: " + newV    1122   model->SetGlobalDescription("Line: " + newValue);
1125   const G4String& currentSceneName = pScene -    1123   const G4String& currentSceneName = pScene -> GetName ();
1126   G4bool successful = pScene -> AddRunDuratio    1124   G4bool successful = pScene -> AddRunDurationModel (model, warn);
1127   if (successful) {                              1125   if (successful) {
1128     if (verbosity >= G4VisManager::confirmati    1126     if (verbosity >= G4VisManager::confirmations) {
1129       G4cout << "Line has been added to scene    1127       G4cout << "Line has been added to scene \""
1130        << currentSceneName << "\"."              1128        << currentSceneName << "\"."
1131        << G4endl;                                1129        << G4endl;
1132     }                                            1130     }
1133   }                                              1131   }
1134   else G4VisCommandsSceneAddUnsuccessful(verb    1132   else G4VisCommandsSceneAddUnsuccessful(verbosity);
1135                                                  1133 
1136   CheckSceneAndNotifyHandlers (pScene);          1134   CheckSceneAndNotifyHandlers (pScene);
1137 }                                                1135 }
1138                                                  1136 
1139 G4VisCommandSceneAddLine::Line::Line             1137 G4VisCommandSceneAddLine::Line::Line
1140 (G4double x1, G4double y1, G4double z1,          1138 (G4double x1, G4double y1, G4double z1,
1141  G4double x2, G4double y2, G4double z2,          1139  G4double x2, G4double y2, G4double z2,
1142  G4double width, const G4Colour& colour):        1140  G4double width, const G4Colour& colour):
1143   fWidth(width), fColour(colour)                 1141   fWidth(width), fColour(colour)
1144 {                                                1142 {
1145   fPolyline.push_back(G4Point3D(x1,y1,z1));      1143   fPolyline.push_back(G4Point3D(x1,y1,z1));
1146   fPolyline.push_back(G4Point3D(x2,y2,z2));      1144   fPolyline.push_back(G4Point3D(x2,y2,z2));
1147   G4VisAttributes va;                            1145   G4VisAttributes va;
1148   va.SetLineWidth(fWidth);                       1146   va.SetLineWidth(fWidth);
1149   va.SetColour(fColour);                         1147   va.SetColour(fColour);
1150   fPolyline.SetVisAttributes(va);                1148   fPolyline.SetVisAttributes(va);
1151 }                                                1149 }
1152                                                  1150 
1153 void G4VisCommandSceneAddLine::Line::operator    1151 void G4VisCommandSceneAddLine::Line::operator()
1154   (G4VGraphicsScene& sceneHandler, const G4Mo    1152   (G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
1155 {                                                1153 {
1156   sceneHandler.BeginPrimitives();                1154   sceneHandler.BeginPrimitives();
1157   sceneHandler.AddPrimitive(fPolyline);          1155   sceneHandler.AddPrimitive(fPolyline);
1158   sceneHandler.EndPrimitives();                  1156   sceneHandler.EndPrimitives();
1159 }                                                1157 }
1160                                                  1158 
1161 ////////////// /vis/scene/add/line2D ////////    1159 ////////////// /vis/scene/add/line2D ///////////////////////////////////////
1162                                                  1160 
1163 G4VisCommandSceneAddLine2D::G4VisCommandScene    1161 G4VisCommandSceneAddLine2D::G4VisCommandSceneAddLine2D () {
1164   fpCommand = new G4UIcommand("/vis/scene/add    1162   fpCommand = new G4UIcommand("/vis/scene/add/line2D", this);
1165   fpCommand -> SetGuidance ("Adds 2D line to     1163   fpCommand -> SetGuidance ("Adds 2D line to current scene.");
1166   fpCommand -> SetGuidance ("x,y in range [-1 << 
1167   G4bool omitable;                               1164   G4bool omitable;
1168   G4UIparameter* parameter;                      1165   G4UIparameter* parameter;
1169   parameter = new G4UIparameter ("x1", 'd', o    1166   parameter = new G4UIparameter ("x1", 'd', omitable = false);
1170   fpCommand -> SetParameter (parameter);         1167   fpCommand -> SetParameter (parameter);
1171   parameter = new G4UIparameter ("y1", 'd', o    1168   parameter = new G4UIparameter ("y1", 'd', omitable = false);
1172   fpCommand -> SetParameter (parameter);         1169   fpCommand -> SetParameter (parameter);
1173   parameter = new G4UIparameter ("x2", 'd', o    1170   parameter = new G4UIparameter ("x2", 'd', omitable = false);
1174   fpCommand -> SetParameter (parameter);         1171   fpCommand -> SetParameter (parameter);
1175   parameter = new G4UIparameter ("y2", 'd', o    1172   parameter = new G4UIparameter ("y2", 'd', omitable = false);
1176   fpCommand -> SetParameter (parameter);         1173   fpCommand -> SetParameter (parameter);
1177 }                                                1174 }
1178                                                  1175 
1179 G4VisCommandSceneAddLine2D::~G4VisCommandScen    1176 G4VisCommandSceneAddLine2D::~G4VisCommandSceneAddLine2D () {
1180   delete fpCommand;                              1177   delete fpCommand;
1181 }                                                1178 }
1182                                                  1179 
1183 G4String G4VisCommandSceneAddLine2D::GetCurre    1180 G4String G4VisCommandSceneAddLine2D::GetCurrentValue (G4UIcommand*) {
1184   return "";                                     1181   return "";
1185 }                                                1182 }
1186                                                  1183 
1187 void G4VisCommandSceneAddLine2D::SetNewValue     1184 void G4VisCommandSceneAddLine2D::SetNewValue (G4UIcommand*, G4String newValue)
1188 {                                                1185 {
1189   G4VisManager::Verbosity verbosity = fpVisMa    1186   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1190   G4bool warn(verbosity >= G4VisManager::warn    1187   G4bool warn(verbosity >= G4VisManager::warnings);
1191                                                  1188 
1192   G4Scene* pScene = fpVisManager->GetCurrentS    1189   G4Scene* pScene = fpVisManager->GetCurrentScene();
1193   if (!pScene) {                                 1190   if (!pScene) {
1194     if (verbosity >= G4VisManager::errors) {     1191     if (verbosity >= G4VisManager::errors) {
1195       G4warn << "ERROR: No current scene.  Pl << 1192       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
1196     }                                            1193     }
1197     return;                                      1194     return;
1198   }                                              1195   }
1199                                                  1196 
1200   G4double x1, y1, x2, y2;                       1197   G4double x1, y1, x2, y2;
1201   std::istringstream is(newValue);               1198   std::istringstream is(newValue);
1202   is >> x1 >> y1 >> x2 >> y2;                    1199   is >> x1 >> y1 >> x2 >> y2;
1203                                                  1200 
1204   Line2D* line2D = new Line2D                    1201   Line2D* line2D = new Line2D
1205     (x1, y1, x2, y2, fCurrentLineWidth, fCurr    1202     (x1, y1, x2, y2, fCurrentLineWidth, fCurrentColour);
1206   G4VModel* model =                              1203   G4VModel* model =
1207     new G4CallbackModel<G4VisCommandSceneAddL    1204     new G4CallbackModel<G4VisCommandSceneAddLine2D::Line2D>(line2D);
1208   model->SetType("Line2D");                      1205   model->SetType("Line2D");
1209   model->SetGlobalTag("Line2D");                 1206   model->SetGlobalTag("Line2D");
1210   model->SetGlobalDescription("Line2D: " + ne    1207   model->SetGlobalDescription("Line2D: " + newValue);
1211   const G4String& currentSceneName = pScene -    1208   const G4String& currentSceneName = pScene -> GetName ();
1212   G4bool successful = pScene -> AddRunDuratio    1209   G4bool successful = pScene -> AddRunDurationModel (model, warn);
1213   if (successful) {                              1210   if (successful) {
1214     if (verbosity >= G4VisManager::confirmati    1211     if (verbosity >= G4VisManager::confirmations) {
1215       G4cout << "A 2D line has been added to     1212       G4cout << "A 2D line has been added to scene \""
1216        << currentSceneName << "\"."              1213        << currentSceneName << "\"."
1217        << G4endl;                                1214        << G4endl;
1218     }                                            1215     }
1219   }                                              1216   }
1220   else G4VisCommandsSceneAddUnsuccessful(verb    1217   else G4VisCommandsSceneAddUnsuccessful(verbosity);
1221                                                  1218 
1222   CheckSceneAndNotifyHandlers (pScene);          1219   CheckSceneAndNotifyHandlers (pScene);
1223 }                                                1220 }
1224                                                  1221 
1225 G4VisCommandSceneAddLine2D::Line2D::Line2D       1222 G4VisCommandSceneAddLine2D::Line2D::Line2D
1226 (G4double x1, G4double y1,                       1223 (G4double x1, G4double y1,
1227  G4double x2, G4double y2,                       1224  G4double x2, G4double y2,
1228  G4double width, const G4Colour& colour):        1225  G4double width, const G4Colour& colour):
1229   fWidth(width), fColour(colour)                 1226   fWidth(width), fColour(colour)
1230 {                                                1227 {
1231   fPolyline.push_back(G4Point3D(x1,y1,0));       1228   fPolyline.push_back(G4Point3D(x1,y1,0));
1232   fPolyline.push_back(G4Point3D(x2,y2,0));       1229   fPolyline.push_back(G4Point3D(x2,y2,0));
1233   G4VisAttributes va;                            1230   G4VisAttributes va;
1234   va.SetLineWidth(fWidth);                       1231   va.SetLineWidth(fWidth);
1235   va.SetColour(fColour);                         1232   va.SetColour(fColour);
1236   fPolyline.SetVisAttributes(va);                1233   fPolyline.SetVisAttributes(va);
1237 }                                                1234 }
1238                                                  1235 
1239 void G4VisCommandSceneAddLine2D::Line2D::oper    1236 void G4VisCommandSceneAddLine2D::Line2D::operator()
1240   (G4VGraphicsScene& sceneHandler, const G4Mo    1237   (G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
1241 {                                                1238 {
1242   sceneHandler.BeginPrimitives2D();              1239   sceneHandler.BeginPrimitives2D();
1243   sceneHandler.AddPrimitive(fPolyline);          1240   sceneHandler.AddPrimitive(fPolyline);
1244   sceneHandler.EndPrimitives2D();                1241   sceneHandler.EndPrimitives2D();
1245 }                                                1242 }
1246                                                  1243 
1247 ////////////// /vis/scene/add/localAxes /////    1244 ////////////// /vis/scene/add/localAxes ///////////////////////////////////////
1248                                                  1245 
1249 G4VisCommandSceneAddLocalAxes::G4VisCommandSc    1246 G4VisCommandSceneAddLocalAxes::G4VisCommandSceneAddLocalAxes () {
1250   G4bool omitable;                               1247   G4bool omitable;
1251   fpCommand = new G4UIcommand ("/vis/scene/ad    1248   fpCommand = new G4UIcommand ("/vis/scene/add/localAxes", this);
1252   fpCommand -> SetGuidance                       1249   fpCommand -> SetGuidance
1253   ("Adds local axes to physical volume(s).");    1250   ("Adds local axes to physical volume(s).");
1254   G4UIparameter* parameter;                      1251   G4UIparameter* parameter;
1255   parameter = new G4UIparameter ("physical-vo    1252   parameter = new G4UIparameter ("physical-volume-name", 's', omitable = false);
1256   fpCommand -> SetParameter (parameter);         1253   fpCommand -> SetParameter (parameter);
1257   parameter = new G4UIparameter ("copy-no", '    1254   parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
1258   parameter -> SetGuidance ("If negative, mat    1255   parameter -> SetGuidance ("If negative, matches any copy no.");
1259   parameter -> SetDefaultValue (-1);             1256   parameter -> SetDefaultValue (-1);
1260   fpCommand -> SetParameter (parameter);         1257   fpCommand -> SetParameter (parameter);
1261 }                                                1258 }
1262                                                  1259 
1263 G4VisCommandSceneAddLocalAxes::~G4VisCommandS    1260 G4VisCommandSceneAddLocalAxes::~G4VisCommandSceneAddLocalAxes () {
1264   delete fpCommand;                              1261   delete fpCommand;
1265 }                                                1262 }
1266                                                  1263 
1267 G4String G4VisCommandSceneAddLocalAxes::GetCu    1264 G4String G4VisCommandSceneAddLocalAxes::GetCurrentValue (G4UIcommand*) {
1268   return "world 0 -1";                           1265   return "world 0 -1";
1269 }                                                1266 }
1270                                                  1267 
1271 void G4VisCommandSceneAddLocalAxes::SetNewVal    1268 void G4VisCommandSceneAddLocalAxes::SetNewValue (G4UIcommand*,
1272              G4String newValue) {                1269              G4String newValue) {
1273                                                  1270 
1274   G4VisManager::Verbosity verbosity = fpVisMa    1271   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1275   G4bool warn = verbosity >= G4VisManager::wa    1272   G4bool warn = verbosity >= G4VisManager::warnings;
1276                                                  1273 
1277   G4Scene* pScene = fpVisManager->GetCurrentS    1274   G4Scene* pScene = fpVisManager->GetCurrentScene();
1278   if (!pScene) {                                 1275   if (!pScene) {
1279     if (verbosity >= G4VisManager::errors) {     1276     if (verbosity >= G4VisManager::errors) {
1280       G4warn << "ERROR: No current scene.  Pl << 1277       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
1281     }                                            1278     }
1282     return;                                      1279     return;
1283   }                                              1280   }
1284                                                  1281 
1285   G4String name;                                 1282   G4String name;
1286   G4int copyNo;                                  1283   G4int copyNo;
1287   std::istringstream is (newValue);              1284   std::istringstream is (newValue);
1288   is >> name >> copyNo;                          1285   is >> name >> copyNo;
1289                                                  1286 
1290   std::vector<G4PhysicalVolumesSearchScene::F    1287   std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
1291                                                  1288 
1292   // Search all worlds...                        1289   // Search all worlds...
1293   G4TransportationManager* transportationMana    1290   G4TransportationManager* transportationManager =
1294   G4TransportationManager::GetTransportationM    1291   G4TransportationManager::GetTransportationManager ();
1295   std::vector<G4VPhysicalVolume*>::iterator i    1292   std::vector<G4VPhysicalVolume*>::iterator iterWorld =
1296   transportationManager->GetWorldsIterator();    1293   transportationManager->GetWorldsIterator();
1297   size_t nWorlds = transportationManager->Get    1294   size_t nWorlds = transportationManager->GetNoWorlds();
1298   for (size_t i = 0; i < nWorlds; ++i, ++iter    1295   for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
1299     G4ModelingParameters mp;  // Default - no    1296     G4ModelingParameters mp;  // Default - no culling.
1300     G4PhysicalVolumeModel searchModel            1297     G4PhysicalVolumeModel searchModel
1301     (*iterWorld,                                 1298     (*iterWorld,
1302      G4PhysicalVolumeModel::UNLIMITED,           1299      G4PhysicalVolumeModel::UNLIMITED,
1303      G4Transform3D(),                            1300      G4Transform3D(),
1304      &mp,                                        1301      &mp,
1305      true);  // Use full extent (avoids initi    1302      true);  // Use full extent (avoids initial descent of geometry tree)
1306     G4PhysicalVolumesSearchScene searchScene     1303     G4PhysicalVolumesSearchScene searchScene
1307     (&searchModel, name, copyNo);                1304     (&searchModel, name, copyNo);
1308     searchModel.DescribeYourselfTo (searchSce    1305     searchModel.DescribeYourselfTo (searchScene);  // Initiate search.
1309     for (const auto& findings: searchScene.Ge    1306     for (const auto& findings: searchScene.GetFindings()) {
1310       findingsVector.push_back(findings);        1307       findingsVector.push_back(findings);
1311     }                                            1308     }
1312   }                                              1309   }
1313                                                  1310 
1314   G4int id = 0;  // To distinguish axes model    1311   G4int id = 0;  // To distinguish axes models by their global description
1315   for (const auto& findings: findingsVector)     1312   for (const auto& findings: findingsVector) {
1316                                                  1313 
1317     // Create axes model based on size and tr    1314     // Create axes model based on size and transformation of found volume(s).
1318     const auto& extent = findings.fpFoundPV->    1315     const auto& extent = findings.fpFoundPV->GetLogicalVolume()->GetSolid()->GetExtent();
1319     const auto& transform = findings.fFoundOb    1316     const auto& transform = findings.fFoundObjectTransformation;
1320                                                  1317 
1321     const G4double lengthMax = extent.GetExte    1318     const G4double lengthMax = extent.GetExtentRadius()/2.;
1322     const G4double intLog10LengthMax = std::f    1319     const G4double intLog10LengthMax = std::floor(std::log10(lengthMax));
1323     G4double length = std::pow(10,intLog10Len    1320     G4double length = std::pow(10,intLog10LengthMax);
1324     if (5.*length < lengthMax) length *= 5.;     1321     if (5.*length < lengthMax) length *= 5.;
1325     else if (2.*length < lengthMax) length *=    1322     else if (2.*length < lengthMax) length *= 2.;
1326                                                  1323 
1327     const auto& axesModel = new G4AxesModel(0    1324     const auto& axesModel = new G4AxesModel(0.,0.,0.,length,transform);
1328     axesModel->SetGlobalTag("LocalAxesModel")    1325     axesModel->SetGlobalTag("LocalAxesModel");
1329     std::ostringstream oss; oss                  1326     std::ostringstream oss; oss
1330     << "Local Axes for " << findings.fpFoundP    1327     << "Local Axes for " << findings.fpFoundPV->GetName()
1331     << ':' << findings.fFoundPVCopyNo << ':'     1328     << ':' << findings.fFoundPVCopyNo << ':' << id++;
1332     axesModel->SetGlobalDescription(oss.str()    1329     axesModel->SetGlobalDescription(oss.str());
1333     // ...so add it to the scene.                1330     // ...so add it to the scene.
1334     G4bool successful = pScene->AddRunDuratio    1331     G4bool successful = pScene->AddRunDurationModel(axesModel,warn);
1335     if (successful) {                            1332     if (successful) {
1336       if (verbosity >= G4VisManager::confirma    1333       if (verbosity >= G4VisManager::confirmations) {
1337   G4cout << "\"" << findings.fpFoundPV->GetNa    1334   G4cout << "\"" << findings.fpFoundPV->GetName()
1338   << "\", copy no. " << findings.fFoundPVCopy    1335   << "\", copy no. " << findings.fFoundPVCopyNo
1339   << ",\n  found in searched volume \""          1336   << ",\n  found in searched volume \""
1340   << findings.fpSearchPV->GetName()              1337   << findings.fpSearchPV->GetName()
1341   << "\" at depth " << findings.fFoundDepth      1338   << "\" at depth " << findings.fFoundDepth
1342   << ",\n  base path: \"" << findings.fFoundB    1339   << ",\n  base path: \"" << findings.fFoundBasePVPath
1343   << "\".\n  Local axes have been added to sc    1340   << "\".\n  Local axes have been added to scene \""
1344   << pScene->GetName() << "\".";                 1341   << pScene->GetName() << "\".";
1345   if (verbosity >= G4VisManager::parameters)     1342   if (verbosity >= G4VisManager::parameters) {
1346     G4cout << "  With extent " << extent         1343     G4cout << "  With extent " << extent
1347     << "\n  at " << transform.getRotation()      1344     << "\n  at " << transform.getRotation()
1348     << "  " << transform.getTranslation();       1345     << "  " << transform.getTranslation();
1349   }                                              1346   }
1350   G4cout << G4endl;                              1347   G4cout << G4endl;
1351       }                                          1348       }
1352     } else {                                     1349     } else {
1353       G4VisCommandsSceneAddUnsuccessful(verbo    1350       G4VisCommandsSceneAddUnsuccessful(verbosity);
1354     }                                            1351     }
1355   }                                              1352   }
1356                                                  1353 
1357   if (findingsVector.empty()) {                  1354   if (findingsVector.empty()) {
1358     if (verbosity >= G4VisManager::errors) {     1355     if (verbosity >= G4VisManager::errors) {
1359       G4warn << "ERROR: Volume \"" << name << << 1356       G4cerr << "ERROR: Volume \"" << name << "\"";
1360       if (copyNo >= 0) {                         1357       if (copyNo >= 0) {
1361   G4warn << ", copy no. " << copyNo << ",";   << 1358   G4cerr << ", copy no. " << copyNo << ",";
1362       }                                          1359       }
1363       G4warn << " not found." << G4endl;      << 1360       G4cerr << " not found." << G4endl;
1364     }                                            1361     }
1365     G4VisCommandsSceneAddUnsuccessful(verbosi    1362     G4VisCommandsSceneAddUnsuccessful(verbosity);
1366     return;                                      1363     return;
1367   }                                              1364   }
1368                                                  1365 
1369   CheckSceneAndNotifyHandlers(pScene);           1366   CheckSceneAndNotifyHandlers(pScene);
1370 }                                                1367 }
1371                                                  1368 
1372 ////////////// /vis/scene/add/logicalVolume /    1369 ////////////// /vis/scene/add/logicalVolume //////////////////////////////////
1373                                                  1370 
1374 G4VisCommandSceneAddLogicalVolume::G4VisComma    1371 G4VisCommandSceneAddLogicalVolume::G4VisCommandSceneAddLogicalVolume () {
1375   G4bool omitable;                               1372   G4bool omitable;
1376   fpCommand = new G4UIcommand ("/vis/scene/ad    1373   fpCommand = new G4UIcommand ("/vis/scene/add/logicalVolume", this);
1377   fpCommand -> SetGuidance ("Adds a logical v    1374   fpCommand -> SetGuidance ("Adds a logical volume to the current scene,");
1378   fpCommand -> SetGuidance                       1375   fpCommand -> SetGuidance
1379   ("Shows boolean components (if any), voxels    1376   ("Shows boolean components (if any), voxels (if any), readout geometry"
1380    "\n  (if any), local axes and overlaps (if    1377    "\n  (if any), local axes and overlaps (if any), under control of the"
1381    "\n  appropriate flag."                       1378    "\n  appropriate flag."
1382    "\n  Note: voxels are not constructed unti    1379    "\n  Note: voxels are not constructed until start of run -"
1383    "\n \"/run/beamOn\".  (For voxels without     1380    "\n \"/run/beamOn\".  (For voxels without a run, \"/run/beamOn 0\".)");
1384   G4UIparameter* parameter;                      1381   G4UIparameter* parameter;
1385   parameter = new G4UIparameter ("logical-vol    1382   parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false);
1386   fpCommand -> SetParameter (parameter);         1383   fpCommand -> SetParameter (parameter);
1387   parameter = new G4UIparameter ("depth-of-de    1384   parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
1388   parameter -> SetGuidance ("Depth of descent    1385   parameter -> SetGuidance ("Depth of descent of geometry hierarchy.");
1389   parameter -> SetDefaultValue (1);              1386   parameter -> SetDefaultValue (1);
1390   fpCommand -> SetParameter (parameter);         1387   fpCommand -> SetParameter (parameter);
1391   parameter = new G4UIparameter ("booleans-fl    1388   parameter = new G4UIparameter ("booleans-flag", 'b', omitable = true);
1392   parameter -> SetDefaultValue (true);           1389   parameter -> SetDefaultValue (true);
1393   fpCommand -> SetParameter (parameter);         1390   fpCommand -> SetParameter (parameter);
1394   parameter = new G4UIparameter ("voxels-flag    1391   parameter = new G4UIparameter ("voxels-flag", 'b', omitable = true);
1395   parameter -> SetDefaultValue (true);           1392   parameter -> SetDefaultValue (true);
1396   fpCommand -> SetParameter (parameter);         1393   fpCommand -> SetParameter (parameter);
1397   parameter = new G4UIparameter ("readout-fla    1394   parameter = new G4UIparameter ("readout-flag", 'b', omitable = true);
1398   parameter -> SetDefaultValue (true);           1395   parameter -> SetDefaultValue (true);
1399   fpCommand -> SetParameter (parameter);         1396   fpCommand -> SetParameter (parameter);
1400   parameter = new G4UIparameter ("axes-flag",    1397   parameter = new G4UIparameter ("axes-flag", 'b', omitable = true);
1401   parameter -> SetDefaultValue (true);           1398   parameter -> SetDefaultValue (true);
1402   parameter -> SetGuidance ("Set \"false\" to    1399   parameter -> SetGuidance ("Set \"false\" to suppress axes.");
1403   fpCommand -> SetParameter (parameter);         1400   fpCommand -> SetParameter (parameter);
1404   parameter = new G4UIparameter("check-overla    1401   parameter = new G4UIparameter("check-overlap-flag", 'b', omitable = true);
1405   parameter->SetDefaultValue(true);              1402   parameter->SetDefaultValue(true);
1406   parameter -> SetGuidance ("Set \"false\" to    1403   parameter -> SetGuidance ("Set \"false\" to suppress overlap check.");
1407   fpCommand->SetParameter(parameter);            1404   fpCommand->SetParameter(parameter);
1408 }                                                1405 }
1409                                                  1406 
1410 G4VisCommandSceneAddLogicalVolume::~G4VisComm    1407 G4VisCommandSceneAddLogicalVolume::~G4VisCommandSceneAddLogicalVolume () {
1411   delete fpCommand;                              1408   delete fpCommand;
1412 }                                                1409 }
1413                                                  1410 
1414 G4String G4VisCommandSceneAddLogicalVolume::G    1411 G4String G4VisCommandSceneAddLogicalVolume::GetCurrentValue (G4UIcommand*) {
1415   return "";                                     1412   return "";
1416 }                                                1413 }
1417                                                  1414 
1418 void G4VisCommandSceneAddLogicalVolume::SetNe    1415 void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand*,
1419                  G4String newValue) {            1416                  G4String newValue) {
1420                                                  1417 
1421   G4VisManager::Verbosity verbosity = fpVisMa    1418   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1422   G4bool warn(verbosity >= G4VisManager::warn    1419   G4bool warn(verbosity >= G4VisManager::warnings);
1423                                                  1420 
1424   G4Scene* pScene = fpVisManager->GetCurrentS    1421   G4Scene* pScene = fpVisManager->GetCurrentScene();
1425   if (!pScene) {                                 1422   if (!pScene) {
1426     if (verbosity >= G4VisManager::errors) {     1423     if (verbosity >= G4VisManager::errors) {
1427       G4warn << "ERROR: No current scene.  Pl << 1424       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
1428     }                                            1425     }
1429     return;                                      1426     return;
1430   }                                              1427   }
1431                                                  1428 
1432   G4String name;                                 1429   G4String name;
1433   G4int requestedDepthOfDescent;                 1430   G4int requestedDepthOfDescent;
1434   G4String booleansString, voxelsString, read    1431   G4String booleansString, voxelsString, readoutString, axesString;
1435   G4String overlapString;                        1432   G4String overlapString;
1436   std::istringstream is (newValue);              1433   std::istringstream is (newValue);
1437   is >> name >> requestedDepthOfDescent          1434   is >> name >> requestedDepthOfDescent
1438      >>  booleansString >> voxelsString >> re    1435      >>  booleansString >> voxelsString >> readoutString >> axesString
1439      >> overlapString;                           1436      >> overlapString;
1440   G4bool booleans = G4UIcommand::ConvertToBoo    1437   G4bool booleans = G4UIcommand::ConvertToBool(booleansString);
1441   G4bool voxels = G4UIcommand::ConvertToBool(    1438   G4bool voxels = G4UIcommand::ConvertToBool(voxelsString);
1442   G4bool readout = G4UIcommand::ConvertToBool    1439   G4bool readout = G4UIcommand::ConvertToBool(readoutString);
1443   G4bool axes = G4UIcommand::ConvertToBool(ax    1440   G4bool axes = G4UIcommand::ConvertToBool(axesString);
1444   G4bool checkOverlaps = G4UIcommand::Convert    1441   G4bool checkOverlaps = G4UIcommand::ConvertToBool(overlapString);
1445                                                  1442 
1446   G4LogicalVolumeStore *pLVStore = G4LogicalV    1443   G4LogicalVolumeStore *pLVStore = G4LogicalVolumeStore::GetInstance();
1447   G4LogicalVolume* pLV = nullptr;                1444   G4LogicalVolume* pLV = nullptr;
1448   pLV = pLVStore->GetVolume(name);               1445   pLV = pLVStore->GetVolume(name);
1449   if (pLV == nullptr) return;  // Volume not     1446   if (pLV == nullptr) return;  // Volume not found; warning message thrown
1450                                                  1447 
1451   const std::vector<G4Scene::Model>& rdModelL    1448   const std::vector<G4Scene::Model>& rdModelList =
1452     pScene -> GetRunDurationModelList();         1449     pScene -> GetRunDurationModelList();
1453   std::vector<G4Scene::Model>::const_iterator    1450   std::vector<G4Scene::Model>::const_iterator i;
1454   for (i = rdModelList.begin(); i != rdModelL    1451   for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
1455     if (i->fpModel->GetGlobalDescription().fi    1452     if (i->fpModel->GetGlobalDescription().find("Volume") != std::string::npos) break;
1456   }                                              1453   }
1457   if (i != rdModelList.end()) {                  1454   if (i != rdModelList.end()) {
1458     if (verbosity >= G4VisManager::errors) {     1455     if (verbosity >= G4VisManager::errors) {
1459       G4warn << "There is already a volume, \ << 1456       G4cout << "There is already a volume, \""
1460              << i->fpModel->GetGlobalDescript    1457              << i->fpModel->GetGlobalDescription()
1461              << "\",\n in the run-duration mo    1458              << "\",\n in the run-duration model list of scene \""
1462              << pScene -> GetName()              1459              << pScene -> GetName()
1463              << "\".\n Your logical volume mu    1460              << "\".\n Your logical volume must be the only volume in the scene."
1464        << "\n Create a new scene and try agai    1461        << "\n Create a new scene and try again:"
1465        << "\n  /vis/specify " << name            1462        << "\n  /vis/specify " << name
1466        << "\n or"                                1463        << "\n or"
1467        << "\n  /vis/scene/create"                1464        << "\n  /vis/scene/create"
1468        << "\n  /vis/scene/add/logicalVolume "    1465        << "\n  /vis/scene/add/logicalVolume " << name
1469        << "\n  /vis/sceneHandler/attach"         1466        << "\n  /vis/sceneHandler/attach"
1470        << "\n (and also, if necessary, /vis/v    1467        << "\n (and also, if necessary, /vis/viewer/flush)"
1471              << G4endl;                          1468              << G4endl;
1472     }                                            1469     }
1473     return;                                      1470     return;
1474   }                                              1471   }
1475                                                  1472 
1476   G4LogicalVolumeModel* model = new G4Logical    1473   G4LogicalVolumeModel* model = new G4LogicalVolumeModel
1477     (pLV, requestedDepthOfDescent, booleans,     1474     (pLV, requestedDepthOfDescent, booleans, voxels, readout, checkOverlaps);
1478   const G4String& currentSceneName = pScene -    1475   const G4String& currentSceneName = pScene -> GetName ();
1479   G4bool successful = pScene -> AddRunDuratio    1476   G4bool successful = pScene -> AddRunDurationModel (model, warn);
1480                                                  1477 
1481   if (successful) {                              1478   if (successful) {
1482                                                  1479 
1483     G4bool axesSuccessful = false;               1480     G4bool axesSuccessful = false;
1484     if (axes) {                                  1481     if (axes) {
1485       const G4double radius = model->GetExten    1482       const G4double radius = model->GetExtent().GetExtentRadius();
1486       const G4double axisLengthMax = radius /    1483       const G4double axisLengthMax = radius / 2.;
1487       const G4double intLog10Length = std::fl    1484       const G4double intLog10Length = std::floor(std::log10(axisLengthMax));
1488       G4double axisLength = std::pow(10,intLo    1485       G4double axisLength = std::pow(10,intLog10Length);
1489       if (5.*axisLength < axisLengthMax) axis    1486       if (5.*axisLength < axisLengthMax) axisLength *= 5.;
1490       else if (2.*axisLength < axisLengthMax)    1487       else if (2.*axisLength < axisLengthMax) axisLength *= 2.;
1491       const G4double axisWidth = axisLength /    1488       const G4double axisWidth = axisLength / 20.;
1492       G4VModel* axesModel = new G4AxesModel(0    1489       G4VModel* axesModel = new G4AxesModel(0.,0.,0.,axisLength,axisWidth);
1493       axesSuccessful = pScene -> AddRunDurati    1490       axesSuccessful = pScene -> AddRunDurationModel (axesModel, warn);
1494     }                                            1491     }
1495                                                  1492 
1496 //    if (verbosity >= G4VisManager::warnings    1493 //    if (verbosity >= G4VisManager::warnings) {
1497 //      const std::map<G4String,G4AttDef>* at    1494 //      const std::map<G4String,G4AttDef>* attDefs = model->GetAttDefs();
1498 //      std::vector<G4AttValue>* attValues =     1495 //      std::vector<G4AttValue>* attValues = model->CreateCurrentAttValues();
1499 //      G4warn << G4AttCheck(attValues, attDe << 1496 //      G4cout << G4AttCheck(attValues, attDefs);
1500 //      delete attValues;                        1497 //      delete attValues;
1501 //    }                                          1498 //    }
1502                                                  1499 
1503     if (verbosity >= G4VisManager::confirmati    1500     if (verbosity >= G4VisManager::confirmations) {
1504       G4cout << "Logical volume \"" << pLV ->    1501       G4cout << "Logical volume \"" << pLV -> GetName ()
1505        << "\" with requested depth of descent    1502        << "\" with requested depth of descent "
1506        << requestedDepthOfDescent                1503        << requestedDepthOfDescent
1507        << ",\n  with";                           1504        << ",\n  with";
1508       if (!booleans) G4cout << "out";            1505       if (!booleans) G4cout << "out";
1509       G4cout << " boolean components, with";     1506       G4cout << " boolean components, with";
1510       if (!voxels) G4cout << "out";              1507       if (!voxels) G4cout << "out";
1511       G4cout << " voxels,\n  with";              1508       G4cout << " voxels,\n  with";
1512       if (!readout) G4cout << "out";             1509       if (!readout) G4cout << "out";
1513       G4cout << " readout geometry and with";    1510       G4cout << " readout geometry and with";
1514       if (!checkOverlaps) G4cout << "out";       1511       if (!checkOverlaps) G4cout << "out";
1515       G4cout << " overlap checking"              1512       G4cout << " overlap checking"
1516        << "\n  has been added to scene \"" <<    1513        << "\n  has been added to scene \"" << currentSceneName << "\".";
1517       if (axes) {                                1514       if (axes) {
1518         if (axesSuccessful) {                    1515         if (axesSuccessful) {
1519           G4cout <<                              1516           G4cout <<
1520           "\n  Axes have also been added at t    1517           "\n  Axes have also been added at the origin of local cooordinates.";
1521         } else {                                 1518         } else {
1522           G4cout <<                              1519           G4cout <<
1523           "\n  Axes have not been added for s    1520           "\n  Axes have not been added for some reason possibly stated above.";
1524         }                                        1521         }
1525       }                                          1522       }
1526       G4cout << G4endl;                          1523       G4cout << G4endl;
1527     }                                            1524     }
1528   }                                              1525   }
1529   else {                                         1526   else {
1530     G4VisCommandsSceneAddUnsuccessful(verbosi    1527     G4VisCommandsSceneAddUnsuccessful(verbosity);
1531     return;                                      1528     return;
1532   }                                              1529   }
1533                                                  1530 
1534   CheckSceneAndNotifyHandlers (pScene);          1531   CheckSceneAndNotifyHandlers (pScene);
1535 }                                                1532 }
1536                                                  1533 
1537                                                  1534 
1538 ////////////// /vis/scene/add/logo //////////    1535 ////////////// /vis/scene/add/logo //////////////////////////////////
1539                                                  1536 
1540 G4VisCommandSceneAddLogo::G4VisCommandSceneAd    1537 G4VisCommandSceneAddLogo::G4VisCommandSceneAddLogo () {
1541   G4bool omitable;                               1538   G4bool omitable;
1542   fpCommand = new G4UIcommand ("/vis/scene/ad    1539   fpCommand = new G4UIcommand ("/vis/scene/add/logo", this);
1543   fpCommand -> SetGuidance ("Adds a G4 logo t    1540   fpCommand -> SetGuidance ("Adds a G4 logo to the current scene.");
1544   fpCommand -> SetGuidance                       1541   fpCommand -> SetGuidance
1545   ("If \"unit\" is \"auto\", height is roughl    1542   ("If \"unit\" is \"auto\", height is roughly one tenth of scene extent.");
1546   fpCommand -> SetGuidance                       1543   fpCommand -> SetGuidance
1547   ("\"direction\" is that of outward-facing n    1544   ("\"direction\" is that of outward-facing normal to front face of logo."
1548    "\nIf \"direction\" is \"auto\", logo face    1545    "\nIf \"direction\" is \"auto\", logo faces the user in the current viewer.");
1549   fpCommand -> SetGuidance                       1546   fpCommand -> SetGuidance
1550   ("\nIf \"placement\" is \"auto\", logo is p    1547   ("\nIf \"placement\" is \"auto\", logo is placed at bottom right of screen"
1551    "\n  when viewed from logo direction.");      1548    "\n  when viewed from logo direction.");
1552   G4UIparameter* parameter;                      1549   G4UIparameter* parameter;
1553   parameter = new G4UIparameter ("height", 'd    1550   parameter = new G4UIparameter ("height", 'd', omitable = true);
1554   parameter->SetDefaultValue (1.);               1551   parameter->SetDefaultValue (1.);
1555   fpCommand->SetParameter (parameter);           1552   fpCommand->SetParameter (parameter);
1556   parameter =  new G4UIparameter ("unit", 's'    1553   parameter =  new G4UIparameter ("unit", 's', omitable = true);
1557   parameter->SetDefaultValue ("auto");           1554   parameter->SetDefaultValue ("auto");
1558   fpCommand->SetParameter (parameter);           1555   fpCommand->SetParameter (parameter);
1559   parameter =  new G4UIparameter ("direction"    1556   parameter =  new G4UIparameter ("direction", 's', omitable = true);
1560   parameter->SetGuidance ("auto|[-]x|[-]y|[-]    1557   parameter->SetGuidance ("auto|[-]x|[-]y|[-]z");
1561   parameter->SetDefaultValue ("auto");           1558   parameter->SetDefaultValue ("auto");
1562   fpCommand->SetParameter (parameter);           1559   fpCommand->SetParameter (parameter);
1563   parameter =  new G4UIparameter ("red", 'd',    1560   parameter =  new G4UIparameter ("red", 'd', omitable = true);
1564   parameter->SetDefaultValue (0.);               1561   parameter->SetDefaultValue (0.);
1565   fpCommand->SetParameter (parameter);           1562   fpCommand->SetParameter (parameter);
1566   parameter =  new G4UIparameter ("green", 'd    1563   parameter =  new G4UIparameter ("green", 'd', omitable = true);
1567   parameter->SetDefaultValue (1.);               1564   parameter->SetDefaultValue (1.);
1568   fpCommand->SetParameter (parameter);           1565   fpCommand->SetParameter (parameter);
1569   parameter =  new G4UIparameter ("blue", 'd'    1566   parameter =  new G4UIparameter ("blue", 'd', omitable = true);
1570   parameter->SetDefaultValue (0.);               1567   parameter->SetDefaultValue (0.);
1571   fpCommand->SetParameter (parameter);           1568   fpCommand->SetParameter (parameter);
1572   parameter =  new G4UIparameter ("placement"    1569   parameter =  new G4UIparameter ("placement", 's', omitable = true);
1573   parameter -> SetParameterCandidates("auto m    1570   parameter -> SetParameterCandidates("auto manual");
1574   parameter->SetDefaultValue  ("auto");          1571   parameter->SetDefaultValue  ("auto");
1575   fpCommand->SetParameter     (parameter);       1572   fpCommand->SetParameter     (parameter);
1576   parameter =  new G4UIparameter ("xmid", 'd'    1573   parameter =  new G4UIparameter ("xmid", 'd', omitable = true);
1577   parameter->SetDefaultValue (0.);               1574   parameter->SetDefaultValue (0.);
1578   fpCommand->SetParameter (parameter);           1575   fpCommand->SetParameter (parameter);
1579   parameter =  new G4UIparameter ("ymid", 'd'    1576   parameter =  new G4UIparameter ("ymid", 'd', omitable = true);
1580   parameter->SetDefaultValue (0.);               1577   parameter->SetDefaultValue (0.);
1581   fpCommand->SetParameter (parameter);           1578   fpCommand->SetParameter (parameter);
1582   parameter =  new G4UIparameter ("zmid", 'd'    1579   parameter =  new G4UIparameter ("zmid", 'd', omitable = true);
1583   parameter->SetDefaultValue (0.);               1580   parameter->SetDefaultValue (0.);
1584   fpCommand->SetParameter (parameter);           1581   fpCommand->SetParameter (parameter);
1585   parameter =  new G4UIparameter ("unit", 's'    1582   parameter =  new G4UIparameter ("unit", 's', omitable = true);
1586   parameter->SetDefaultValue ("m");              1583   parameter->SetDefaultValue ("m");
1587   fpCommand->SetParameter (parameter);           1584   fpCommand->SetParameter (parameter);
1588 }                                                1585 }
1589                                                  1586 
1590 G4VisCommandSceneAddLogo::~G4VisCommandSceneA    1587 G4VisCommandSceneAddLogo::~G4VisCommandSceneAddLogo () {
1591   delete fpCommand;                              1588   delete fpCommand;
1592 }                                                1589 }
1593                                                  1590 
1594 G4String G4VisCommandSceneAddLogo::GetCurrent    1591 G4String G4VisCommandSceneAddLogo::GetCurrentValue (G4UIcommand*) {
1595   return "";                                     1592   return "";
1596 }                                                1593 }
1597                                                  1594 
1598 void G4VisCommandSceneAddLogo::SetNewValue (G    1595 void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
1599                                                  1596 
1600   G4VisManager::Verbosity verbosity = fpVisMa    1597   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1601   G4bool warn = verbosity >= G4VisManager::wa    1598   G4bool warn = verbosity >= G4VisManager::warnings;
1602                                                  1599 
1603   G4Scene* pScene = fpVisManager->GetCurrentS    1600   G4Scene* pScene = fpVisManager->GetCurrentScene();
1604   if (!pScene) {                                 1601   if (!pScene) {
1605     if (verbosity >= G4VisManager::errors) {     1602     if (verbosity >= G4VisManager::errors) {
1606       G4warn << "ERROR: No current scene.  Pl << 1603       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
1607     }                                            1604     }
1608     return;                                      1605     return;
1609   } else {                                       1606   } else {
1610     if (pScene->GetExtent().GetExtentRadius()    1607     if (pScene->GetExtent().GetExtentRadius() <= 0.) {
1611       if (verbosity >= G4VisManager::errors)     1608       if (verbosity >= G4VisManager::errors) {
1612         G4warn                                << 1609         G4cerr
1613   << "ERROR: Scene has no extent. Add volumes    1610   << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1614         << G4endl;                               1611         << G4endl;
1615       }                                          1612       }
1616       return;                                    1613       return;
1617     }                                            1614     }
1618   }                                              1615   }
1619                                                  1616 
1620   G4VViewer* pViewer = fpVisManager->GetCurre    1617   G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
1621   if (!pViewer) {                                1618   if (!pViewer) {
1622     if (verbosity >= G4VisManager::errors) {     1619     if (verbosity >= G4VisManager::errors) {
1623       G4warn <<                               << 1620       G4cerr <<
1624   "ERROR: G4VisCommandSceneAddLogo::SetNewVal    1621   "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1625   "\n  Auto direction needs a viewer."           1622   "\n  Auto direction needs a viewer."
1626        << G4endl;                                1623        << G4endl;
1627     }                                            1624     }
1628     return;                                      1625     return;
1629   }                                              1626   }
1630                                                  1627 
1631   G4double userHeight, red, green, blue, xmid    1628   G4double userHeight, red, green, blue, xmid, ymid, zmid;
1632   G4String userHeightUnit, direction, placeme    1629   G4String userHeightUnit, direction, placement, positionUnit;
1633   std::istringstream is (newValue);              1630   std::istringstream is (newValue);
1634   is >> userHeight >> userHeightUnit >> direc    1631   is >> userHeight >> userHeightUnit >> direction
1635      >> red >> green >> blue                     1632      >> red >> green >> blue
1636      >> placement                                1633      >> placement
1637      >> xmid >> ymid >> zmid >> positionUnit;    1634      >> xmid >> ymid >> zmid >> positionUnit;
1638                                                  1635 
1639   G4double height = userHeight;                  1636   G4double height = userHeight;
1640   const G4VisExtent& sceneExtent = pScene->Ge    1637   const G4VisExtent& sceneExtent = pScene->GetExtent();  // Existing extent.
1641   if (userHeightUnit == "auto") {                1638   if (userHeightUnit == "auto") {
1642     height *= 0.2 * sceneExtent.GetExtentRadi    1639     height *= 0.2 * sceneExtent.GetExtentRadius();
1643   } else {                                       1640   } else {
1644     height *= G4UIcommand::ValueOf(userHeight    1641     height *= G4UIcommand::ValueOf(userHeightUnit);
1645   }                                              1642   }
1646                                                  1643 
1647   G4double unit = G4UIcommand::ValueOf(positi    1644   G4double unit = G4UIcommand::ValueOf(positionUnit);
1648   xmid *= unit; ymid *= unit; zmid *= unit;      1645   xmid *= unit; ymid *= unit; zmid *= unit;
1649                                                  1646 
1650   Direction logoDirection = X;  // Initialise    1647   Direction logoDirection = X;  // Initialise to keep some compilers happy.
1651   if (direction == "auto") {                     1648   if (direction == "auto") {
1652     // Take cue from viewer                      1649     // Take cue from viewer
1653     const G4Vector3D& vp =                       1650     const G4Vector3D& vp =
1654       pViewer->GetViewParameters().GetViewpoi    1651       pViewer->GetViewParameters().GetViewpointDirection();
1655     if (vp.x() > vp.y() && vp.x() > vp.z()) l    1652     if (vp.x() > vp.y() && vp.x() > vp.z()) logoDirection = X;
1656     else if (vp.x() < vp.y() && vp.x() < vp.z    1653     else if (vp.x() < vp.y() && vp.x() < vp.z()) logoDirection = minusX;
1657     else if (vp.y() > vp.x() && vp.y() > vp.z    1654     else if (vp.y() > vp.x() && vp.y() > vp.z()) logoDirection = Y;
1658     else if (vp.y() < vp.x() && vp.y() < vp.z    1655     else if (vp.y() < vp.x() && vp.y() < vp.z()) logoDirection = minusY;
1659     else if (vp.z() > vp.x() && vp.z() > vp.y    1656     else if (vp.z() > vp.x() && vp.z() > vp.y()) logoDirection = Z;
1660     else if (vp.z() < vp.x() && vp.z() < vp.y    1657     else if (vp.z() < vp.x() && vp.z() < vp.y()) logoDirection = minusZ;
1661   }                                              1658   }
1662   else if (direction[0] == 'x') logoDirection    1659   else if (direction[0] == 'x') logoDirection = X;
1663   else if (direction[0] == 'y') logoDirection    1660   else if (direction[0] == 'y') logoDirection = Y;
1664   else if (direction[0] == 'z') logoDirection    1661   else if (direction[0] == 'z') logoDirection = Z;
1665   else if (direction[0] == '-') {                1662   else if (direction[0] == '-') {
1666     if (direction[1] == 'x') logoDirection =     1663     if (direction[1] == 'x') logoDirection = minusX;
1667     else if (direction[1] == 'y') logoDirecti    1664     else if (direction[1] == 'y') logoDirection = minusY;
1668     else if (direction[1] == 'z') logoDirecti    1665     else if (direction[1] == 'z') logoDirection = minusZ;
1669   } else {                                       1666   } else {
1670     if (verbosity >= G4VisManager::errors) {     1667     if (verbosity >= G4VisManager::errors) {
1671       G4warn << "ERROR: Unrecogniseed directi << 1668       G4cerr << "ERROR: Unrecogniseed direction: \""
1672        << direction << "\"." << G4endl;          1669        << direction << "\"." << G4endl;
1673       return;                                    1670       return;
1674     }                                            1671     }
1675   }                                              1672   }
1676                                                  1673 
1677   G4bool autoPlacing = false; if (placement =    1674   G4bool autoPlacing = false; if (placement == "auto") autoPlacing = true;
1678   // Parameters read and interpreted.            1675   // Parameters read and interpreted.
1679                                                  1676 
1680   // Current scene extent                        1677   // Current scene extent
1681   const G4double xmin = sceneExtent.GetXmin()    1678   const G4double xmin = sceneExtent.GetXmin();
1682   const G4double xmax = sceneExtent.GetXmax()    1679   const G4double xmax = sceneExtent.GetXmax();
1683   const G4double ymin = sceneExtent.GetYmin()    1680   const G4double ymin = sceneExtent.GetYmin();
1684   const G4double ymax = sceneExtent.GetYmax()    1681   const G4double ymax = sceneExtent.GetYmax();
1685   const G4double zmin = sceneExtent.GetZmin()    1682   const G4double zmin = sceneExtent.GetZmin();
1686   const G4double zmax = sceneExtent.GetZmax()    1683   const G4double zmax = sceneExtent.GetZmax();
1687                                                  1684 
1688   // Test existing extent and issue warnings.    1685   // Test existing extent and issue warnings...
1689   G4bool worried = false;                        1686   G4bool worried = false;
1690   if (sceneExtent.GetExtentRadius() == 0) {      1687   if (sceneExtent.GetExtentRadius() == 0) {
1691     worried = true;                              1688     worried = true;
1692     if (verbosity >= G4VisManager::warnings)     1689     if (verbosity >= G4VisManager::warnings) {
1693       G4warn <<                               << 1690       G4cout <<
1694   "WARNING: Existing scene does not yet have     1691   "WARNING: Existing scene does not yet have any extent."
1695   "\n  Maybe you have not yet added any geome    1692   "\n  Maybe you have not yet added any geometrical object."
1696        << G4endl;                                1693        << G4endl;
1697     }                                            1694     }
1698   }                                              1695   }
1699                                                  1696 
1700   // Useful constants, etc...                    1697   // Useful constants, etc...
1701   const G4double halfHeight(height / 2.);        1698   const G4double halfHeight(height / 2.);
1702   const G4double comfort(0.01);  // 0.15 seem    1699   const G4double comfort(0.01);  // 0.15 seems too big.  0.05 might be better.
1703   const G4double freeHeightFraction (1. + 2.     1700   const G4double freeHeightFraction (1. + 2. * comfort);
1704                                                  1701 
1705   // Test existing scene for room...             1702   // Test existing scene for room...
1706   G4bool room = true;                            1703   G4bool room = true;
1707   switch (logoDirection) {                       1704   switch (logoDirection) {
1708   case X:                                        1705   case X:
1709   case minusX:                                   1706   case minusX:
1710     if (freeHeightFraction * (xmax - xmin) <     1707     if (freeHeightFraction * (xmax - xmin) < height) room = false;
1711     break;                                       1708     break;
1712   case Y:                                        1709   case Y:
1713   case minusY:                                   1710   case minusY:
1714     if (freeHeightFraction * (ymax - ymin) <     1711     if (freeHeightFraction * (ymax - ymin) < height) room = false;
1715     break;                                       1712     break;
1716   case Z:                                        1713   case Z:
1717   case minusZ:                                   1714   case minusZ:
1718     if (freeHeightFraction * (zmax - zmin) <     1715     if (freeHeightFraction * (zmax - zmin) < height) room = false;
1719     break;                                       1716     break;
1720   }                                              1717   }
1721   if (!room) {                                   1718   if (!room) {
1722     worried = true;                              1719     worried = true;
1723     if (verbosity >= G4VisManager::warnings)     1720     if (verbosity >= G4VisManager::warnings) {
1724       G4warn <<                               << 1721       G4cout <<
1725   "WARNING: Not enough room in existing scene    1722   "WARNING: Not enough room in existing scene.  Maybe logo is too large."
1726        << G4endl;                                1723        << G4endl;
1727     }                                            1724     }
1728   }                                              1725   }
1729   if (worried) {                                 1726   if (worried) {
1730     if (verbosity >= G4VisManager::warnings)     1727     if (verbosity >= G4VisManager::warnings) {
1731       G4warn <<                               << 1728       G4cout <<
1732   "WARNING: The logo you have asked for is bi    1729   "WARNING: The logo you have asked for is bigger than the existing"
1733   "\n  scene.  Maybe you have added it too so    1730   "\n  scene.  Maybe you have added it too soon.  It is recommended that"
1734   "\n  you add the logo last so that it can b    1731   "\n  you add the logo last so that it can be correctly auto-positioned"
1735   "\n  so as not to be obscured by any existi    1732   "\n  so as not to be obscured by any existing object and so that the"
1736   "\n  view parameters can be correctly recal    1733   "\n  view parameters can be correctly recalculated."
1737        << G4endl;                                1734        << G4endl;
1738     }                                            1735     }
1739   }                                              1736   }
1740                                                  1737 
1741   G4double sxmid(xmid), symid(ymid), szmid(zm    1738   G4double sxmid(xmid), symid(ymid), szmid(zmid);
1742   if (autoPlacing) {                             1739   if (autoPlacing) {
1743     // Aim to place at bottom right of screen    1740     // Aim to place at bottom right of screen when viewed from logoDirection.
1744     // Give some comfort zone.                   1741     // Give some comfort zone.
1745     const G4double xComfort = comfort * (xmax    1742     const G4double xComfort = comfort * (xmax - xmin);
1746     const G4double yComfort = comfort * (ymax    1743     const G4double yComfort = comfort * (ymax - ymin);
1747     const G4double zComfort = comfort * (zmax    1744     const G4double zComfort = comfort * (zmax - zmin);
1748     switch (logoDirection) {                     1745     switch (logoDirection) {
1749     case X:  // y-axis up, z-axis to left?       1746     case X:  // y-axis up, z-axis to left?
1750       sxmid = xmax + halfHeight + xComfort;      1747       sxmid = xmax + halfHeight + xComfort;
1751       symid = ymin - yComfort;                   1748       symid = ymin - yComfort;
1752       szmid = zmin - zComfort;                   1749       szmid = zmin - zComfort;
1753       break;                                     1750       break;
1754     case minusX:  // y-axis up, z-axis to rig    1751     case minusX:  // y-axis up, z-axis to right?
1755       sxmid = xmin - halfHeight - xComfort;      1752       sxmid = xmin - halfHeight - xComfort;
1756       symid = ymin - yComfort;                   1753       symid = ymin - yComfort;
1757       szmid = zmax + zComfort;                   1754       szmid = zmax + zComfort;
1758       break;                                     1755       break;
1759     case Y:  // z-axis up, x-axis to left?       1756     case Y:  // z-axis up, x-axis to left?
1760       sxmid = xmin - xComfort;                   1757       sxmid = xmin - xComfort;
1761       symid = ymax + halfHeight + yComfort;      1758       symid = ymax + halfHeight + yComfort;
1762       szmid = zmin - zComfort;                   1759       szmid = zmin - zComfort;
1763       break;                                     1760       break;
1764     case minusY:  // z-axis up, x-axis to rig    1761     case minusY:  // z-axis up, x-axis to right?
1765       sxmid = xmax + xComfort;                   1762       sxmid = xmax + xComfort;
1766       symid = ymin - halfHeight - yComfort;      1763       symid = ymin - halfHeight - yComfort;
1767       szmid = zmin - zComfort;                   1764       szmid = zmin - zComfort;
1768       break;                                     1765       break;
1769     case Z:  // y-axis up, x-axis to right?      1766     case Z:  // y-axis up, x-axis to right?
1770       sxmid = xmax + xComfort;                   1767       sxmid = xmax + xComfort;
1771       symid = ymin - yComfort;                   1768       symid = ymin - yComfort;
1772       szmid = zmax + halfHeight + zComfort;      1769       szmid = zmax + halfHeight + zComfort;
1773       break;                                     1770       break;
1774     case minusZ:  // y-axis up, x-axis to lef    1771     case minusZ:  // y-axis up, x-axis to left?
1775       sxmid = xmin - xComfort;                   1772       sxmid = xmin - xComfort;
1776       symid = ymin - yComfort;                   1773       symid = ymin - yComfort;
1777       szmid = zmin - halfHeight - zComfort;      1774       szmid = zmin - halfHeight - zComfort;
1778       break;                                     1775       break;
1779     }                                            1776     }
1780   }                                              1777   }
1781                                                  1778 
1782   G4Transform3D transform;                       1779   G4Transform3D transform;
1783   switch (logoDirection) {                       1780   switch (logoDirection) {
1784   case X:  // y-axis up, z-axis to left?         1781   case X:  // y-axis up, z-axis to left?
1785     transform = G4RotateY3D(halfpi);             1782     transform = G4RotateY3D(halfpi);
1786     break;                                       1783     break;
1787   case minusX:  // y-axis up, z-axis to right    1784   case minusX:  // y-axis up, z-axis to right?
1788     transform = G4RotateY3D(-halfpi);            1785     transform = G4RotateY3D(-halfpi);
1789     break;                                       1786     break;
1790   case Y:  // z-axis up, x-axis to left?         1787   case Y:  // z-axis up, x-axis to left?
1791     transform = G4RotateX3D(-halfpi) * G4Rota    1788     transform = G4RotateX3D(-halfpi) * G4RotateZ3D(pi);
1792     break;                                       1789     break;
1793   case minusY:  // z-axis up, x-axis to right    1790   case minusY:  // z-axis up, x-axis to right?
1794     transform = G4RotateX3D(halfpi);             1791     transform = G4RotateX3D(halfpi);
1795     break;                                       1792     break;
1796   case Z:  // y-axis up, x-axis to right?        1793   case Z:  // y-axis up, x-axis to right?
1797     // No transformation required.               1794     // No transformation required.
1798     break;                                       1795     break;
1799   case minusZ:  // y-axis up, x-axis to left?    1796   case minusZ:  // y-axis up, x-axis to left?
1800     transform = G4RotateY3D(pi);                 1797     transform = G4RotateY3D(pi);
1801     break;                                       1798     break;
1802   }                                              1799   }
1803   transform = G4Translate3D(sxmid,symid,szmid    1800   transform = G4Translate3D(sxmid,symid,szmid) * transform;
1804                                                  1801 
1805   G4VisAttributes visAtts(G4Colour(red, green    1802   G4VisAttributes visAtts(G4Colour(red, green, blue));
1806   visAtts.SetForceSolid(true);         // Alw    1803   visAtts.SetForceSolid(true);         // Always solid.
1807                                                  1804 
1808   G4Logo* logo = new G4Logo(height,visAtts,tr    1805   G4Logo* logo = new G4Logo(height,visAtts,transform);
1809   G4VModel* model =                              1806   G4VModel* model =
1810     new G4CallbackModel<G4VisCommandSceneAddL    1807     new G4CallbackModel<G4VisCommandSceneAddLogo::G4Logo>(logo);
1811   model->SetType("G4Logo");                      1808   model->SetType("G4Logo");
1812   model->SetGlobalTag("G4Logo");                 1809   model->SetGlobalTag("G4Logo");
1813   model->SetGlobalDescription("G4Logo: " + ne    1810   model->SetGlobalDescription("G4Logo: " + newValue);
1814   G4double& h = height;                          1811   G4double& h = height;
1815   G4double h2 = h/2.;                            1812   G4double h2 = h/2.;
1816   G4VisExtent extent(-h,h,-h2,h2,-h2,h2);        1813   G4VisExtent extent(-h,h,-h2,h2,-h2,h2);
1817   model->SetExtent(extent.Transform(transform    1814   model->SetExtent(extent.Transform(transform));
1818   // This extent gets "added" to existing sce    1815   // This extent gets "added" to existing scene extent in
1819   // AddRunDurationModel below.                  1816   // AddRunDurationModel below.
1820   const G4String& currentSceneName = pScene -    1817   const G4String& currentSceneName = pScene -> GetName ();
1821   G4bool successful = pScene -> AddRunDuratio    1818   G4bool successful = pScene -> AddRunDurationModel (model, warn);
1822   if (successful) {                              1819   if (successful) {
1823     if (verbosity >= G4VisManager::confirmati    1820     if (verbosity >= G4VisManager::confirmations) {
1824       G4cout << "G4 Logo of height " << userH    1821       G4cout << "G4 Logo of height " << userHeight << ' ' << userHeightUnit
1825        << ", " << direction << "-direction, a    1822        << ", " << direction << "-direction, added to scene \""
1826        << currentSceneName << "\"";              1823        << currentSceneName << "\"";
1827       if (verbosity >= G4VisManager::paramete    1824       if (verbosity >= G4VisManager::parameters) {
1828   G4cout << "\n  with extent " << extent         1825   G4cout << "\n  with extent " << extent
1829          << "\n  at " << transform.getRotatio    1826          << "\n  at " << transform.getRotation()
1830          << "  " << transform.getTranslation(    1827          << "  " << transform.getTranslation();
1831       }                                          1828       }
1832       G4cout << G4endl;                          1829       G4cout << G4endl;
1833     }                                            1830     }
1834   }                                              1831   }
1835   else G4VisCommandsSceneAddUnsuccessful(verb    1832   else G4VisCommandsSceneAddUnsuccessful(verbosity);
1836                                                  1833 
1837   CheckSceneAndNotifyHandlers (pScene);          1834   CheckSceneAndNotifyHandlers (pScene);
1838 }                                                1835 }
1839                                                  1836 
1840 G4VisCommandSceneAddLogo::G4Logo::G4Logo         1837 G4VisCommandSceneAddLogo::G4Logo::G4Logo
1841 (G4double height, const G4VisAttributes& visA    1838 (G4double height, const G4VisAttributes& visAtts, const G4Transform3D& transform)
1842 {                                                1839 {
1843   const G4double& h =  height;                   1840   const G4double& h =  height;
1844   const G4double h2  = 0.5 * h;   // Half hei    1841   const G4double h2  = 0.5 * h;   // Half height.
1845   const G4double ri  = 0.25 * h;  // Inner ra    1842   const G4double ri  = 0.25 * h;  // Inner radius.
1846   const G4double ro  = 0.5 * h;   // Outer ra    1843   const G4double ro  = 0.5 * h;   // Outer radius.
1847   const G4double ro2 = 0.5 * ro;  // Half out    1844   const G4double ro2 = 0.5 * ro;  // Half outer radius.
1848   const G4double w   = ro - ri;   // Width.      1845   const G4double w   = ro - ri;   // Width.
1849   const G4double w2  = 0.5 * w;   // Half wid    1846   const G4double w2  = 0.5 * w;   // Half width.
1850   const G4double d2  = 0.2 * h;   // Half dep    1847   const G4double d2  = 0.2 * h;   // Half depth.
1851   const G4double f1  = 0.05 * h;  // left edg    1848   const G4double f1  = 0.05 * h;  // left edge of stem of "4".
1852   const G4double f2  = -0.3 * h;  // bottom e    1849   const G4double f2  = -0.3 * h;  // bottom edge of cross of "4".
1853   const G4double e = 1.e-4 * h;   // epsilon.    1850   const G4double e = 1.e-4 * h;   // epsilon.
1854   const G4double xt = f1, yt = h2;      // To    1851   const G4double xt = f1, yt = h2;      // Top of slope.
1855   const G4double xb = -h2, yb = f2 + w; // Bo    1852   const G4double xb = -h2, yb = f2 + w; // Bottom of slope.
1856   const G4double dx = xt - xb, dy = yt - yb;     1853   const G4double dx = xt - xb, dy = yt - yb;
1857   const G4double angle = std::atan2(dy,dx);      1854   const G4double angle = std::atan2(dy,dx);
1858   G4RotationMatrix rm;                           1855   G4RotationMatrix rm;
1859   rm.rotateZ(angle*rad);                         1856   rm.rotateZ(angle*rad);
1860   const G4double d = std::sqrt(dx * dx + dy *    1857   const G4double d = std::sqrt(dx * dx + dy * dy);
1861   const G4double ss = h;  // Half height of s    1858   const G4double ss = h;  // Half height of square subtractor
1862   const G4double y8 = ss; // Choose y of subt    1859   const G4double y8 = ss; // Choose y of subtractor for outer slope.
1863   const G4double x8 = ((-ss * d - dx * (yt -     1860   const G4double x8 = ((-ss * d - dx * (yt - y8)) / dy) + xt;
1864   G4double y9 = ss; // Choose y of subtractor    1861   G4double y9 = ss; // Choose y of subtractor for inner slope.
1865   G4double x9 = ((-(ss - w) * d - dx * (yt -     1862   G4double x9 = ((-(ss - w) * d - dx * (yt - y8)) / dy) + xt;
1866   // But to get inner, we make a triangle tra    1863   // But to get inner, we make a triangle translated by...
1867   const G4double xtr = ss - f1, ytr = -ss - f    1864   const G4double xtr = ss - f1, ytr = -ss - f2 -w;
1868   x9 += xtr; y9 += ytr;                          1865   x9 += xtr; y9 += ytr;
1869                                                  1866 
1870   // The idea here is to create a polyhedron     1867   // The idea here is to create a polyhedron for the G and the 4.  To do
1871   // this we use Geant4 geometry solids and m    1868   // this we use Geant4 geometry solids and make boolean operations.
1872   // Note that we do not need to keep the sol    1869   // Note that we do not need to keep the solids. We use local objects,
1873   // which, of course, are deleted on leaving    1870   // which, of course, are deleted on leaving this function. This
1874   // is contrary to the usual requirement for    1871   // is contrary to the usual requirement for solids that are part of the
1875   // detector for which solids MUST be create    1872   // detector for which solids MUST be created on the heap (with "new").
1876   // Finally we invoke CreatePolyhedron, whic    1873   // Finally we invoke CreatePolyhedron, which creates a polyhedron on the heap
1877   // and returns a pointer.  It is the user's    1874   // and returns a pointer.  It is the user's responsibility to delete,
1878   // which is done in the destructor of this     1875   // which is done in the destructor of this class. Thus the polyhedra,
1879   // created here, remain on the heap for the    1876   // created here, remain on the heap for the lifetime of the job.
1880                                                  1877 
1881   // G...                                        1878   // G...
1882   G4Tubs tG("tG",ri,ro,d2,0.15*pi,1.85*pi);      1879   G4Tubs tG("tG",ri,ro,d2,0.15*pi,1.85*pi);
1883   G4Box bG("bG",w2,ro2,d2);                      1880   G4Box bG("bG",w2,ro2,d2);
1884   G4UnionSolid logoG("logoG",&tG,&bG,G4Transl    1881   G4UnionSolid logoG("logoG",&tG,&bG,G4Translate3D(ri+w2,-ro2,0.));
1885   // Create with these vis atts (force solid) << 
1886   G4Polyhedron::SetNumberOfRotationSteps      << 
1887   (fpVisManager->GetCurrentViewer()->GetViewP << 
1888   fpG = logoG.CreatePolyhedron();                1882   fpG = logoG.CreatePolyhedron();
1889   G4Polyhedron::ResetNumberOfRotationSteps () << 
1890   fpG->SetVisAttributes(visAtts);                1883   fpG->SetVisAttributes(visAtts);
1891   fpG->Transform(G4Translate3D(-0.55*h,0.,0.)    1884   fpG->Transform(G4Translate3D(-0.55*h,0.,0.));
1892   fpG->Transform(transform);                     1885   fpG->Transform(transform);
1893                                                  1886 
1894   // 4...                                        1887   // 4...
1895   G4Box b1("b1",h2,h2,d2);                       1888   G4Box b1("b1",h2,h2,d2);
1896   G4Box bS("bS",ss,ss,d2+e);  // Subtractor.     1889   G4Box bS("bS",ss,ss,d2+e);  // Subtractor.
1897   G4Box bS2("bS2",ss,ss,d2+2.*e);  // 2nd Sub    1890   G4Box bS2("bS2",ss,ss,d2+2.*e);  // 2nd Subtractor.
1898   G4SubtractionSolid s1("s1",&b1,&bS,G4Transl    1891   G4SubtractionSolid s1("s1",&b1,&bS,G4Translate3D(f1-ss,f2-ss,0.));
1899   G4SubtractionSolid s2("s2",&s1,&bS,G4Transl    1892   G4SubtractionSolid s2("s2",&s1,&bS,G4Translate3D(f1+ss+w,f2-ss,0.));
1900   G4SubtractionSolid s3("s3",&s2,&bS,G4Transl    1893   G4SubtractionSolid s3("s3",&s2,&bS,G4Translate3D(f1+ss+w,f2+ss+w,0.));
1901   G4SubtractionSolid s4                          1894   G4SubtractionSolid s4
1902     ("s4",&s3,&bS,G4Transform3D(rm,G4ThreeVec    1895     ("s4",&s3,&bS,G4Transform3D(rm,G4ThreeVector(x8,y8,0.)));
1903   G4SubtractionSolid s5    // Triangular hole    1896   G4SubtractionSolid s5    // Triangular hole.
1904     ("s5",&bS,&bS2,G4Transform3D(rm,G4ThreeVe    1897     ("s5",&bS,&bS2,G4Transform3D(rm,G4ThreeVector(x9,y9,0.)));
1905   G4SubtractionSolid logo4("logo4",&s4,&s5,G4    1898   G4SubtractionSolid logo4("logo4",&s4,&s5,G4Translate3D(-xtr,-ytr,0.));
1906   fp4 = logo4.CreatePolyhedron();                1899   fp4 = logo4.CreatePolyhedron();
1907   /* Experiment with creating own polyhedron.    1900   /* Experiment with creating own polyhedron...
1908   int nNodes = 4;                                1901   int nNodes = 4;
1909   int nFaces = 4;                                1902   int nFaces = 4;
1910   double xyz[][3] = {{0,0,0},{1*m,0,0},{0,1*m    1903   double xyz[][3] = {{0,0,0},{1*m,0,0},{0,1*m,0},{0,0,1*m}};
1911   int faces[][4] = {{1,3,2,0},{1,2,4,0},{1,4,    1904   int faces[][4] = {{1,3,2,0},{1,2,4,0},{1,4,3,0},{2,3,4,0}};
1912   fp4 = new G4Polyhedron();                      1905   fp4 = new G4Polyhedron();
1913   fp4->createPolyhedron(nNodes,nFaces,xyz,fac    1906   fp4->createPolyhedron(nNodes,nFaces,xyz,faces);
1914   */                                             1907   */
1915   fp4->SetVisAttributes(visAtts);                1908   fp4->SetVisAttributes(visAtts);
1916   fp4->Transform(G4Translate3D(0.55*h,0.,0.))    1909   fp4->Transform(G4Translate3D(0.55*h,0.,0.));
1917   fp4->Transform(transform);                     1910   fp4->Transform(transform);
1918 }                                                1911 }
1919                                                  1912 
1920 G4VisCommandSceneAddLogo::G4Logo::~G4Logo() {    1913 G4VisCommandSceneAddLogo::G4Logo::~G4Logo() {
1921   delete fpG;                                    1914   delete fpG;
1922   delete fp4;                                    1915   delete fp4;
1923 }                                                1916 }
1924                                                  1917 
1925 void G4VisCommandSceneAddLogo::G4Logo::operat    1918 void G4VisCommandSceneAddLogo::G4Logo::operator()
1926   (G4VGraphicsScene& sceneHandler, const G4Mo    1919   (G4VGraphicsScene& sceneHandler, const G4ModelingParameters*) {
1927   sceneHandler.BeginPrimitives();                1920   sceneHandler.BeginPrimitives();
1928   sceneHandler.AddPrimitive(*fpG);               1921   sceneHandler.AddPrimitive(*fpG);
1929   sceneHandler.AddPrimitive(*fp4);               1922   sceneHandler.AddPrimitive(*fp4);
1930   sceneHandler.EndPrimitives();                  1923   sceneHandler.EndPrimitives();
1931 }                                                1924 }
1932                                                  1925 
1933 ////////////// /vis/scene/add/logo2D ////////    1926 ////////////// /vis/scene/add/logo2D ///////////////////////////////////////
1934                                                  1927 
1935 G4VisCommandSceneAddLogo2D::G4VisCommandScene    1928 G4VisCommandSceneAddLogo2D::G4VisCommandSceneAddLogo2D () {
1936   G4bool omitable;                               1929   G4bool omitable;
1937   fpCommand = new G4UIcommand ("/vis/scene/ad    1930   fpCommand = new G4UIcommand ("/vis/scene/add/logo2D", this);
1938   fpCommand -> SetGuidance ("Adds 2D logo to     1931   fpCommand -> SetGuidance ("Adds 2D logo to current scene.");
1939   G4UIparameter* parameter;                      1932   G4UIparameter* parameter;
1940   parameter = new G4UIparameter ("size", 'i',    1933   parameter = new G4UIparameter ("size", 'i', omitable = true);
1941   parameter -> SetGuidance ("Screen size of t    1934   parameter -> SetGuidance ("Screen size of text in pixels.");
1942   parameter -> SetDefaultValue (48);             1935   parameter -> SetDefaultValue (48);
1943   fpCommand -> SetParameter (parameter);         1936   fpCommand -> SetParameter (parameter);
1944   parameter = new G4UIparameter ("x-position"    1937   parameter = new G4UIparameter ("x-position", 'd', omitable = true);
1945   parameter -> SetGuidance ("x screen positio    1938   parameter -> SetGuidance ("x screen position in range -1 < x < 1.");
1946   parameter -> SetDefaultValue (-0.9);           1939   parameter -> SetDefaultValue (-0.9);
1947   fpCommand -> SetParameter (parameter);         1940   fpCommand -> SetParameter (parameter);
1948   parameter = new G4UIparameter ("y-position"    1941   parameter = new G4UIparameter ("y-position", 'd', omitable = true);
1949   parameter -> SetGuidance ("y screen positio    1942   parameter -> SetGuidance ("y screen position in range -1 < y < 1.");
1950   parameter -> SetDefaultValue (-0.9);           1943   parameter -> SetDefaultValue (-0.9);
1951   fpCommand -> SetParameter (parameter);         1944   fpCommand -> SetParameter (parameter);
1952   parameter = new G4UIparameter ("layout", 's    1945   parameter = new G4UIparameter ("layout", 's', omitable = true);
1953   parameter -> SetGuidance ("Layout, i.e., ad    1946   parameter -> SetGuidance ("Layout, i.e., adjustment: left|centre|right.");
1954   parameter -> SetDefaultValue ("left");         1947   parameter -> SetDefaultValue ("left");
1955   fpCommand -> SetParameter (parameter);         1948   fpCommand -> SetParameter (parameter);
1956 }                                                1949 }
1957                                                  1950 
1958 G4VisCommandSceneAddLogo2D::~G4VisCommandScen    1951 G4VisCommandSceneAddLogo2D::~G4VisCommandSceneAddLogo2D () {
1959   delete fpCommand;                              1952   delete fpCommand;
1960 }                                                1953 }
1961                                                  1954 
1962 G4String G4VisCommandSceneAddLogo2D::GetCurre    1955 G4String G4VisCommandSceneAddLogo2D::GetCurrentValue (G4UIcommand*) {
1963   return "";                                     1956   return "";
1964 }                                                1957 }
1965                                                  1958 
1966 void G4VisCommandSceneAddLogo2D::SetNewValue     1959 void G4VisCommandSceneAddLogo2D::SetNewValue (G4UIcommand*, G4String newValue)
1967 {                                                1960 {
1968   G4VisManager::Verbosity verbosity = fpVisMa    1961   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1969   G4bool warn(verbosity >= G4VisManager::warn    1962   G4bool warn(verbosity >= G4VisManager::warnings);
1970                                                  1963 
1971   G4Scene* pScene = fpVisManager->GetCurrentS    1964   G4Scene* pScene = fpVisManager->GetCurrentScene();
1972   if (!pScene) {                                 1965   if (!pScene) {
1973     if (verbosity >= G4VisManager::errors) {     1966     if (verbosity >= G4VisManager::errors) {
1974       G4warn << "ERROR: No current scene.  Pl << 1967       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
1975     }                                            1968     }
1976     return;                                      1969     return;
1977   }                                              1970   }
1978                                                  1971 
1979   G4int size;                                    1972   G4int size;
1980   G4double x, y;                                 1973   G4double x, y;
1981   G4String layoutString;                         1974   G4String layoutString;
1982   std::istringstream is(newValue);               1975   std::istringstream is(newValue);
1983   is >> size >> x >> y >> layoutString;          1976   is >> size >> x >> y >> layoutString;
1984   G4Text::Layout layout = G4Text::right;         1977   G4Text::Layout layout = G4Text::right;
1985   if (layoutString[0] == 'l') layout = G4Text    1978   if (layoutString[0] == 'l') layout = G4Text::left;
1986   else if (layoutString[0] == 'c') layout = G    1979   else if (layoutString[0] == 'c') layout = G4Text::centre;
1987   else if (layoutString[0] == 'r') layout = G    1980   else if (layoutString[0] == 'r') layout = G4Text::right;
1988                                                  1981 
1989   Logo2D* logo2D = new Logo2D(fpVisManager, s    1982   Logo2D* logo2D = new Logo2D(fpVisManager, size, x, y, layout);
1990   G4VModel* model =                              1983   G4VModel* model =
1991     new G4CallbackModel<G4VisCommandSceneAddL    1984     new G4CallbackModel<G4VisCommandSceneAddLogo2D::Logo2D>(logo2D);
1992   model->SetType("G4Logo2D");                    1985   model->SetType("G4Logo2D");
1993   model->SetGlobalTag("G4Logo2D");               1986   model->SetGlobalTag("G4Logo2D");
1994   model->SetGlobalDescription("G4Logo2D: " +     1987   model->SetGlobalDescription("G4Logo2D: " + newValue);
1995   const G4String& currentSceneName = pScene -    1988   const G4String& currentSceneName = pScene -> GetName ();
1996   G4bool successful = pScene -> AddRunDuratio    1989   G4bool successful = pScene -> AddRunDurationModel (model, warn);
1997   if (successful) {                              1990   if (successful) {
1998     if (verbosity >= G4VisManager::confirmati    1991     if (verbosity >= G4VisManager::confirmations) {
1999       G4cout << "2D logo has been added to sc    1992       G4cout << "2D logo has been added to scene \""
2000        << currentSceneName << "\"."              1993        << currentSceneName << "\"."
2001        << G4endl;                                1994        << G4endl;
2002     }                                            1995     }
2003   }                                              1996   }
2004   else G4VisCommandsSceneAddUnsuccessful(verb    1997   else G4VisCommandsSceneAddUnsuccessful(verbosity);
2005                                                  1998 
2006   CheckSceneAndNotifyHandlers (pScene);          1999   CheckSceneAndNotifyHandlers (pScene);
2007 }                                                2000 }
2008                                                  2001 
2009 void G4VisCommandSceneAddLogo2D::Logo2D::oper    2002 void G4VisCommandSceneAddLogo2D::Logo2D::operator()
2010   (G4VGraphicsScene& sceneHandler, const G4Mo    2003   (G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
2011 {                                                2004 {
2012   G4Text text("Geant4", G4Point3D(fX, fY, 0.)    2005   G4Text text("Geant4", G4Point3D(fX, fY, 0.));
2013   text.SetScreenSize(fSize);                     2006   text.SetScreenSize(fSize);
2014   text.SetLayout(fLayout);                       2007   text.SetLayout(fLayout);
2015   G4VisAttributes textAtts(G4Colour::Brown())    2008   G4VisAttributes textAtts(G4Colour::Brown());
2016   text.SetVisAttributes(textAtts);               2009   text.SetVisAttributes(textAtts);
2017   sceneHandler.BeginPrimitives2D();              2010   sceneHandler.BeginPrimitives2D();
2018   sceneHandler.AddPrimitive(text);               2011   sceneHandler.AddPrimitive(text);
2019   sceneHandler.EndPrimitives2D();                2012   sceneHandler.EndPrimitives2D();
2020 }                                                2013 }
2021                                                  2014 
2022 ////////////// /vis/scene/add/magneticField /    2015 ////////////// /vis/scene/add/magneticField ///////////////////////////////////////
2023                                                  2016 
2024 G4VisCommandSceneAddMagneticField::G4VisComma    2017 G4VisCommandSceneAddMagneticField::G4VisCommandSceneAddMagneticField () {
2025   fpCommand = new G4UIcommand ("/vis/scene/ad    2018   fpCommand = new G4UIcommand ("/vis/scene/add/magneticField", this);
2026   fpCommand -> SetGuidance                       2019   fpCommand -> SetGuidance
2027   ("Adds magnetic field representation to cur    2020   ("Adds magnetic field representation to current scene.");
2028   const G4UIcommandTree* tree = G4UImanager::    2021   const G4UIcommandTree* tree = G4UImanager::GetUIpointer()->GetTree();
2029   const G4UIcommand* addElecFieldCmd = tree->    2022   const G4UIcommand* addElecFieldCmd = tree->FindPath("/vis/scene/add/electricField");
2030   // Pick up additional guidance from /vis/sc    2023   // Pick up additional guidance from /vis/scene/add/electricField
2031   CopyGuidanceFrom(addElecFieldCmd,fpCommand,    2024   CopyGuidanceFrom(addElecFieldCmd,fpCommand,1);
2032   // Pick up parameters from /vis/scene/add/e    2025   // Pick up parameters from /vis/scene/add/electricField
2033   CopyParametersFrom(addElecFieldCmd,fpComman    2026   CopyParametersFrom(addElecFieldCmd,fpCommand);
2034 }                                                2027 }
2035                                                  2028 
2036 G4VisCommandSceneAddMagneticField::~G4VisComm    2029 G4VisCommandSceneAddMagneticField::~G4VisCommandSceneAddMagneticField () {
2037   delete fpCommand;                              2030   delete fpCommand;
2038 }                                                2031 }
2039                                                  2032 
2040 G4String G4VisCommandSceneAddMagneticField::G    2033 G4String G4VisCommandSceneAddMagneticField::GetCurrentValue (G4UIcommand*) {
2041   return "";                                     2034   return "";
2042 }                                                2035 }
2043                                                  2036 
2044 void G4VisCommandSceneAddMagneticField::SetNe    2037 void G4VisCommandSceneAddMagneticField::SetNewValue
2045 (G4UIcommand*, G4String newValue) {              2038 (G4UIcommand*, G4String newValue) {
2046                                                  2039 
2047   G4VisManager::Verbosity verbosity = fpVisMa    2040   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2048   G4bool warn(verbosity >= G4VisManager::warn    2041   G4bool warn(verbosity >= G4VisManager::warnings);
2049                                                  2042 
2050   G4Scene* pScene = fpVisManager->GetCurrentS    2043   G4Scene* pScene = fpVisManager->GetCurrentScene();
2051   if (!pScene) {                                 2044   if (!pScene) {
2052     if (verbosity >= G4VisManager::errors) {     2045     if (verbosity >= G4VisManager::errors) {
2053       G4warn <<  "ERROR: No current scene.  P << 2046       G4cerr <<  "ERROR: No current scene.  Please create one." << G4endl;
2054     }                                            2047     }
2055     return;                                      2048     return;
2056   }                                              2049   }
2057                                                  2050 
2058   G4int nDataPointsPerHalfScene;                 2051   G4int nDataPointsPerHalfScene;
2059   G4String representation;                       2052   G4String representation;
2060   std::istringstream iss(newValue);              2053   std::istringstream iss(newValue);
2061   iss >> nDataPointsPerHalfScene >> represent    2054   iss >> nDataPointsPerHalfScene >> representation;
2062   G4ElectricFieldModel::Representation           2055   G4ElectricFieldModel::Representation
2063   modelRepresentation = G4ElectricFieldModel:    2056   modelRepresentation = G4ElectricFieldModel::fullArrow;
2064   if (representation == "lightArrow") {          2057   if (representation == "lightArrow") {
2065     modelRepresentation = G4ElectricFieldMode    2058     modelRepresentation = G4ElectricFieldModel::lightArrow;
2066   }                                              2059   }
2067   G4VModel* model;                               2060   G4VModel* model;
2068   model = new G4MagneticFieldModel               2061   model = new G4MagneticFieldModel
2069   (nDataPointsPerHalfScene,modelRepresentatio    2062   (nDataPointsPerHalfScene,modelRepresentation,
2070    fCurrentArrow3DLineSegmentsPerCircle,         2063    fCurrentArrow3DLineSegmentsPerCircle,
2071    fCurrentExtentForField,                       2064    fCurrentExtentForField,
2072    fCurrrentPVFindingsForField);                 2065    fCurrrentPVFindingsForField);
2073   const G4String& currentSceneName = pScene -    2066   const G4String& currentSceneName = pScene -> GetName ();
2074   G4bool successful = pScene -> AddRunDuratio    2067   G4bool successful = pScene -> AddRunDurationModel (model, warn);
2075   if (successful) {                              2068   if (successful) {
2076     if (verbosity >= G4VisManager::confirmati    2069     if (verbosity >= G4VisManager::confirmations) {
2077       G4cout                                     2070       G4cout
2078       << "Magnetic field, if any, will be dra    2071       << "Magnetic field, if any, will be drawn in scene \""
2079       << currentSceneName                        2072       << currentSceneName
2080       << "\"\n  with "                           2073       << "\"\n  with "
2081       << nDataPointsPerHalfScene                 2074       << nDataPointsPerHalfScene
2082       << " data points per half extent and wi    2075       << " data points per half extent and with representation \""
2083       << representation                          2076       << representation
2084       << '\"'                                    2077       << '\"'
2085       << G4endl;                                 2078       << G4endl;
2086     }                                            2079     }
2087   }                                              2080   }
2088   else G4VisCommandsSceneAddUnsuccessful(verb    2081   else G4VisCommandsSceneAddUnsuccessful(verbosity);
2089                                                  2082 
2090   CheckSceneAndNotifyHandlers (pScene);          2083   CheckSceneAndNotifyHandlers (pScene);
2091 }                                                2084 }
2092                                                  2085 
2093 ////////////// /vis/scene/add/psHits ////////    2086 ////////////// /vis/scene/add/psHits ///////////////////////////////////////
2094                                                  2087 
2095 G4VisCommandSceneAddPSHits::G4VisCommandScene    2088 G4VisCommandSceneAddPSHits::G4VisCommandSceneAddPSHits () {
2096   G4bool omitable;                               2089   G4bool omitable;
2097   fpCommand = new G4UIcmdWithAString ("/vis/s    2090   fpCommand = new G4UIcmdWithAString ("/vis/scene/add/psHits", this);
2098   fpCommand -> SetGuidance                       2091   fpCommand -> SetGuidance
2099     ("Adds Primitive Scorer Hits (PSHits) to     2092     ("Adds Primitive Scorer Hits (PSHits) to current scene.");
2100   fpCommand -> SetGuidance                       2093   fpCommand -> SetGuidance
2101     ("PSHits are drawn at end of run when the    2094     ("PSHits are drawn at end of run when the scene in which"
2102      "\nthey are added is current.");            2095      "\nthey are added is current.");
2103   fpCommand -> SetGuidance                       2096   fpCommand -> SetGuidance
2104     ("Optional parameter specifies name of sc    2097     ("Optional parameter specifies name of scoring map.  By default all"
2105      "\nscoring maps registered with the G4Sc    2098      "\nscoring maps registered with the G4ScoringManager are drawn.");
2106   fpCommand -> SetParameterName ("mapname", o    2099   fpCommand -> SetParameterName ("mapname", omitable = true);
2107   fpCommand -> SetDefaultValue ("all");          2100   fpCommand -> SetDefaultValue ("all");
2108 }                                                2101 }
2109                                                  2102 
2110 G4VisCommandSceneAddPSHits::~G4VisCommandScen    2103 G4VisCommandSceneAddPSHits::~G4VisCommandSceneAddPSHits () {
2111   delete fpCommand;                              2104   delete fpCommand;
2112 }                                                2105 }
2113                                                  2106 
2114 G4String G4VisCommandSceneAddPSHits::GetCurre    2107 G4String G4VisCommandSceneAddPSHits::GetCurrentValue (G4UIcommand*) {
2115   return "";                                     2108   return "";
2116 }                                                2109 }
2117                                                  2110 
2118 void G4VisCommandSceneAddPSHits::SetNewValue     2111 void G4VisCommandSceneAddPSHits::SetNewValue
2119 (G4UIcommand*, G4String newValue)                2112 (G4UIcommand*, G4String newValue)
2120 {                                                2113 {
2121   G4VisManager::Verbosity verbosity = fpVisMa    2114   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2122   G4bool warn(verbosity >= G4VisManager::warn    2115   G4bool warn(verbosity >= G4VisManager::warnings);
2123                                                  2116 
2124   G4Scene* pScene = fpVisManager->GetCurrentS    2117   G4Scene* pScene = fpVisManager->GetCurrentScene();
2125   if (!pScene) {                                 2118   if (!pScene) {
2126     if (verbosity >= G4VisManager::errors) {     2119     if (verbosity >= G4VisManager::errors) {
2127       G4warn << "ERROR: No current scene.  Pl << 2120       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
2128     }                                            2121     }
2129     return;                                      2122     return;
2130   }                                              2123   }
2131                                                  2124 
2132   G4VModel* model = new G4PSHitsModel(newValu    2125   G4VModel* model = new G4PSHitsModel(newValue);
2133   const G4String& currentSceneName = pScene -    2126   const G4String& currentSceneName = pScene -> GetName ();
2134   G4bool successful = pScene -> AddEndOfRunMo    2127   G4bool successful = pScene -> AddEndOfRunModel (model, warn);
2135   if (successful) {                              2128   if (successful) {
2136     if (verbosity >= G4VisManager::confirmati    2129     if (verbosity >= G4VisManager::confirmations) {
2137       if (newValue == "all") {                   2130       if (newValue == "all") {
2138   G4cout << "All Primitive Scorer hits";         2131   G4cout << "All Primitive Scorer hits";
2139       } else {                                   2132       } else {
2140   G4cout << "Hits of Primitive Scorer \"" <<     2133   G4cout << "Hits of Primitive Scorer \"" << newValue << '"';
2141       }                                          2134       }
2142       G4cout << " will be drawn at end of run    2135       G4cout << " will be drawn at end of run in scene \""
2143        << currentSceneName << "\"."              2136        << currentSceneName << "\"."
2144        << G4endl;                                2137        << G4endl;
2145     }                                            2138     }
2146   }                                              2139   }
2147   else G4VisCommandsSceneAddUnsuccessful(verb    2140   else G4VisCommandsSceneAddUnsuccessful(verbosity);
2148                                                  2141 
2149   CheckSceneAndNotifyHandlers (pScene);          2142   CheckSceneAndNotifyHandlers (pScene);
2150 }                                                2143 }
2151                                                  2144 
2152 ////////////// /vis/scene/add/scale /////////    2145 ////////////// /vis/scene/add/scale //////////////////////////////////
2153                                                  2146 
2154 G4VisCommandSceneAddScale::G4VisCommandSceneA    2147 G4VisCommandSceneAddScale::G4VisCommandSceneAddScale () {
2155   G4bool omitable;                               2148   G4bool omitable;
2156   fpCommand = new G4UIcommand ("/vis/scene/ad    2149   fpCommand = new G4UIcommand ("/vis/scene/add/scale", this);
2157   fpCommand -> SetGuidance                       2150   fpCommand -> SetGuidance
2158   ("Adds an annotated scale line to the curre    2151   ("Adds an annotated scale line to the current scene.");
2159   fpCommand -> SetGuidance                       2152   fpCommand -> SetGuidance
2160   ("If \"unit\" is \"auto\", length is roughl    2153   ("If \"unit\" is \"auto\", length is roughly one tenth of the scene extent.");
2161   fpCommand -> SetGuidance                       2154   fpCommand -> SetGuidance
2162   ("If \"direction\" is \"auto\", scale is ro    2155   ("If \"direction\" is \"auto\", scale is roughly in the plane of the current view.");
2163   fpCommand -> SetGuidance                       2156   fpCommand -> SetGuidance
2164   ("If \"placement\" is \"auto\", scale is pl    2157   ("If \"placement\" is \"auto\", scale is placed at bottom left of current view."
2165    "\n  Otherwise placed at (xmid,ymid,zmid).    2158    "\n  Otherwise placed at (xmid,ymid,zmid).");
2166   fpCommand -> SetGuidance                       2159   fpCommand -> SetGuidance
2167   ("An annotated line in the specified direct    2160   ("An annotated line in the specified direction with tick marks at the"
2168    "\nend.  If autoPlacing is true it is requ    2161    "\nend.  If autoPlacing is true it is required to be centred at the"
2169    "\nfront, right, bottom corner of the worl    2162    "\nfront, right, bottom corner of the world space, comfortably outside"
2170    "\nthe existing bounding box/sphere so tha    2163    "\nthe existing bounding box/sphere so that existing objects do not"
2171    "\nobscure it.  Otherwise it is required t    2164    "\nobscure it.  Otherwise it is required to be drawn with mid-point at"
2172    "\n(xmid, ymid, zmid)."                       2165    "\n(xmid, ymid, zmid)."
2173    "\n"                                          2166    "\n"
2174    "\nThe auto placing algorithm is (approx):    2167    "\nThe auto placing algorithm is (approx):"
2175    "\n  x = xmin + (1 + comfort) * (xmax - xm    2168    "\n  x = xmin + (1 + comfort) * (xmax - xmin);"
2176    "\n  y = ymin - comfort * (ymax - ymin);"     2169    "\n  y = ymin - comfort * (ymax - ymin);"
2177    "\n  z = zmin + (1 + comfort) * (zmax - zm    2170    "\n  z = zmin + (1 + comfort) * (zmax - zmin);"
2178    "\n  if direction == x then (x - length,y,    2171    "\n  if direction == x then (x - length,y,z) to (x,y,z);"
2179    "\n  if direction == y then (x,y,z) to (x,    2172    "\n  if direction == y then (x,y,z) to (x,y + length,z);"
2180    "\n  if direction == z then (x,y,z - lengt    2173    "\n  if direction == z then (x,y,z - length) to (x,y,z);"
2181    );                                            2174    );
2182   G4UIparameter* parameter;                      2175   G4UIparameter* parameter;
2183   parameter = new G4UIparameter ("length", 'd    2176   parameter = new G4UIparameter ("length", 'd', omitable = true);
2184   parameter->SetDefaultValue (1.);               2177   parameter->SetDefaultValue (1.);
2185   fpCommand->SetParameter (parameter);           2178   fpCommand->SetParameter (parameter);
2186   parameter =  new G4UIparameter ("unit", 's'    2179   parameter =  new G4UIparameter ("unit", 's', omitable = true);
2187   parameter->SetDefaultValue ("auto");           2180   parameter->SetDefaultValue ("auto");
2188   fpCommand->SetParameter (parameter);           2181   fpCommand->SetParameter (parameter);
2189   parameter =  new G4UIparameter ("direction"    2182   parameter =  new G4UIparameter ("direction", 's', omitable = true);
2190   parameter->SetGuidance ("auto|x|y|z");         2183   parameter->SetGuidance ("auto|x|y|z");
2191   parameter->SetDefaultValue ("auto");           2184   parameter->SetDefaultValue ("auto");
2192   fpCommand->SetParameter (parameter);           2185   fpCommand->SetParameter (parameter);
2193   parameter =  new G4UIparameter ("red", 'd',    2186   parameter =  new G4UIparameter ("red", 'd', omitable = true);
2194   parameter->SetDefaultValue (1.);               2187   parameter->SetDefaultValue (1.);
2195   fpCommand->SetParameter (parameter);           2188   fpCommand->SetParameter (parameter);
2196   parameter =  new G4UIparameter ("green", 'd    2189   parameter =  new G4UIparameter ("green", 'd', omitable = true);
2197   parameter->SetDefaultValue (0.);               2190   parameter->SetDefaultValue (0.);
2198   fpCommand->SetParameter (parameter);           2191   fpCommand->SetParameter (parameter);
2199   parameter =  new G4UIparameter ("blue", 'd'    2192   parameter =  new G4UIparameter ("blue", 'd', omitable = true);
2200   parameter->SetDefaultValue (0.);               2193   parameter->SetDefaultValue (0.);
2201   fpCommand->SetParameter (parameter);           2194   fpCommand->SetParameter (parameter);
2202   parameter =  new G4UIparameter ("placement"    2195   parameter =  new G4UIparameter ("placement", 's', omitable = true);
2203   parameter -> SetParameterCandidates("auto m    2196   parameter -> SetParameterCandidates("auto manual");
2204   parameter->SetDefaultValue  ("auto");          2197   parameter->SetDefaultValue  ("auto");
2205   fpCommand->SetParameter     (parameter);       2198   fpCommand->SetParameter     (parameter);
2206   parameter =  new G4UIparameter ("xmid", 'd'    2199   parameter =  new G4UIparameter ("xmid", 'd', omitable = true);
2207   parameter->SetDefaultValue (0.);               2200   parameter->SetDefaultValue (0.);
2208   fpCommand->SetParameter (parameter);           2201   fpCommand->SetParameter (parameter);
2209   parameter =  new G4UIparameter ("ymid", 'd'    2202   parameter =  new G4UIparameter ("ymid", 'd', omitable = true);
2210   parameter->SetDefaultValue (0.);               2203   parameter->SetDefaultValue (0.);
2211   fpCommand->SetParameter (parameter);           2204   fpCommand->SetParameter (parameter);
2212   parameter =  new G4UIparameter ("zmid", 'd'    2205   parameter =  new G4UIparameter ("zmid", 'd', omitable = true);
2213   parameter->SetDefaultValue (0.);               2206   parameter->SetDefaultValue (0.);
2214   fpCommand->SetParameter (parameter);           2207   fpCommand->SetParameter (parameter);
2215   parameter =  new G4UIparameter ("unit", 's'    2208   parameter =  new G4UIparameter ("unit", 's', omitable = true);
2216   parameter->SetDefaultValue ("m");              2209   parameter->SetDefaultValue ("m");
2217   fpCommand->SetParameter (parameter);           2210   fpCommand->SetParameter (parameter);
2218 }                                                2211 }
2219                                                  2212 
2220 G4VisCommandSceneAddScale::~G4VisCommandScene    2213 G4VisCommandSceneAddScale::~G4VisCommandSceneAddScale () {
2221   delete fpCommand;                              2214   delete fpCommand;
2222 }                                                2215 }
2223                                                  2216 
2224 G4String G4VisCommandSceneAddScale::GetCurren    2217 G4String G4VisCommandSceneAddScale::GetCurrentValue (G4UIcommand*) {
2225   return "";                                     2218   return "";
2226 }                                                2219 }
2227                                                  2220 
2228 void G4VisCommandSceneAddScale::SetNewValue (    2221 void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
2229                                                  2222 
2230   G4VisManager::Verbosity verbosity = fpVisMa    2223   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2231   G4bool warn = verbosity >= G4VisManager::wa    2224   G4bool warn = verbosity >= G4VisManager::warnings;
2232                                                  2225 
2233   G4Scene* pScene = fpVisManager->GetCurrentS    2226   G4Scene* pScene = fpVisManager->GetCurrentScene();
2234   if (!pScene) {                                 2227   if (!pScene) {
2235     if (verbosity >= G4VisManager::errors) {     2228     if (verbosity >= G4VisManager::errors) {
2236       G4warn << "ERROR: No current scene.  Pl << 2229       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
2237     }                                            2230     }
2238     return;                                      2231     return;
2239   } else {                                       2232   } else {
2240     if (pScene->GetExtent().GetExtentRadius()    2233     if (pScene->GetExtent().GetExtentRadius() <= 0.) {
2241       if (verbosity >= G4VisManager::errors)     2234       if (verbosity >= G4VisManager::errors) {
2242         G4warn                                << 2235         G4cerr
2243   << "ERROR: Scene has no extent. Add volumes    2236   << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
2244         << G4endl;                               2237         << G4endl;
2245       }                                          2238       }
2246       return;                                    2239       return;
2247     }                                            2240     }
2248   }                                              2241   }
2249                                                  2242 
2250   G4double userLength, red, green, blue, xmid    2243   G4double userLength, red, green, blue, xmid, ymid, zmid;
2251   G4String userLengthUnit, direction, placeme    2244   G4String userLengthUnit, direction, placement, positionUnit;
2252   std::istringstream is (newValue);              2245   std::istringstream is (newValue);
2253   is >> userLength >> userLengthUnit >> direc    2246   is >> userLength >> userLengthUnit >> direction
2254      >> red >> green >> blue                     2247      >> red >> green >> blue
2255      >> placement                                2248      >> placement
2256      >> xmid >> ymid >> zmid >> positionUnit;    2249      >> xmid >> ymid >> zmid >> positionUnit;
2257                                                  2250 
2258   G4double length = userLength;                  2251   G4double length = userLength;
2259   const G4VisExtent& sceneExtent = pScene->Ge    2252   const G4VisExtent& sceneExtent = pScene->GetExtent();  // Existing extent.
2260   if (userLengthUnit == "auto") {                2253   if (userLengthUnit == "auto") {
2261     const G4double lengthMax = 0.5 * sceneExt    2254     const G4double lengthMax = 0.5 * sceneExtent.GetExtentRadius();
2262     const G4double intLog10Length = std::floo    2255     const G4double intLog10Length = std::floor(std::log10(lengthMax));
2263     length = std::pow(10,intLog10Length);        2256     length = std::pow(10,intLog10Length);
2264     if (5.*length < lengthMax) length *= 5.;     2257     if (5.*length < lengthMax) length *= 5.;
2265     else if (2.*length < lengthMax) length *=    2258     else if (2.*length < lengthMax) length *= 2.;
2266   } else {                                       2259   } else {
2267     length *= G4UIcommand::ValueOf(userLength    2260     length *= G4UIcommand::ValueOf(userLengthUnit);
2268   }                                              2261   }
2269   G4String annotation = G4BestUnit(length,"Le    2262   G4String annotation = G4BestUnit(length,"Length");
2270                                                  2263 
2271   G4double unit = G4UIcommand::ValueOf(positi    2264   G4double unit = G4UIcommand::ValueOf(positionUnit);
2272   xmid *= unit; ymid *= unit; zmid *= unit;      2265   xmid *= unit; ymid *= unit; zmid *= unit;
2273                                                  2266 
2274   Scale::Direction scaleDirection (Scale::x);    2267   Scale::Direction scaleDirection (Scale::x);
2275   if (direction[0] == 'y') scaleDirection = S    2268   if (direction[0] == 'y') scaleDirection = Scale::y;
2276   if (direction[0] == 'z') scaleDirection = S    2269   if (direction[0] == 'z') scaleDirection = Scale::z;
2277                                                  2270 
2278   G4VViewer* pViewer = fpVisManager->GetCurre    2271   G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
2279   if (!pViewer) {                                2272   if (!pViewer) {
2280     if (verbosity >= G4VisManager::errors) {     2273     if (verbosity >= G4VisManager::errors) {
2281       G4warn <<                               << 2274       G4cerr <<
2282   "ERROR: G4VisCommandSceneAddScale::SetNewVa    2275   "ERROR: G4VisCommandSceneAddScale::SetNewValue: no viewer."
2283   "\n  Auto direction needs a viewer."           2276   "\n  Auto direction needs a viewer."
2284        << G4endl;                                2277        << G4endl;
2285     }                                            2278     }
2286     return;                                      2279     return;
2287   }                                              2280   }
2288                                                  2281 
2289   const G4Vector3D& vp =                         2282   const G4Vector3D& vp =
2290     pViewer->GetViewParameters().GetViewpoint    2283     pViewer->GetViewParameters().GetViewpointDirection();
2291   const G4Vector3D& up =                         2284   const G4Vector3D& up =
2292     pViewer->GetViewParameters().GetUpVector(    2285     pViewer->GetViewParameters().GetUpVector();
2293                                                  2286 
2294   if (direction == "auto") {  // Takes cue fr    2287   if (direction == "auto") {  // Takes cue from viewer.
2295     if (std::abs(vp.x()) > std::abs(vp.y()) &    2288     if (std::abs(vp.x()) > std::abs(vp.y()) &&
2296   std::abs(vp.x()) > std::abs(vp.z())) {  //     2289   std::abs(vp.x()) > std::abs(vp.z())) {  // x viewpoint
2297       if (std::abs(up.y()) > std::abs(up.z())    2290       if (std::abs(up.y()) > std::abs(up.z())) scaleDirection = Scale::z;
2298     else scaleDirection = Scale::y;              2291     else scaleDirection = Scale::y;
2299     }                                            2292     }
2300     else if (std::abs(vp.y()) > std::abs(vp.x    2293     else if (std::abs(vp.y()) > std::abs(vp.x()) &&
2301        std::abs(vp.y()) > std::abs(vp.z())) {    2294        std::abs(vp.y()) > std::abs(vp.z())) {  // y viewpoint
2302       if (std::abs(up.x()) > std::abs(up.z())    2295       if (std::abs(up.x()) > std::abs(up.z())) scaleDirection = Scale::z;
2303     else scaleDirection = Scale::x;              2296     else scaleDirection = Scale::x;
2304     }                                            2297     }
2305     else if (std::abs(vp.z()) > std::abs(vp.x    2298     else if (std::abs(vp.z()) > std::abs(vp.x()) &&
2306        std::abs(vp.z()) > std::abs(vp.y())) {    2299        std::abs(vp.z()) > std::abs(vp.y())) {  // z viewpoint
2307       if (std::abs(up.y()) > std::abs(up.x())    2300       if (std::abs(up.y()) > std::abs(up.x())) scaleDirection = Scale::x;
2308     else scaleDirection = Scale::y;              2301     else scaleDirection = Scale::y;
2309     }                                            2302     }
2310   }                                              2303   }
2311                                                  2304 
2312   G4bool autoPlacing = false; if (placement =    2305   G4bool autoPlacing = false; if (placement == "auto") autoPlacing = true;
2313   // Parameters read and interpreted.            2306   // Parameters read and interpreted.
2314                                                  2307 
2315   // Useful constants, etc...                    2308   // Useful constants, etc...
2316   const G4double halfLength(length / 2.);        2309   const G4double halfLength(length / 2.);
2317   const G4double comfort(0.01);  // 0.15 seem    2310   const G4double comfort(0.01);  // 0.15 seems too big.  0.05 might be better.
2318   const G4double freeLengthFraction (1. + 2.     2311   const G4double freeLengthFraction (1. + 2. * comfort);
2319                                                  2312 
2320   const G4double xmin = sceneExtent.GetXmin()    2313   const G4double xmin = sceneExtent.GetXmin();
2321   const G4double xmax = sceneExtent.GetXmax()    2314   const G4double xmax = sceneExtent.GetXmax();
2322   const G4double ymin = sceneExtent.GetYmin()    2315   const G4double ymin = sceneExtent.GetYmin();
2323   const G4double ymax = sceneExtent.GetYmax()    2316   const G4double ymax = sceneExtent.GetYmax();
2324   const G4double zmin = sceneExtent.GetZmin()    2317   const G4double zmin = sceneExtent.GetZmin();
2325   const G4double zmax = sceneExtent.GetZmax()    2318   const G4double zmax = sceneExtent.GetZmax();
2326                                                  2319 
2327   // Test existing extent and issue warnings.    2320   // Test existing extent and issue warnings...
2328   G4bool worried = false;                        2321   G4bool worried = false;
2329   if (sceneExtent.GetExtentRadius() == 0) {      2322   if (sceneExtent.GetExtentRadius() == 0) {
2330     worried = true;                              2323     worried = true;
2331     if (verbosity >= G4VisManager::warnings)     2324     if (verbosity >= G4VisManager::warnings) {
2332       G4warn <<                               << 2325       G4cout <<
2333   "WARNING: Existing scene does not yet have     2326   "WARNING: Existing scene does not yet have any extent."
2334   "\n  Maybe you have not yet added any geome    2327   "\n  Maybe you have not yet added any geometrical object."
2335        << G4endl;                                2328        << G4endl;
2336     }                                            2329     }
2337   }                                              2330   }
2338                                                  2331 
2339   // Test existing scene for room...             2332   // Test existing scene for room...
2340   G4bool room  = true;                           2333   G4bool room  = true;
2341   switch (scaleDirection) {                      2334   switch (scaleDirection) {
2342   case Scale::x:                                 2335   case Scale::x:
2343     if (freeLengthFraction * (xmax - xmin) <     2336     if (freeLengthFraction * (xmax - xmin) < length) room = false;
2344     break;                                       2337     break;
2345   case Scale::y:                                 2338   case Scale::y:
2346     if (freeLengthFraction * (ymax - ymin) <     2339     if (freeLengthFraction * (ymax - ymin) < length) room = false;
2347     break;                                       2340     break;
2348   case Scale::z:                                 2341   case Scale::z:
2349     if (freeLengthFraction * (zmax - zmin) <     2342     if (freeLengthFraction * (zmax - zmin) < length) room = false;
2350     break;                                       2343     break;
2351   }                                              2344   }
2352   if (!room) {                                   2345   if (!room) {
2353     worried = true;                              2346     worried = true;
2354     if (verbosity >= G4VisManager::warnings)     2347     if (verbosity >= G4VisManager::warnings) {
2355       G4warn <<                               << 2348       G4cout <<
2356   "WARNING: Not enough room in existing scene    2349   "WARNING: Not enough room in existing scene.  Maybe scale is too long."
2357        << G4endl;                                2350        << G4endl;
2358     }                                            2351     }
2359   }                                              2352   }
2360   if (worried) {                                 2353   if (worried) {
2361     if (verbosity >= G4VisManager::warnings)     2354     if (verbosity >= G4VisManager::warnings) {
2362       G4warn <<                               << 2355       G4cout <<
2363   "WARNING: The scale you have asked for is b    2356   "WARNING: The scale you have asked for is bigger than the existing"
2364   "\n  scene.  Maybe you have added it too so    2357   "\n  scene.  Maybe you have added it too soon.  It is recommended that"
2365   "\n  you add the scale last so that it can     2358   "\n  you add the scale last so that it can be correctly auto-positioned"
2366   "\n  so as not to be obscured by any existi    2359   "\n  so as not to be obscured by any existing object and so that the"
2367   "\n  view parameters can be correctly recal    2360   "\n  view parameters can be correctly recalculated."
2368        << G4endl;                                2361        << G4endl;
2369     }                                            2362     }
2370   }                                              2363   }
2371                                                  2364 
2372   // Now figure out the extent...                2365   // Now figure out the extent...
2373   //                                             2366   //
2374   // This creates a representation of annotat    2367   // This creates a representation of annotated line in the specified
2375   // direction with tick marks at the end.  I    2368   // direction with tick marks at the end.  If autoPlacing is true it
2376   // is required to be centred at the front,     2369   // is required to be centred at the front, right, bottom corner of
2377   // the world space, comfortably outside the    2370   // the world space, comfortably outside the existing bounding
2378   // box/sphere so that existing objects do n    2371   // box/sphere so that existing objects do not obscure it.  Otherwise
2379   // it is required to be drawn with mid-poin    2372   // it is required to be drawn with mid-point at (xmid, ymid, zmid).
2380   //                                             2373   //
2381   // The auto placing algorithm might be:        2374   // The auto placing algorithm might be:
2382   //   x = xmin + (1 + comfort) * (xmax - xmi    2375   //   x = xmin + (1 + comfort) * (xmax - xmin)
2383   //   y = ymin - comfort * (ymax - ymin)        2376   //   y = ymin - comfort * (ymax - ymin)
2384   //   z = zmin + (1 + comfort) * (zmax - zmi    2377   //   z = zmin + (1 + comfort) * (zmax - zmin)
2385   //   if direction == x then (x - length,y,z    2378   //   if direction == x then (x - length,y,z) to (x,y,z)
2386   //   if direction == y then (x,y,z) to (x,y    2379   //   if direction == y then (x,y,z) to (x,y + length,z)
2387   //   if direction == z then (x,y,z - length    2380   //   if direction == z then (x,y,z - length) to (x,y,z)
2388   //                                             2381   //
2389   // Implement this in two parts.  Here, use     2382   // Implement this in two parts.  Here, use the scale's extent to
2390   // "expand" the scene's extent.  Then rende    2383   // "expand" the scene's extent.  Then rendering - in
2391   // G4VSceneHandler::AddPrimitive(const G4Sc    2384   // G4VSceneHandler::AddPrimitive(const G4Scale&) - simply has to
2392   // ensure it's within the new extent.          2385   // ensure it's within the new extent.
2393   //                                             2386   //
2394                                                  2387 
2395   G4double sxmid(xmid), symid(ymid), szmid(zm    2388   G4double sxmid(xmid), symid(ymid), szmid(zmid);
2396   if (autoPlacing) {                             2389   if (autoPlacing) {
2397     // Aim to place at bottom right of screen    2390     // Aim to place at bottom right of screen in current view.
2398     // Give some comfort zone.                   2391     // Give some comfort zone.
2399     const G4double xComfort = comfort * (xmax    2392     const G4double xComfort = comfort * (xmax - xmin);
2400     const G4double yComfort = comfort * (ymax    2393     const G4double yComfort = comfort * (ymax - ymin);
2401     const G4double zComfort = comfort * (zmax    2394     const G4double zComfort = comfort * (zmax - zmin);
2402     switch (scaleDirection) {                    2395     switch (scaleDirection) {
2403     case Scale::x:                               2396     case Scale::x:
2404       if (vp.z() > 0.) {                         2397       if (vp.z() > 0.) {
2405   sxmid = xmax + xComfort;                       2398   sxmid = xmax + xComfort;
2406   symid = ymin - yComfort;                       2399   symid = ymin - yComfort;
2407   szmid = zmin - zComfort;                       2400   szmid = zmin - zComfort;
2408       } else {                                   2401       } else {
2409   sxmid = xmin - xComfort;                       2402   sxmid = xmin - xComfort;
2410   symid = ymin - yComfort;                       2403   symid = ymin - yComfort;
2411   szmid = zmax + zComfort;                       2404   szmid = zmax + zComfort;
2412       }                                          2405       }
2413       break;                                     2406       break;
2414     case Scale::y:                               2407     case Scale::y:
2415       if (vp.x() > 0.) {                         2408       if (vp.x() > 0.) {
2416   sxmid = xmin - xComfort;                       2409   sxmid = xmin - xComfort;
2417   symid = ymax + yComfort;                       2410   symid = ymax + yComfort;
2418   szmid = zmin - zComfort;                       2411   szmid = zmin - zComfort;
2419       } else {                                   2412       } else {
2420   sxmid = xmax + xComfort;                       2413   sxmid = xmax + xComfort;
2421   symid = ymin - yComfort;                       2414   symid = ymin - yComfort;
2422   szmid = zmin - zComfort;                       2415   szmid = zmin - zComfort;
2423       }                                          2416       }
2424       break;                                     2417       break;
2425     case Scale::z:                               2418     case Scale::z:
2426       if (vp.x() > 0.) {                         2419       if (vp.x() > 0.) {
2427   sxmid = xmax + xComfort;                       2420   sxmid = xmax + xComfort;
2428   symid = ymin - yComfort;                       2421   symid = ymin - yComfort;
2429   szmid = zmax + zComfort;                       2422   szmid = zmax + zComfort;
2430       } else {                                   2423       } else {
2431   sxmid = xmin - xComfort;                       2424   sxmid = xmin - xComfort;
2432   symid = ymin - yComfort;                       2425   symid = ymin - yComfort;
2433   szmid = zmax + zComfort;                       2426   szmid = zmax + zComfort;
2434       }                                          2427       }
2435       break;                                     2428       break;
2436     }                                            2429     }
2437   }                                              2430   }
2438                                                  2431 
2439   G4Transform3D transform;                       2432   G4Transform3D transform;
2440   const G4double h = halfLength;                 2433   const G4double h = halfLength;
2441   const G4double t = h/5.;                       2434   const G4double t = h/5.;
2442   G4VisExtent scaleExtent(-h,h,-t,t,-t,t);       2435   G4VisExtent scaleExtent(-h,h,-t,t,-t,t);
2443   switch (scaleDirection) {                      2436   switch (scaleDirection) {
2444   case Scale::x:                                 2437   case Scale::x:
2445     break;                                       2438     break;
2446   case Scale::y:                                 2439   case Scale::y:
2447     transform = G4RotateZ3D(halfpi);             2440     transform = G4RotateZ3D(halfpi);
2448     break;                                       2441     break;
2449   case Scale::z:                                 2442   case Scale::z:
2450     transform = G4RotateY3D(halfpi);             2443     transform = G4RotateY3D(halfpi);
2451     break;                                       2444     break;
2452   }                                              2445   }
2453   transform = G4Translate3D(sxmid,symid,szmid    2446   transform = G4Translate3D(sxmid,symid,szmid) * transform;
2454   scaleExtent = scaleExtent.Transform(transfo    2447   scaleExtent = scaleExtent.Transform(transform);
2455                                                  2448 
2456   G4Colour colour(red, green, blue);             2449   G4Colour colour(red, green, blue);
2457   if (direction == "auto") {                     2450   if (direction == "auto") {
2458     switch (scaleDirection) {                    2451     switch (scaleDirection) {
2459       case Scale::x:                             2452       case Scale::x:
2460   colour = G4Colour::Red();                      2453   colour = G4Colour::Red();
2461   break;                                         2454   break;
2462       case Scale::y:                             2455       case Scale::y:
2463   colour = G4Colour::Green();                    2456   colour = G4Colour::Green();
2464   break;                                         2457   break;
2465       case Scale::z:                             2458       case Scale::z:
2466   colour = G4Colour::Blue();                     2459   colour = G4Colour::Blue();
2467   break;                                         2460   break;
2468     }                                            2461     }
2469   }                                              2462   }
2470   G4VisAttributes visAttr(colour);               2463   G4VisAttributes visAttr(colour);
2471                                                  2464 
2472   Scale* scale = new Scale                       2465   Scale* scale = new Scale
2473   (visAttr, length, transform,                   2466   (visAttr, length, transform,
2474    annotation, fCurrentTextSize, colour);        2467    annotation, fCurrentTextSize, colour);
2475   G4VModel* model = new G4CallbackModel<Scale    2468   G4VModel* model = new G4CallbackModel<Scale>(scale);
2476   model->SetType("Scale");                       2469   model->SetType("Scale");
2477   model->SetGlobalTag("Scale");                  2470   model->SetGlobalTag("Scale");
2478   model->SetGlobalDescription("Scale: " + new    2471   model->SetGlobalDescription("Scale: " + newValue);
2479   model->SetExtent(scaleExtent);                 2472   model->SetExtent(scaleExtent);
2480                                                  2473 
2481   const G4String& currentSceneName = pScene -    2474   const G4String& currentSceneName = pScene -> GetName ();
2482   G4bool successful = pScene -> AddRunDuratio    2475   G4bool successful = pScene -> AddRunDurationModel (model, warn);
2483   if (successful) {                              2476   if (successful) {
2484     if (verbosity >= G4VisManager::confirmati    2477     if (verbosity >= G4VisManager::confirmations) {
2485       G4cout << "Scale of " << annotation        2478       G4cout << "Scale of " << annotation
2486        << " added to scene \"" << currentScen    2479        << " added to scene \"" << currentSceneName << "\".";
2487       if (verbosity >= G4VisManager::paramete    2480       if (verbosity >= G4VisManager::parameters) {
2488   G4cout << "\n  with extent " << scaleExtent    2481   G4cout << "\n  with extent " << scaleExtent
2489          << "\n  at " << transform.getRotatio    2482          << "\n  at " << transform.getRotation()
2490          << "  " << transform.getTranslation(    2483          << "  " << transform.getTranslation();
2491       }                                          2484       }
2492       G4cout << G4endl;                          2485       G4cout << G4endl;
2493     }                                            2486     }
2494   }                                              2487   }
2495   else G4VisCommandsSceneAddUnsuccessful(verb    2488   else G4VisCommandsSceneAddUnsuccessful(verbosity);
2496                                                  2489 
2497   CheckSceneAndNotifyHandlers (pScene);          2490   CheckSceneAndNotifyHandlers (pScene);
2498 }                                                2491 }
2499                                                  2492 
2500 G4VisCommandSceneAddScale::Scale::Scale          2493 G4VisCommandSceneAddScale::Scale::Scale
2501  (const G4VisAttributes& visAtts,                2494  (const G4VisAttributes& visAtts,
2502   G4double length, const G4Transform3D& trans    2495   G4double length, const G4Transform3D& transform,
2503   const G4String& annotation, G4double annota    2496   const G4String& annotation, G4double annotationSize,
2504   const G4Colour& annotationColour):             2497   const G4Colour& annotationColour):
2505 fVisAtts(visAtts)                                2498 fVisAtts(visAtts)
2506 {                                                2499 {
2507   // Useful constants...                         2500   // Useful constants...
2508   const G4double halfLength(length / 2.);        2501   const G4double halfLength(length / 2.);
2509   const G4double tickLength(length / 20.);       2502   const G4double tickLength(length / 20.);
2510                                                  2503 
2511   // Create (empty) polylines having the same    2504   // Create (empty) polylines having the same vis attributes...
2512   // (OK to pass address since fVisAtts is lo    2505   // (OK to pass address since fVisAtts is long lived.)
2513   fScaleLine.SetVisAttributes(&fVisAtts);        2506   fScaleLine.SetVisAttributes(&fVisAtts);
2514   fTick11.SetVisAttributes(&fVisAtts);           2507   fTick11.SetVisAttributes(&fVisAtts);
2515   fTick12.SetVisAttributes(&fVisAtts);           2508   fTick12.SetVisAttributes(&fVisAtts);
2516   fTick21.SetVisAttributes(&fVisAtts);           2509   fTick21.SetVisAttributes(&fVisAtts);
2517   fTick22.SetVisAttributes(&fVisAtts);           2510   fTick22.SetVisAttributes(&fVisAtts);
2518                                                  2511 
2519   // Add points to the polylines to represent    2512   // Add points to the polylines to represent a scale parallel to the
2520   // x-axis centred on the origin...             2513   // x-axis centred on the origin...
2521   G4Point3D r1(G4Point3D(-halfLength, 0., 0.)    2514   G4Point3D r1(G4Point3D(-halfLength, 0., 0.));
2522   G4Point3D r2(G4Point3D( halfLength, 0., 0.)    2515   G4Point3D r2(G4Point3D( halfLength, 0., 0.));
2523   fScaleLine.push_back(r1);                      2516   fScaleLine.push_back(r1);
2524   fScaleLine.push_back(r2);                      2517   fScaleLine.push_back(r2);
2525   G4Point3D ticky(0., tickLength, 0.);           2518   G4Point3D ticky(0., tickLength, 0.);
2526   G4Point3D tickz(0., 0., tickLength);           2519   G4Point3D tickz(0., 0., tickLength);
2527   fTick11.push_back(r1 + ticky);                 2520   fTick11.push_back(r1 + ticky);
2528   fTick11.push_back(r1 - ticky);                 2521   fTick11.push_back(r1 - ticky);
2529   fTick12.push_back(r1 + tickz);                 2522   fTick12.push_back(r1 + tickz);
2530   fTick12.push_back(r1 - tickz);                 2523   fTick12.push_back(r1 - tickz);
2531   fTick21.push_back(r2 + ticky);                 2524   fTick21.push_back(r2 + ticky);
2532   fTick21.push_back(r2 - ticky);                 2525   fTick21.push_back(r2 - ticky);
2533   fTick22.push_back(r2 + tickz);                 2526   fTick22.push_back(r2 + tickz);
2534   fTick22.push_back(r2 - tickz);                 2527   fTick22.push_back(r2 - tickz);
2535   // ...and transform to chosen position and     2528   // ...and transform to chosen position and orientation
2536   fScaleLine.transform(transform);               2529   fScaleLine.transform(transform);
2537   fTick11.transform(transform);                  2530   fTick11.transform(transform);
2538   fTick12.transform(transform);                  2531   fTick12.transform(transform);
2539   fTick21.transform(transform);                  2532   fTick21.transform(transform);
2540   fTick22.transform(transform);                  2533   fTick22.transform(transform);
2541   // Similarly for annotation                    2534   // Similarly for annotation
2542   G4Point3D textPosition(0., tickLength, 0.);    2535   G4Point3D textPosition(0., tickLength, 0.);
2543   textPosition.transform(transform);             2536   textPosition.transform(transform);
2544   fText = G4Text(annotation,textPosition);       2537   fText = G4Text(annotation,textPosition);
2545   fText.SetVisAttributes(annotationColour);      2538   fText.SetVisAttributes(annotationColour);
2546   fText.SetScreenSize(annotationSize);           2539   fText.SetScreenSize(annotationSize);
2547 }                                                2540 }
2548                                                  2541 
2549 void G4VisCommandSceneAddScale::Scale::operat    2542 void G4VisCommandSceneAddScale::Scale::operator()
2550 (G4VGraphicsScene& sceneHandler,const G4Model    2543 (G4VGraphicsScene& sceneHandler,const G4ModelingParameters*)
2551 {                                                2544 {
2552   // Draw...                                     2545   // Draw...
2553   sceneHandler.BeginPrimitives();                2546   sceneHandler.BeginPrimitives();
2554   sceneHandler.AddPrimitive(fScaleLine);         2547   sceneHandler.AddPrimitive(fScaleLine);
2555   sceneHandler.AddPrimitive(fTick11);            2548   sceneHandler.AddPrimitive(fTick11);
2556   sceneHandler.AddPrimitive(fTick12);            2549   sceneHandler.AddPrimitive(fTick12);
2557   sceneHandler.AddPrimitive(fTick21);            2550   sceneHandler.AddPrimitive(fTick21);
2558   sceneHandler.AddPrimitive(fTick22);            2551   sceneHandler.AddPrimitive(fTick22);
2559   sceneHandler.AddPrimitive(fText);              2552   sceneHandler.AddPrimitive(fText);
2560   sceneHandler.EndPrimitives();                  2553   sceneHandler.EndPrimitives();
2561 }                                                2554 }
2562                                                  2555 
2563 ////////////// /vis/scene/add/text //////////    2556 ////////////// /vis/scene/add/text //////////////////////////////////
2564                                                  2557 
2565 G4VisCommandSceneAddText::G4VisCommandSceneAd    2558 G4VisCommandSceneAddText::G4VisCommandSceneAddText () {
2566   G4bool omitable;                               2559   G4bool omitable;
2567   fpCommand = new G4UIcommand ("/vis/scene/ad    2560   fpCommand = new G4UIcommand ("/vis/scene/add/text", this);
2568   fpCommand -> SetGuidance ("Adds text to cur    2561   fpCommand -> SetGuidance ("Adds text to current scene.");
2569   fpCommand -> SetGuidance                       2562   fpCommand -> SetGuidance
2570     ("Use \"/vis/set/textColour\" to set colo    2563     ("Use \"/vis/set/textColour\" to set colour.");
2571   fpCommand -> SetGuidance                       2564   fpCommand -> SetGuidance
2572     ("Use \"/vis/set/textLayout\" to set layo    2565     ("Use \"/vis/set/textLayout\" to set layout:");
2573   G4UIparameter* parameter;                      2566   G4UIparameter* parameter;
2574   parameter = new G4UIparameter ("x", 'd', om    2567   parameter = new G4UIparameter ("x", 'd', omitable = true);
2575   parameter->SetDefaultValue (0);                2568   parameter->SetDefaultValue (0);
2576   fpCommand->SetParameter (parameter);           2569   fpCommand->SetParameter (parameter);
2577   parameter =  new G4UIparameter ("y", 'd', o    2570   parameter =  new G4UIparameter ("y", 'd', omitable = true);
2578   parameter->SetDefaultValue (0);                2571   parameter->SetDefaultValue (0);
2579   fpCommand->SetParameter (parameter);           2572   fpCommand->SetParameter (parameter);
2580   parameter =  new G4UIparameter ("z", 'd', o    2573   parameter =  new G4UIparameter ("z", 'd', omitable = true);
2581   parameter->SetDefaultValue (0);                2574   parameter->SetDefaultValue (0);
2582   fpCommand->SetParameter (parameter);           2575   fpCommand->SetParameter (parameter);
2583   parameter =  new G4UIparameter ("unit", 's'    2576   parameter =  new G4UIparameter ("unit", 's', omitable = true);
2584   parameter->SetDefaultValue ("m");              2577   parameter->SetDefaultValue ("m");
2585   fpCommand->SetParameter     (parameter);       2578   fpCommand->SetParameter     (parameter);
2586   parameter =  new G4UIparameter ("font_size"    2579   parameter =  new G4UIparameter ("font_size", 'd', omitable = true);
2587   parameter->SetDefaultValue (12);               2580   parameter->SetDefaultValue (12);
2588   parameter->SetGuidance ("pixels");             2581   parameter->SetGuidance ("pixels");
2589   fpCommand->SetParameter (parameter);           2582   fpCommand->SetParameter (parameter);
2590   parameter =  new G4UIparameter ("x_offset",    2583   parameter =  new G4UIparameter ("x_offset", 'd', omitable = true);
2591   parameter->SetDefaultValue (0);                2584   parameter->SetDefaultValue (0);
2592   parameter->SetGuidance ("pixels");             2585   parameter->SetGuidance ("pixels");
2593   fpCommand->SetParameter (parameter);           2586   fpCommand->SetParameter (parameter);
2594   parameter =  new G4UIparameter ("y_offset",    2587   parameter =  new G4UIparameter ("y_offset", 'd', omitable = true);
2595   parameter->SetDefaultValue (0);                2588   parameter->SetDefaultValue (0);
2596   parameter->SetGuidance ("pixels");             2589   parameter->SetGuidance ("pixels");
2597   fpCommand->SetParameter (parameter);           2590   fpCommand->SetParameter (parameter);
2598   parameter =  new G4UIparameter ("text", 's'    2591   parameter =  new G4UIparameter ("text", 's', omitable = true);
2599   parameter->SetGuidance ("The rest of the li    2592   parameter->SetGuidance ("The rest of the line is text.");
2600   parameter->SetDefaultValue ("Hello G4");       2593   parameter->SetDefaultValue ("Hello G4");
2601   fpCommand->SetParameter (parameter);           2594   fpCommand->SetParameter (parameter);
2602 }                                                2595 }
2603                                                  2596 
2604 G4VisCommandSceneAddText::~G4VisCommandSceneA    2597 G4VisCommandSceneAddText::~G4VisCommandSceneAddText () {
2605   delete fpCommand;                              2598   delete fpCommand;
2606 }                                                2599 }
2607                                                  2600 
2608 G4String G4VisCommandSceneAddText::GetCurrent    2601 G4String G4VisCommandSceneAddText::GetCurrentValue (G4UIcommand*) {
2609   return "";                                     2602   return "";
2610 }                                                2603 }
2611                                                  2604 
2612 void G4VisCommandSceneAddText::SetNewValue (G    2605 void G4VisCommandSceneAddText::SetNewValue (G4UIcommand*, G4String newValue) {
2613                                                  2606 
2614   G4VisManager::Verbosity verbosity = fpVisMa    2607   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2615   G4bool warn = verbosity >= G4VisManager::wa    2608   G4bool warn = verbosity >= G4VisManager::warnings;
2616                                                  2609 
2617   G4Scene* pScene = fpVisManager->GetCurrentS    2610   G4Scene* pScene = fpVisManager->GetCurrentScene();
2618   if (!pScene) {                                 2611   if (!pScene) {
2619     if (verbosity >= G4VisManager::errors) {     2612     if (verbosity >= G4VisManager::errors) {
2620       G4warn << "ERROR: No current scene.  Pl << 2613       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
2621     }                                            2614     }
2622     return;                                      2615     return;
2623   }                                              2616   }
2624                                                  2617 
2625   G4Tokenizer next(newValue);                    2618   G4Tokenizer next(newValue);
2626   G4double x = StoD(next());                     2619   G4double x = StoD(next());
2627   G4double y = StoD(next());                     2620   G4double y = StoD(next());
2628   G4double z = StoD(next());                     2621   G4double z = StoD(next());
2629   G4String unitString = next();                  2622   G4String unitString = next();
2630   G4double font_size = StoD(next());             2623   G4double font_size = StoD(next());
2631   G4double x_offset = StoD(next());              2624   G4double x_offset = StoD(next());
2632   G4double y_offset = StoD(next());              2625   G4double y_offset = StoD(next());
2633   G4String text = next("\n");                    2626   G4String text = next("\n");
2634                                                  2627 
2635   G4double unit = G4UIcommand::ValueOf(unitSt    2628   G4double unit = G4UIcommand::ValueOf(unitString);
2636   x *= unit; y *= unit; z *= unit;               2629   x *= unit; y *= unit; z *= unit;
2637                                                  2630 
2638   G4Text g4text(text, G4Point3D(x,y,z));         2631   G4Text g4text(text, G4Point3D(x,y,z));
2639   G4VisAttributes visAtts(fCurrentTextColour)    2632   G4VisAttributes visAtts(fCurrentTextColour);
2640   g4text.SetVisAttributes(visAtts);              2633   g4text.SetVisAttributes(visAtts);
2641   g4text.SetLayout(fCurrentTextLayout);          2634   g4text.SetLayout(fCurrentTextLayout);
2642   g4text.SetScreenSize(font_size);               2635   g4text.SetScreenSize(font_size);
2643   g4text.SetOffset(x_offset,y_offset);           2636   g4text.SetOffset(x_offset,y_offset);
2644   G4VModel* model = new G4TextModel(g4text);     2637   G4VModel* model = new G4TextModel(g4text);
2645   const G4String& currentSceneName = pScene -    2638   const G4String& currentSceneName = pScene -> GetName ();
2646   G4bool successful = pScene -> AddRunDuratio    2639   G4bool successful = pScene -> AddRunDurationModel (model, warn);
2647   if (successful) {                              2640   if (successful) {
2648     if (verbosity >= G4VisManager::confirmati    2641     if (verbosity >= G4VisManager::confirmations) {
2649       G4cout << "Text '" << text              << 2642       G4cout << "Text \"" << text
2650        << "' has been added to scene \"" << c << 2643        << "\" has been added to scene \"" << currentSceneName << "\"."
2651        << G4endl;                                2644        << G4endl;
2652     }                                            2645     }
2653   }                                              2646   }
2654   else G4VisCommandsSceneAddUnsuccessful(verb    2647   else G4VisCommandsSceneAddUnsuccessful(verbosity);
2655                                                  2648 
2656   CheckSceneAndNotifyHandlers (pScene);          2649   CheckSceneAndNotifyHandlers (pScene);
2657 }                                                2650 }
2658                                                  2651 
2659                                                  2652 
2660 ////////////// /vis/scene/add/text2D ////////    2653 ////////////// /vis/scene/add/text2D //////////////////////////////////
2661                                                  2654 
2662 G4VisCommandSceneAddText2D::G4VisCommandScene    2655 G4VisCommandSceneAddText2D::G4VisCommandSceneAddText2D () {
2663   G4bool omitable;                               2656   G4bool omitable;
2664   fpCommand = new G4UIcommand ("/vis/scene/ad    2657   fpCommand = new G4UIcommand ("/vis/scene/add/text2D", this);
2665   fpCommand -> SetGuidance ("Adds 2D text to     2658   fpCommand -> SetGuidance ("Adds 2D text to current scene.");
2666   fpCommand -> SetGuidance ("x,y in range [-1 << 
2667   fpCommand -> SetGuidance                       2659   fpCommand -> SetGuidance
2668     ("Use \"/vis/set/textColour\" to set colo    2660     ("Use \"/vis/set/textColour\" to set colour.");
2669   fpCommand -> SetGuidance                       2661   fpCommand -> SetGuidance
2670     ("Use \"/vis/set/textLayout\" to set layo    2662     ("Use \"/vis/set/textLayout\" to set layout:");
2671   G4UIparameter* parameter;                      2663   G4UIparameter* parameter;
2672   parameter = new G4UIparameter ("x", 'd', om    2664   parameter = new G4UIparameter ("x", 'd', omitable = true);
2673   parameter->SetDefaultValue (0);                2665   parameter->SetDefaultValue (0);
2674   fpCommand->SetParameter (parameter);           2666   fpCommand->SetParameter (parameter);
2675   parameter =  new G4UIparameter ("y", 'd', o    2667   parameter =  new G4UIparameter ("y", 'd', omitable = true);
2676   parameter->SetDefaultValue (0);                2668   parameter->SetDefaultValue (0);
2677   fpCommand->SetParameter (parameter);           2669   fpCommand->SetParameter (parameter);
2678   parameter =  new G4UIparameter ("font_size"    2670   parameter =  new G4UIparameter ("font_size", 'd', omitable = true);
2679   parameter->SetDefaultValue (12);               2671   parameter->SetDefaultValue (12);
2680   parameter->SetGuidance ("pixels");             2672   parameter->SetGuidance ("pixels");
2681   fpCommand->SetParameter (parameter);           2673   fpCommand->SetParameter (parameter);
2682   parameter =  new G4UIparameter ("x_offset",    2674   parameter =  new G4UIparameter ("x_offset", 'd', omitable = true);
2683   parameter->SetDefaultValue (0);                2675   parameter->SetDefaultValue (0);
2684   parameter->SetGuidance ("pixels");             2676   parameter->SetGuidance ("pixels");
2685   fpCommand->SetParameter (parameter);           2677   fpCommand->SetParameter (parameter);
2686   parameter =  new G4UIparameter ("y_offset",    2678   parameter =  new G4UIparameter ("y_offset", 'd', omitable = true);
2687   parameter->SetDefaultValue (0);                2679   parameter->SetDefaultValue (0);
2688   parameter->SetGuidance ("pixels");             2680   parameter->SetGuidance ("pixels");
2689   fpCommand->SetParameter (parameter);           2681   fpCommand->SetParameter (parameter);
2690   parameter =  new G4UIparameter ("text", 's'    2682   parameter =  new G4UIparameter ("text", 's', omitable = true);
2691   parameter->SetGuidance ("The rest of the li    2683   parameter->SetGuidance ("The rest of the line is text.");
2692   parameter->SetDefaultValue ("Hello G4");       2684   parameter->SetDefaultValue ("Hello G4");
2693   fpCommand->SetParameter (parameter);           2685   fpCommand->SetParameter (parameter);
2694 }                                                2686 }
2695                                                  2687 
2696 G4VisCommandSceneAddText2D::~G4VisCommandScen    2688 G4VisCommandSceneAddText2D::~G4VisCommandSceneAddText2D () {
2697   delete fpCommand;                              2689   delete fpCommand;
2698 }                                                2690 }
2699                                                  2691 
2700 G4String G4VisCommandSceneAddText2D::GetCurre    2692 G4String G4VisCommandSceneAddText2D::GetCurrentValue (G4UIcommand*) {
2701   return "";                                     2693   return "";
2702 }                                                2694 }
2703                                                  2695 
2704 void G4VisCommandSceneAddText2D::SetNewValue     2696 void G4VisCommandSceneAddText2D::SetNewValue (G4UIcommand*, G4String newValue) {
2705                                                  2697 
2706   G4VisManager::Verbosity verbosity = fpVisMa    2698   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2707   G4bool warn = verbosity >= G4VisManager::wa    2699   G4bool warn = verbosity >= G4VisManager::warnings;
2708                                                  2700 
2709   G4Scene* pScene = fpVisManager->GetCurrentS    2701   G4Scene* pScene = fpVisManager->GetCurrentScene();
2710   if (!pScene) {                                 2702   if (!pScene) {
2711     if (verbosity >= G4VisManager::errors) {     2703     if (verbosity >= G4VisManager::errors) {
2712       G4warn << "ERROR: No current scene.  Pl << 2704       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
2713     }                                            2705     }
2714     return;                                      2706     return;
2715   }                                              2707   }
2716                                                  2708 
2717   G4Tokenizer next(newValue);                    2709   G4Tokenizer next(newValue);
2718   G4double x = StoD(next());                     2710   G4double x = StoD(next());
2719   G4double y = StoD(next());                     2711   G4double y = StoD(next());
2720   G4double font_size = StoD(next());             2712   G4double font_size = StoD(next());
2721   G4double x_offset = StoD(next());              2713   G4double x_offset = StoD(next());
2722   G4double y_offset = StoD(next());              2714   G4double y_offset = StoD(next());
2723   G4String text = next("\n");                    2715   G4String text = next("\n");
2724                                                  2716 
2725   G4Text g4text(text, G4Point3D(x,y,0.));        2717   G4Text g4text(text, G4Point3D(x,y,0.));
2726   G4VisAttributes visAtts(fCurrentTextColour)    2718   G4VisAttributes visAtts(fCurrentTextColour);
2727   g4text.SetVisAttributes(visAtts);              2719   g4text.SetVisAttributes(visAtts);
2728   g4text.SetLayout(fCurrentTextLayout);          2720   g4text.SetLayout(fCurrentTextLayout);
2729   g4text.SetScreenSize(font_size);               2721   g4text.SetScreenSize(font_size);
2730   g4text.SetOffset(x_offset,y_offset);           2722   g4text.SetOffset(x_offset,y_offset);
2731   G4Text2D* g4text2D = new G4Text2D(g4text);     2723   G4Text2D* g4text2D = new G4Text2D(g4text);
2732   G4VModel* model =                              2724   G4VModel* model =
2733     new G4CallbackModel<G4VisCommandSceneAddT    2725     new G4CallbackModel<G4VisCommandSceneAddText2D::G4Text2D>(g4text2D);
2734   model->SetType("Text2D");                      2726   model->SetType("Text2D");
2735   model->SetGlobalTag("Text2D");                 2727   model->SetGlobalTag("Text2D");
2736   std::ostringstream oss;                     << 2728   model->SetGlobalDescription("Text2D: " + newValue);
2737   oss << "Text2D: '" << g4text.GetText()      << 
2738   << "' at " << g4text.GetPosition().x() << ' << 
2739   << " with size " << g4text.GetScreenSize()  << 
2740   << " with offsets " << g4text.GetXOffset()  << 
2741   model->SetGlobalDescription(oss.str());     << 
2742   const G4String& currentSceneName = pScene -    2729   const G4String& currentSceneName = pScene -> GetName ();
2743   G4bool successful = pScene -> AddRunDuratio    2730   G4bool successful = pScene -> AddRunDurationModel (model, warn);
2744   if (successful) {                              2731   if (successful) {
2745     if (verbosity >= G4VisManager::confirmati    2732     if (verbosity >= G4VisManager::confirmations) {
2746       G4cout << "2D text '" << text           << 2733       G4cout << "2D text \"" << text
2747        << "' has been added to scene \"" << c << 2734        << "\" has been added to scene \"" << currentSceneName << "\"."
2748        << G4endl;                                2735        << G4endl;
2749     }                                            2736     }
2750   }                                              2737   }
2751   else G4VisCommandsSceneAddUnsuccessful(verb    2738   else G4VisCommandsSceneAddUnsuccessful(verbosity);
2752                                                  2739 
2753   CheckSceneAndNotifyHandlers (pScene);          2740   CheckSceneAndNotifyHandlers (pScene);
2754 }                                                2741 }
2755                                                  2742 
2756 G4VisCommandSceneAddText2D::G4Text2D::G4Text2    2743 G4VisCommandSceneAddText2D::G4Text2D::G4Text2D(const G4Text& text):
2757   fText(text)                                    2744   fText(text)
2758 {}                                               2745 {}
2759                                                  2746 
2760 void G4VisCommandSceneAddText2D::G4Text2D::op    2747 void G4VisCommandSceneAddText2D::G4Text2D::operator()
2761   (G4VGraphicsScene& sceneHandler, const G4Mo    2748   (G4VGraphicsScene& sceneHandler, const G4ModelingParameters*) {
2762   sceneHandler.BeginPrimitives2D();              2749   sceneHandler.BeginPrimitives2D();
2763   sceneHandler.AddPrimitive(fText);              2750   sceneHandler.AddPrimitive(fText);
2764   sceneHandler.EndPrimitives2D();                2751   sceneHandler.EndPrimitives2D();
2765 }                                                2752 }
2766                                                  2753 
2767                                                  2754 
2768 ////////////// /vis/scene/add/trajectories //    2755 ////////////// /vis/scene/add/trajectories ///////////////////////////////////
2769                                                  2756 
2770 G4VisCommandSceneAddTrajectories::G4VisComman    2757 G4VisCommandSceneAddTrajectories::G4VisCommandSceneAddTrajectories () {
2771   G4bool omitable;                               2758   G4bool omitable;
2772   fpCommand = new G4UIcmdWithAString             2759   fpCommand = new G4UIcmdWithAString
2773     ("/vis/scene/add/trajectories", this);       2760     ("/vis/scene/add/trajectories", this);
2774   fpCommand -> SetGuidance                       2761   fpCommand -> SetGuidance
2775     ("Adds trajectories to current scene.");     2762     ("Adds trajectories to current scene.");
2776   fpCommand -> SetGuidance                       2763   fpCommand -> SetGuidance
2777     ("Causes trajectories, if any, to be draw    2764     ("Causes trajectories, if any, to be drawn at the end of processing an"
2778      "\nevent.  Switches on trajectory storin    2765      "\nevent.  Switches on trajectory storing and sets the"
2779      "\ndefault trajectory type.");              2766      "\ndefault trajectory type.");
2780   fpCommand -> SetGuidance                       2767   fpCommand -> SetGuidance
2781     ("The command line parameter list determi    2768     ("The command line parameter list determines the default trajectory type."
2782      "\nIf it contains the string \"smooth\",    2769      "\nIf it contains the string \"smooth\", auxiliary inter-step points will"
2783      "\nbe inserted to improve the smoothness    2770      "\nbe inserted to improve the smoothness of the drawing of a curved"
2784      "\ntrajectory."                             2771      "\ntrajectory."
2785      "\nIf it contains the string \"rich\", s    2772      "\nIf it contains the string \"rich\", significant extra information will"
2786      "\nbe stored in the trajectory (G4RichTr    2773      "\nbe stored in the trajectory (G4RichTrajectory) amenable to modeling"
2787      "\nand filtering with \"/vis/modeling/tr    2774      "\nand filtering with \"/vis/modeling/trajectories/create/drawByAttribute\""
2788      "\nand \"/vis/filtering/trajectories/cre    2775      "\nand \"/vis/filtering/trajectories/create/attributeFilter\" commands."
2789      "\nIt may contain both strings in any or    2776      "\nIt may contain both strings in any order.");
2790   fpCommand -> SetGuidance                       2777   fpCommand -> SetGuidance
2791     ("\nTo switch off trajectory storing: \"/    2778     ("\nTo switch off trajectory storing: \"/tracking/storeTrajectory 0\"."
2792      "\nSee also \"/vis/scene/endOfEventActio    2779      "\nSee also \"/vis/scene/endOfEventAction\".");
2793   fpCommand -> SetGuidance                       2780   fpCommand -> SetGuidance
2794     ("Note:  This only sets the default.  Ind    2781     ("Note:  This only sets the default.  Independently of the result of this"
2795      "\ncommand, a user may instantiate a tra    2782      "\ncommand, a user may instantiate a trajectory that overrides this default"
2796      "\nin PreUserTrackingAction.");             2783      "\nin PreUserTrackingAction.");
2797   fpCommand -> SetParameterName ("default-tra    2784   fpCommand -> SetParameterName ("default-trajectory-type", omitable = true);
2798   fpCommand -> SetDefaultValue ("");             2785   fpCommand -> SetDefaultValue ("");
2799 }                                                2786 }
2800                                                  2787 
2801 G4VisCommandSceneAddTrajectories::~G4VisComma    2788 G4VisCommandSceneAddTrajectories::~G4VisCommandSceneAddTrajectories () {
2802   delete fpCommand;                              2789   delete fpCommand;
2803 }                                                2790 }
2804                                                  2791 
2805 G4String G4VisCommandSceneAddTrajectories::Ge    2792 G4String G4VisCommandSceneAddTrajectories::GetCurrentValue (G4UIcommand*) {
2806   return "";                                     2793   return "";
2807 }                                                2794 }
2808                                                  2795 
2809 void G4VisCommandSceneAddTrajectories::SetNew    2796 void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
2810                 G4String newValue) {             2797                 G4String newValue) {
2811                                                  2798 
2812   G4VisManager::Verbosity verbosity = fpVisMa    2799   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2813   G4bool warn = verbosity >= G4VisManager::wa    2800   G4bool warn = verbosity >= G4VisManager::warnings;
2814                                                  2801 
2815   G4Scene* pScene = fpVisManager->GetCurrentS    2802   G4Scene* pScene = fpVisManager->GetCurrentScene();
2816   if (!pScene) {                                 2803   if (!pScene) {
2817     if (verbosity >= G4VisManager::errors) {     2804     if (verbosity >= G4VisManager::errors) {
2818       G4warn << "ERROR: No current scene.  Pl << 2805       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
2819     }                                            2806     }
2820     return;                                      2807     return;
2821   }                                              2808   }
2822   const G4String& currentSceneName = pScene -    2809   const G4String& currentSceneName = pScene -> GetName ();
2823                                                  2810 
2824   G4bool smooth = false;                         2811   G4bool smooth = false;
2825   G4bool rich = false;                           2812   G4bool rich = false;
2826   if (newValue.find("smooth") != std::string:    2813   if (newValue.find("smooth") != std::string::npos) smooth = true;
2827   if (newValue.find("rich") != std::string::n    2814   if (newValue.find("rich") != std::string::npos) rich = true;
2828   if (newValue.size() && !(rich || smooth)) {    2815   if (newValue.size() && !(rich || smooth)) {
2829     if (verbosity >= G4VisManager::errors) {     2816     if (verbosity >= G4VisManager::errors) {
2830       G4warn << "ERROR: Unrecognised paramete << 2817       G4cerr << "ERROR: Unrecognised parameter \"" << newValue << "\""
2831       "\n  No action taken."                     2818       "\n  No action taken."
2832       << G4endl;                                 2819       << G4endl;
2833     }                                            2820     }
2834     return;                                      2821     return;
2835   }                                              2822   }
2836                                                  2823 
2837   G4UImanager* UImanager = G4UImanager::GetUI    2824   G4UImanager* UImanager = G4UImanager::GetUIpointer();
                                                   >> 2825   G4int keepVerbose = UImanager->GetVerboseLevel();
                                                   >> 2826   G4int newVerbose = 2;
                                                   >> 2827   UImanager->SetVerboseLevel(newVerbose);
2838   G4String defaultTrajectoryType;                2828   G4String defaultTrajectoryType;
2839   if (smooth && rich) {                          2829   if (smooth && rich) {
2840     UImanager->ApplyCommand("/tracking/storeT    2830     UImanager->ApplyCommand("/tracking/storeTrajectory 4");
2841     defaultTrajectoryType = "G4RichTrajectory    2831     defaultTrajectoryType = "G4RichTrajectory configured for smooth steps";
2842   } else if (smooth) {                           2832   } else if (smooth) {
2843     UImanager->ApplyCommand("/tracking/storeT    2833     UImanager->ApplyCommand("/tracking/storeTrajectory 2");
2844     defaultTrajectoryType = "G4SmoothTrajecto    2834     defaultTrajectoryType = "G4SmoothTrajectory";
2845   } else if (rich) {                             2835   } else if (rich) {
2846     UImanager->ApplyCommand("/tracking/storeT    2836     UImanager->ApplyCommand("/tracking/storeTrajectory 3");
2847     defaultTrajectoryType = "G4RichTrajectory    2837     defaultTrajectoryType = "G4RichTrajectory";
2848   } else {                                       2838   } else {
2849     UImanager->ApplyCommand("/tracking/storeT    2839     UImanager->ApplyCommand("/tracking/storeTrajectory 1");
2850     defaultTrajectoryType = "G4Trajectory";      2840     defaultTrajectoryType = "G4Trajectory";
2851   }                                              2841   }
                                                   >> 2842   UImanager->SetVerboseLevel(keepVerbose);
2852                                                  2843 
2853   if (verbosity >= G4VisManager::errors) {       2844   if (verbosity >= G4VisManager::errors) {
2854     G4warn <<                                 << 2845     G4cout <<
2855       "Attributes available for modeling and     2846       "Attributes available for modeling and filtering with"
2856       "\n  \"/vis/modeling/trajectories/creat    2847       "\n  \"/vis/modeling/trajectories/create/drawByAttribute\" and"
2857       "\n  \"/vis/filtering/trajectories/crea    2848       "\n  \"/vis/filtering/trajectories/create/attributeFilter\" commands:"
2858      << G4endl;                                  2849      << G4endl;
2859     G4warn << *G4TrajectoriesModel().GetAttDe << 2850     G4cout << *G4TrajectoriesModel().GetAttDefs();
2860     if (rich) {                                  2851     if (rich) {
2861       G4warn << *G4RichTrajectory().GetAttDef << 2852       G4cout << *G4RichTrajectory().GetAttDefs()
2862        << *G4RichTrajectoryPoint().GetAttDefs    2853        << *G4RichTrajectoryPoint().GetAttDefs();
2863     } else if (smooth) {                         2854     } else if (smooth) {
2864       G4warn << *G4SmoothTrajectory().GetAttD << 2855       G4cout << *G4SmoothTrajectory().GetAttDefs()
2865        << *G4SmoothTrajectoryPoint().GetAttDe    2856        << *G4SmoothTrajectoryPoint().GetAttDefs();
2866     } else {                                     2857     } else {
2867       G4warn << *G4Trajectory().GetAttDefs()  << 2858       G4cout << *G4Trajectory().GetAttDefs()
2868        << *G4TrajectoryPoint().GetAttDefs();     2859        << *G4TrajectoryPoint().GetAttDefs();
2869     }                                            2860     }
2870   }                                              2861   }
2871                                                  2862 
2872   const auto& eoeList = pScene->GetEndOfEvent    2863   const auto& eoeList = pScene->GetEndOfEventModelList();
2873   auto eoeModel = eoeList.begin();               2864   auto eoeModel = eoeList.begin();
2874   for (; eoeModel != eoeList.end(); ++eoeMode    2865   for (; eoeModel != eoeList.end(); ++eoeModel) {
2875     const auto* actualModel = eoeModel->fpMod    2866     const auto* actualModel = eoeModel->fpModel;
2876     if (dynamic_cast<const G4TrajectoriesMode    2867     if (dynamic_cast<const G4TrajectoriesModel*>(actualModel)) break;
2877   }                                              2868   }
2878   if (eoeModel == eoeList.end()) {               2869   if (eoeModel == eoeList.end()) {
2879     // No trajectories model exists in the sc    2870     // No trajectories model exists in the scene so create a new one...
2880     G4VModel* model = new G4TrajectoriesModel    2871     G4VModel* model = new G4TrajectoriesModel();
2881     pScene -> AddEndOfEventModel (model, warn    2872     pScene -> AddEndOfEventModel (model, warn);
2882   }  // ...else it already exists and there i    2873   }  // ...else it already exists and there is no need to add a new one
2883   // because G4TrajectoriesModel simply descr    2874   // because G4TrajectoriesModel simply describes trajectories in the
2884   // trajectories store whatever the type.       2875   // trajectories store whatever the type.
2885                                                  2876 
2886   if (verbosity >= G4VisManager::confirmation    2877   if (verbosity >= G4VisManager::confirmations) {
2887     G4cout << "Default trajectory type " << d    2878     G4cout << "Default trajectory type " << defaultTrajectoryType
2888      << "\n  will be used to store trajectori    2879      << "\n  will be used to store trajectories for scene \""
2889      << currentSceneName << "\"."                2880      << currentSceneName << "\"."
2890      << G4endl;                                  2881      << G4endl;
2891   }                                              2882   }
2892                                                  2883 
2893   if (verbosity >= G4VisManager::warnings) {     2884   if (verbosity >= G4VisManager::warnings) {
2894     G4warn <<                                 << 2885     G4cout <<
2895       "WARNING: Trajectory storing has been r    2886       "WARNING: Trajectory storing has been requested.  This action may be"
2896       "\n  reversed with \"/tracking/storeTra    2887       "\n  reversed with \"/tracking/storeTrajectory 0\"."
2897      << G4endl;                                  2888      << G4endl;
2898   }                                              2889   }
2899                                                  2890 
2900   CheckSceneAndNotifyHandlers (pScene);          2891   CheckSceneAndNotifyHandlers (pScene);
2901 }                                                2892 }
2902                                                  2893 
2903 ////////////// /vis/scene/add/userAction ////    2894 ////////////// /vis/scene/add/userAction ///////////////////////////////////
2904                                                  2895 
2905 G4VisCommandSceneAddUserAction::G4VisCommandS    2896 G4VisCommandSceneAddUserAction::G4VisCommandSceneAddUserAction () {
2906   G4bool omitable;                               2897   G4bool omitable;
2907   fpCommand = new G4UIcmdWithAString("/vis/sc    2898   fpCommand = new G4UIcmdWithAString("/vis/scene/add/userAction",this);
2908   fpCommand -> SetGuidance                       2899   fpCommand -> SetGuidance
2909     ("Add named Vis User Action to current sc    2900     ("Add named Vis User Action to current scene.");
2910   fpCommand -> SetGuidance                       2901   fpCommand -> SetGuidance
2911     ("Attempts to match search string to name    2902     ("Attempts to match search string to name of action - use unique sub-string.");
2912   fpCommand -> SetGuidance                       2903   fpCommand -> SetGuidance
2913     ("(Use /vis/list to see names of register    2904     ("(Use /vis/list to see names of registered actions.)");
2914   fpCommand -> SetGuidance                       2905   fpCommand -> SetGuidance
2915     ("If name == \"all\" (default), all actio    2906     ("If name == \"all\" (default), all actions are added.");
2916   fpCommand -> SetParameterName("action-name"    2907   fpCommand -> SetParameterName("action-name", omitable = true);
2917   fpCommand -> SetDefaultValue("all");           2908   fpCommand -> SetDefaultValue("all");
2918 }                                                2909 }
2919                                                  2910 
2920 G4VisCommandSceneAddUserAction::~G4VisCommand    2911 G4VisCommandSceneAddUserAction::~G4VisCommandSceneAddUserAction () {
2921   delete fpCommand;                              2912   delete fpCommand;
2922 }                                                2913 }
2923                                                  2914 
2924 G4String G4VisCommandSceneAddUserAction::GetC    2915 G4String G4VisCommandSceneAddUserAction::GetCurrentValue (G4UIcommand*) {
2925   return "";                                     2916   return "";
2926 }                                                2917 }
2927                                                  2918 
2928 void G4VisCommandSceneAddUserAction::SetNewVa    2919 void G4VisCommandSceneAddUserAction::SetNewValue
2929 (G4UIcommand*, G4String newValue) {              2920 (G4UIcommand*, G4String newValue) {
2930                                                  2921 
2931   G4VisManager::Verbosity verbosity = fpVisMa    2922   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
2932                                                  2923 
2933   G4Scene* pScene = fpVisManager->GetCurrentS    2924   G4Scene* pScene = fpVisManager->GetCurrentScene();
2934   if (!pScene) {                                 2925   if (!pScene) {
2935     if (verbosity >= G4VisManager::errors) {     2926     if (verbosity >= G4VisManager::errors) {
2936       G4warn << "ERROR: No current scene.  Pl << 2927       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
2937     }                                            2928     }
2938     return;                                      2929     return;
2939   }                                              2930   }
2940                                                  2931 
2941   G4bool any = false;                            2932   G4bool any = false;
2942                                                  2933 
2943   const std::vector<G4VisManager::UserVisActi    2934   const std::vector<G4VisManager::UserVisAction>& runDurationUserVisActions =
2944     fpVisManager->GetRunDurationUserVisAction    2935     fpVisManager->GetRunDurationUserVisActions();
2945   for (size_t i = 0; i < runDurationUserVisAc    2936   for (size_t i = 0; i < runDurationUserVisActions.size(); i++) {
2946     const G4String& name = runDurationUserVis    2937     const G4String& name = runDurationUserVisActions[i].fName;
2947     G4VUserVisAction* visAction = runDuration    2938     G4VUserVisAction* visAction = runDurationUserVisActions[i].fpUserVisAction;
2948     if (newValue == "all" || name.find(newVal    2939     if (newValue == "all" || name.find(newValue) != std::string::npos) {
2949       any = true;                                2940       any = true;
2950       AddVisAction(name,visAction,pScene,runD    2941       AddVisAction(name,visAction,pScene,runDuration,verbosity);
2951     }                                            2942     }
2952   }                                              2943   }
2953                                                  2944 
2954   const std::vector<G4VisManager::UserVisActi    2945   const std::vector<G4VisManager::UserVisAction>& endOfEventUserVisActions =
2955     fpVisManager->GetEndOfEventUserVisActions    2946     fpVisManager->GetEndOfEventUserVisActions();
2956   for (size_t i = 0; i < endOfEventUserVisAct    2947   for (size_t i = 0; i < endOfEventUserVisActions.size(); i++) {
2957     const G4String& name = endOfEventUserVisA    2948     const G4String& name = endOfEventUserVisActions[i].fName;
2958     G4VUserVisAction* visAction = endOfEventU    2949     G4VUserVisAction* visAction = endOfEventUserVisActions[i].fpUserVisAction;
2959     if (newValue == "all" || name.find(newVal    2950     if (newValue == "all" || name.find(newValue) != std::string::npos) {
2960       any = true;                                2951       any = true;
2961       AddVisAction(name,visAction,pScene,endO    2952       AddVisAction(name,visAction,pScene,endOfEvent,verbosity);
2962     }                                            2953     }
2963   }                                              2954   }
2964                                                  2955 
2965   const std::vector<G4VisManager::UserVisActi    2956   const std::vector<G4VisManager::UserVisAction>& endOfRunUserVisActions =
2966     fpVisManager->GetEndOfRunUserVisActions()    2957     fpVisManager->GetEndOfRunUserVisActions();
2967   for (size_t i = 0; i < endOfRunUserVisActio    2958   for (size_t i = 0; i < endOfRunUserVisActions.size(); i++) {
2968     const G4String& name = endOfRunUserVisAct    2959     const G4String& name = endOfRunUserVisActions[i].fName;
2969     G4VUserVisAction* visAction = endOfRunUse    2960     G4VUserVisAction* visAction = endOfRunUserVisActions[i].fpUserVisAction;
2970     if (newValue == "all" || name.find(newVal    2961     if (newValue == "all" || name.find(newValue) != std::string::npos) {
2971       any = true;                                2962       any = true;
2972       AddVisAction(name,visAction,pScene,endO    2963       AddVisAction(name,visAction,pScene,endOfRun,verbosity);
2973     }                                            2964     }
2974   }                                              2965   }
2975                                                  2966 
2976   if (!any) {                                    2967   if (!any) {
2977     if (verbosity >= G4VisManager::warnings)     2968     if (verbosity >= G4VisManager::warnings) {
2978       G4warn << "WARNING: No User Vis Action  << 2969       G4cout << "WARNING: No User Vis Action registered." << G4endl;
2979     }                                            2970     }
2980     return;                                      2971     return;
2981   }                                              2972   }
2982                                                  2973 
2983   CheckSceneAndNotifyHandlers (pScene);          2974   CheckSceneAndNotifyHandlers (pScene);
2984 }                                                2975 }
2985                                                  2976 
2986 void G4VisCommandSceneAddUserAction::AddVisAc    2977 void G4VisCommandSceneAddUserAction::AddVisAction
2987 (const G4String& name,                           2978 (const G4String& name,
2988  G4VUserVisAction* visAction,                    2979  G4VUserVisAction* visAction,
2989  G4Scene* pScene,                                2980  G4Scene* pScene,
2990  G4VisCommandSceneAddUserAction::ActionType t    2981  G4VisCommandSceneAddUserAction::ActionType type,
2991  G4VisManager::Verbosity verbosity)              2982  G4VisManager::Verbosity verbosity)
2992 {                                                2983 {
2993   G4bool warn = verbosity >= G4VisManager::wa    2984   G4bool warn = verbosity >= G4VisManager::warnings;
2994                                                  2985 
2995   const std::map<G4VUserVisAction*,G4VisExten    2986   const std::map<G4VUserVisAction*,G4VisExtent>& visExtentMap =
2996     fpVisManager->GetUserVisActionExtents();     2987     fpVisManager->GetUserVisActionExtents();
2997   G4VisExtent extent;                            2988   G4VisExtent extent;
2998   std::map<G4VUserVisAction*,G4VisExtent>::co    2989   std::map<G4VUserVisAction*,G4VisExtent>::const_iterator i =
2999     visExtentMap.find(visAction);                2990     visExtentMap.find(visAction);
3000   if (i != visExtentMap.end()) extent = i->se    2991   if (i != visExtentMap.end()) extent = i->second;
3001   if (warn) {                                    2992   if (warn) {
3002     if (extent.GetExtentRadius() <= 0.) {        2993     if (extent.GetExtentRadius() <= 0.) {
3003       G4warn                                  << 2994       G4cout
3004       << "WARNING: User Vis Action \"" << nam    2995       << "WARNING: User Vis Action \"" << name << "\" extent is null."
3005       << G4endl;                                 2996       << G4endl;
3006     }                                            2997     }
3007   }                                              2998   }
3008                                                  2999 
3009   G4VModel* model = new G4CallbackModel<G4VUs    3000   G4VModel* model = new G4CallbackModel<G4VUserVisAction>(visAction);
3010   model->SetType("User Vis Action");             3001   model->SetType("User Vis Action");
3011   model->SetGlobalTag(name);                     3002   model->SetGlobalTag(name);
3012   model->SetGlobalDescription(name);             3003   model->SetGlobalDescription(name);
3013   model->SetExtent(extent);                      3004   model->SetExtent(extent);
3014   G4bool successful = false;;                    3005   G4bool successful = false;;
3015   switch (type) {                                3006   switch (type) {
3016   case runDuration:                              3007   case runDuration:
3017     successful = pScene -> AddRunDurationMode    3008     successful = pScene -> AddRunDurationModel (model, warn);
3018     break;                                       3009     break;
3019   case endOfEvent:                               3010   case endOfEvent:
3020     successful = pScene -> AddEndOfEventModel    3011     successful = pScene -> AddEndOfEventModel (model, warn);
3021     break;                                       3012     break;
3022   case endOfRun:                                 3013   case endOfRun:
3023     successful = pScene -> AddEndOfRunModel (    3014     successful = pScene -> AddEndOfRunModel (model, warn);
3024     break;                                       3015     break;
3025   }                                              3016   }
3026   if (successful) {                              3017   if (successful) {
3027     if (verbosity >= G4VisManager::confirmati    3018     if (verbosity >= G4VisManager::confirmations) {
3028       const G4String& currentSceneName = pSce    3019       const G4String& currentSceneName = pScene -> GetName ();
3029       G4cout << "User Vis Action added to sce    3020       G4cout << "User Vis Action added to scene \""
3030       << currentSceneName << "\"";               3021       << currentSceneName << "\"";
3031       if (verbosity >= G4VisManager::paramete    3022       if (verbosity >= G4VisManager::parameters) {
3032         G4cout << "\n  with extent " << exten    3023         G4cout << "\n  with extent " << extent;
3033       }                                          3024       }
3034       G4cout << G4endl;                          3025       G4cout << G4endl;
3035     }                                            3026     }
3036   }                                              3027   }
3037   else G4VisCommandsSceneAddUnsuccessful(verb    3028   else G4VisCommandsSceneAddUnsuccessful(verbosity);
3038 }                                                3029 }
3039                                                  3030 
3040 ////////////// /vis/scene/add/volume ////////    3031 ////////////// /vis/scene/add/volume ///////////////////////////////////////
3041                                                  3032 
3042 G4VisCommandSceneAddVolume::G4VisCommandScene    3033 G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume () {
3043   G4bool omitable;                               3034   G4bool omitable;
3044   fpCommand = new G4UIcommand ("/vis/scene/ad    3035   fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
3045   fpCommand -> SetGuidance                       3036   fpCommand -> SetGuidance 
3046    ("Adds a physical volume to current scene,    3037    ("Adds a physical volume to current scene, with optional clipping volume.");
3047   fpCommand -> SetGuidance                       3038   fpCommand -> SetGuidance 
3048     ("If physical-volume-name is \"world\" (t    3039     ("If physical-volume-name is \"world\" (the default), the top of the"
3049      "\nmain geometry tree (material world) i    3040      "\nmain geometry tree (material world) is added. If \"worlds\", the"
3050      "\ntops of all worlds - material world a    3041      "\ntops of all worlds - material world and parallel worlds, if any - are"
3051      "\nadded. Otherwise a search of all worl    3042      "\nadded. Otherwise a search of all worlds is made.");
3052   fpCommand -> SetGuidance                       3043   fpCommand -> SetGuidance
3053     ("In the last case the names of all volum    3044     ("In the last case the names of all volumes in all worlds are matched"
3054      "\nagainst physical-volume-name. If this    3045      "\nagainst physical-volume-name. If this is of the form \"/regexp/\","
3055      "\nwhere regexp is a regular expression     3046      "\nwhere regexp is a regular expression (see C++ regex), the match uses"
3056      "\nthe usual rules of regular expression    3047      "\nthe usual rules of regular expression matching. Otherwise an exact"
3057      "\nmatch is required."                      3048      "\nmatch is required."
3058      "\nFor example, \"/Shap/\" adds \"Shape1    3049      "\nFor example, \"/Shap/\" adds \"Shape1\" and \"Shape2\".");
3059   fpCommand -> SetGuidance                       3050   fpCommand -> SetGuidance
3060     ("It may help to see a textual representa    3051     ("It may help to see a textual representation of the geometry hierarchy of"
3061      "\nthe worlds. Try \"/vis/drawTree [worl    3052      "\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
3062      "\ncombinations that have the required f    3053      "\ncombinations that have the required functionality, e.g., HepRepFile.");
3063   fpCommand -> SetGuidance                       3054   fpCommand -> SetGuidance
3064     ("If clip-volume-type is specified, the s    3055     ("If clip-volume-type is specified, the subsequent parameters are used to"
3065      "\nto define a clipping volume. For exam    3056      "\nto define a clipping volume. For example,"
3066      "\n\"/vis/scene/add/volume ! ! ! -box km    3057      "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
3067      "\nwith the positive octant cut away. (I    3058      "\nwith the positive octant cut away. (If the Boolean Processor issues"
3068      "\nwarnings try replacing 0 by 0.0000000    3059      "\nwarnings try replacing 0 by 0.000000001 or something.)");
3069   fpCommand -> SetGuidance                       3060   fpCommand -> SetGuidance
3070     ("If clip-volume-type is prepended with '    3061     ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
3071      "\n(cutaway). (This is the default if th    3062      "\n(cutaway). (This is the default if there is no prepended character.)"
3072      "\nIf '*' is prepended, the intersection    3063      "\nIf '*' is prepended, the intersection of the physical-volume and the"
3073      "\nclip-volume is made. (You can make a     3064      "\nclip-volume is made. (You can make a section through the detector with"
3074      "\na thin box, for example).");             3065      "\na thin box, for example).");
3075   fpCommand -> SetGuidance                       3066   fpCommand -> SetGuidance
3076     ("For \"box\", the parameters are xmin,xm    3067     ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
3077      "\nOnly \"box\" is programmed at present    3068      "\nOnly \"box\" is programmed at present.");
3078   G4UIparameter* parameter;                      3069   G4UIparameter* parameter;
3079   parameter = new G4UIparameter ("physical-vo    3070   parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
3080   parameter -> SetDefaultValue ("world");        3071   parameter -> SetDefaultValue ("world");
3081   fpCommand -> SetParameter (parameter);         3072   fpCommand -> SetParameter (parameter);
3082   parameter = new G4UIparameter ("copy-no", '    3073   parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
3083   parameter -> SetGuidance ("If negative, mat    3074   parameter -> SetGuidance ("If negative, matches any copy no.");
3084   parameter -> SetDefaultValue (-1);             3075   parameter -> SetDefaultValue (-1);
3085   fpCommand -> SetParameter (parameter);         3076   fpCommand -> SetParameter (parameter);
3086   parameter = new G4UIparameter ("depth-of-de    3077   parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
3087   parameter -> SetGuidance                       3078   parameter -> SetGuidance
3088     ("Depth of descent of geometry hierarchy.    3079     ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
3089   parameter -> SetDefaultValue (G4PhysicalVol << 3080   parameter -> SetDefaultValue (G4Scene::UNLIMITED);
3090   fpCommand -> SetParameter (parameter);         3081   fpCommand -> SetParameter (parameter);
3091   parameter = new G4UIparameter ("clip-volume    3082   parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
3092   parameter -> SetParameterCandidates("none b    3083   parameter -> SetParameterCandidates("none box -box *box");
3093   parameter -> SetDefaultValue ("none");         3084   parameter -> SetDefaultValue ("none");
3094   parameter -> SetGuidance("[-|*]type.  See g    3085   parameter -> SetGuidance("[-|*]type.  See general guidance.");
3095   fpCommand -> SetParameter (parameter);         3086   fpCommand -> SetParameter (parameter);
3096   parameter = new G4UIparameter ("parameter-u    3087   parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
3097   parameter -> SetDefaultValue ("m");            3088   parameter -> SetDefaultValue ("m");
3098   fpCommand -> SetParameter (parameter);         3089   fpCommand -> SetParameter (parameter);
3099   parameter = new G4UIparameter ("parameter-1    3090   parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
3100   parameter -> SetDefaultValue (0.);             3091   parameter -> SetDefaultValue (0.);
3101   fpCommand -> SetParameter (parameter);         3092   fpCommand -> SetParameter (parameter);
3102   parameter = new G4UIparameter ("parameter-2    3093   parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
3103   parameter -> SetDefaultValue (0.);             3094   parameter -> SetDefaultValue (0.);
3104   fpCommand -> SetParameter (parameter);         3095   fpCommand -> SetParameter (parameter);
3105   parameter = new G4UIparameter ("parameter-3    3096   parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
3106   parameter -> SetDefaultValue (0.);             3097   parameter -> SetDefaultValue (0.);
3107   fpCommand -> SetParameter (parameter);         3098   fpCommand -> SetParameter (parameter);
3108   parameter = new G4UIparameter ("parameter-4    3099   parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
3109   parameter -> SetDefaultValue (0.);             3100   parameter -> SetDefaultValue (0.);
3110   fpCommand -> SetParameter (parameter);         3101   fpCommand -> SetParameter (parameter);
3111   parameter = new G4UIparameter ("parameter-5    3102   parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
3112   parameter -> SetDefaultValue (0.);             3103   parameter -> SetDefaultValue (0.);
3113   fpCommand -> SetParameter (parameter);         3104   fpCommand -> SetParameter (parameter);
3114   parameter = new G4UIparameter ("parameter-6    3105   parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
3115   parameter -> SetDefaultValue (0.);             3106   parameter -> SetDefaultValue (0.);
3116   fpCommand -> SetParameter (parameter);         3107   fpCommand -> SetParameter (parameter);
3117 }                                                3108 }
3118                                                  3109 
3119 G4VisCommandSceneAddVolume::~G4VisCommandScen    3110 G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume () {
3120   delete fpCommand;                              3111   delete fpCommand;
3121 }                                                3112 }
3122                                                  3113 
3123 G4String G4VisCommandSceneAddVolume::GetCurre    3114 G4String G4VisCommandSceneAddVolume::GetCurrentValue (G4UIcommand*) {
3124   return "world 0 -1";                           3115   return "world 0 -1";
3125 }                                                3116 }
3126                                                  3117 
3127 void G4VisCommandSceneAddVolume::SetNewValue     3118 void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
3128                 G4String newValue) {             3119                 G4String newValue) {
3129                                                  3120 
3130   G4VisManager::Verbosity verbosity = fpVisMa    3121   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
3131   G4bool warn = verbosity >= G4VisManager::wa    3122   G4bool warn = verbosity >= G4VisManager::warnings;
3132                                                  3123 
3133   G4Scene* pScene = fpVisManager->GetCurrentS    3124   G4Scene* pScene = fpVisManager->GetCurrentScene();
3134   if (!pScene) {                                 3125   if (!pScene) {
3135     if (verbosity >= G4VisManager::errors) {     3126     if (verbosity >= G4VisManager::errors) {
3136       G4warn << "ERROR: No current scene.  Pl << 3127       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
3137     }                                            3128     }
3138     return;                                      3129     return;
3139   }                                              3130   }
3140                                                  3131 
3141   G4String name, clipVolumeType, parameterUni    3132   G4String name, clipVolumeType, parameterUnit;
3142   G4int copyNo, requestedDepthOfDescent;         3133   G4int copyNo, requestedDepthOfDescent;
3143   G4double param1, param2, param3, param4, pa    3134   G4double param1, param2, param3, param4, param5, param6;
3144   std::istringstream is (newValue);              3135   std::istringstream is (newValue);
3145   is >> name >> copyNo >> requestedDepthOfDes    3136   is >> name >> copyNo >> requestedDepthOfDescent
3146      >> clipVolumeType >> parameterUnit          3137      >> clipVolumeType >> parameterUnit
3147      >> param1 >> param2 >> param3 >> param4     3138      >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
3148   G4PhysicalVolumeModel::ClippingMode clippin    3139   G4PhysicalVolumeModel::ClippingMode clippingMode =
3149     G4PhysicalVolumeModel::subtraction;  // D    3140     G4PhysicalVolumeModel::subtraction;  // Default subtraction mode.
3150   if (clipVolumeType[size_t(0)] == '-') {        3141   if (clipVolumeType[size_t(0)] == '-') {
3151     clipVolumeType = clipVolumeType.substr(1)    3142     clipVolumeType = clipVolumeType.substr(1);  // Remove first character.
3152   } else if (clipVolumeType[size_t(0)] == '*'    3143   } else if (clipVolumeType[size_t(0)] == '*') {
3153     clippingMode = G4PhysicalVolumeModel::int    3144     clippingMode = G4PhysicalVolumeModel::intersection;
3154     clipVolumeType = clipVolumeType.substr(1)    3145     clipVolumeType = clipVolumeType.substr(1);
3155   }                                              3146   }
3156   G4double unit = G4UIcommand::ValueOf(parame    3147   G4double unit = G4UIcommand::ValueOf(parameterUnit);
3157   param1 *= unit; param2 *= unit; param3 *= u    3148   param1 *= unit; param2 *= unit; param3 *= unit;
3158   param4 *= unit; param5 *= unit; param6 *= u    3149   param4 *= unit; param5 *= unit; param6 *= unit;
3159                                                  3150 
3160   G4VSolid* clippingSolid = nullptr;             3151   G4VSolid* clippingSolid = nullptr;
3161   if (clipVolumeType == "box") {                 3152   if (clipVolumeType == "box") {
3162     const G4double dX = (param2 - param1) / 2    3153     const G4double dX = (param2 - param1) / 2.;
3163     const G4double dY = (param4 - param3) / 2    3154     const G4double dY = (param4 - param3) / 2.;
3164     const G4double dZ = (param6 - param5) / 2    3155     const G4double dZ = (param6 - param5) / 2.;
3165     const G4double x0 = (param2 + param1) / 2    3156     const G4double x0 = (param2 + param1) / 2.;
3166     const G4double y0 = (param4 + param3) / 2    3157     const G4double y0 = (param4 + param3) / 2.;
3167     const G4double z0 = (param6 + param5) / 2    3158     const G4double z0 = (param6 + param5) / 2.;
3168     clippingSolid = new G4DisplacedSolid         3159     clippingSolid = new G4DisplacedSolid
3169     ("_displaced_clipping_box",                  3160     ("_displaced_clipping_box",
3170      new G4Box("_clipping_box",dX,dY,dZ),        3161      new G4Box("_clipping_box",dX,dY,dZ),
3171      G4Translate3D(x0,y0,z0));                   3162      G4Translate3D(x0,y0,z0));
3172   }                                              3163   }
3173                                                  3164 
3174   G4TransportationManager* transportationMana    3165   G4TransportationManager* transportationManager =
3175     G4TransportationManager::GetTransportatio    3166     G4TransportationManager::GetTransportationManager ();
3176                                                  3167 
3177   size_t nWorlds = transportationManager->Get    3168   size_t nWorlds = transportationManager->GetNoWorlds();
3178   if (nWorlds > 1) {  // Parallel worlds in o    3169   if (nWorlds > 1) {  // Parallel worlds in operation...
3179     if (verbosity >= G4VisManager::warnings)     3170     if (verbosity >= G4VisManager::warnings) {
3180       static G4bool warned = false;              3171       static G4bool warned = false;
3181       if (!warned && name != "worlds") {         3172       if (!warned && name != "worlds") {
3182   G4warn <<                                   << 3173   G4cout <<
3183     "WARNING: Parallel worlds in operation.      3174     "WARNING: Parallel worlds in operation.  To visualise, specify"
3184     "\n  \"worlds\" or the parallel world vol    3175     "\n  \"worlds\" or the parallel world volume or sub-volume name"
3185     "\n   and control visibility with /vis/ge    3176     "\n   and control visibility with /vis/geometry."
3186          << G4endl;                              3177          << G4endl;
3187   std::vector<G4VPhysicalVolume*>::iterator i    3178   std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3188     transportationManager->GetWorldsIterator(    3179     transportationManager->GetWorldsIterator();
3189   for (size_t i = 0; i < nWorlds; ++i, ++iter    3180   for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3190     G4warn << "  World " << i << ": " << (*it << 3181     G4cout << "  World " << i << ": " << (*iterWorld)->GetName()
3191      << G4endl;                                  3182      << G4endl;
3192     warned = true;                               3183     warned = true;
3193   }                                              3184   }
3194       }                                          3185       }
3195     }                                            3186     }
3196   }                                              3187   }
3197                                                  3188 
3198   // Get the world (the initial value of the     3189   // Get the world (the initial value of the iterator points to the mass world).
3199   G4VPhysicalVolume* world = *(transportation    3190   G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
3200                                                  3191 
3201   if (!world) {                                  3192   if (!world) {
3202     if (verbosity >= G4VisManager::errors) {     3193     if (verbosity >= G4VisManager::errors) {
3203       G4warn <<                               << 3194       G4cerr <<
3204   "ERROR: G4VisCommandSceneAddVolume::SetNewV    3195   "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
3205   "\n  No world.  Maybe the geometry has not     3196   "\n  No world.  Maybe the geometry has not yet been defined."
3206   "\n  Try \"/run/initialize\""                  3197   "\n  Try \"/run/initialize\""
3207        << G4endl;                                3198        << G4endl;
3208     }                                            3199     }
3209     return;                                      3200     return;
3210   }                                              3201   }
3211                                                  3202 
3212   std::vector<G4PhysicalVolumesSearchScene::F    3203   std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
3213                                                  3204 
3214   // When it comes to determining the extent     3205   // When it comes to determining the extent of a physical volume we normally
3215   // assume the user wishes to ignore "invisi    3206   // assume the user wishes to ignore "invisible" volumes. For example, most
3216   // users make the world volume invisible. S    3207   // users make the world volume invisible. So we ask the physical volume
3217   // model to traverse the geometry hierarchy    3208   // model to traverse the geometry hierarchy, starting at the named physical
3218   // volume, until it finds non-invisible one    3209   // volume, until it finds non-invisible ones, whose extents are accumulated
3219   // to determine the overall extent. (Once a    3210   // to determine the overall extent. (Once a non-invisible volume is found,
3220   // the search is curtailed - daughters are     3211   // the search is curtailed - daughters are always contained within the mother
3221   // so they have no subsequent influence on     3212   // so they have no subsequent influence on the extent of the mother - but the
3222   // search continues at the same level until    3213   // search continues at the same level until all highest level non-invisible
3223   // volumes are found an their extents accum    3214   // volumes are found an their extents accumulated.) So the default is
3224   G4bool useFullExtent = false;                  3215   G4bool useFullExtent = false;
3225   // However, the above procedure can be time    3216   // However, the above procedure can be time consuming in some situations, such
3226   // as a nested parameterisation whose ultim    3217   // as a nested parameterisation whose ultimate volumes are the first non-
3227   // visible ones, which are typical of a med    3218   // visible ones, which are typical of a medical "phantom". So we assume here
3228   // below that if a user specifies a name ot    3219   // below that if a user specifies a name other than "world" or "worlds" he/she
3229   // wished the extent to be determined by th    3220   // wished the extent to be determined by the volume, whether it is visible
3230   // or not. So we set useFullExtent true at     3221   // or not. So we set useFullExtent true at that point below.
3231                                                  3222 
3232   if (name == "world") {                         3223   if (name == "world") {
3233                                                  3224 
3234     findingsVector.push_back                     3225     findingsVector.push_back
3235     (G4PhysicalVolumesSearchScene::Findings(w    3226     (G4PhysicalVolumesSearchScene::Findings(world,world));
3236                                                  3227 
3237   } else if (name == "worlds") {                 3228   } else if (name == "worlds") {
3238                                                  3229 
3239     if (nWorlds <= 1) {                          3230     if (nWorlds <= 1) {
3240       if (verbosity >= G4VisManager::warnings    3231       if (verbosity >= G4VisManager::warnings) {
3241   G4warn <<                                   << 3232   G4cout <<
3242     "WARNING: G4VisCommandSceneAddVolume::Set    3233     "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
3243     "\n  Parallel worlds requested but none e    3234     "\n  Parallel worlds requested but none exist."
3244     "\n  Just adding material world."            3235     "\n  Just adding material world."
3245          << G4endl;                              3236          << G4endl;
3246       }                                          3237       }
3247     }                                            3238     }
3248     std::vector<G4VPhysicalVolume*>::iterator    3239     std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3249       transportationManager->GetWorldsIterato    3240       transportationManager->GetWorldsIterator();
3250     for (size_t i = 0; i < nWorlds; ++i, ++it    3241     for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3251       findingsVector.push_back                   3242       findingsVector.push_back
3252       (G4PhysicalVolumesSearchScene::Findings    3243       (G4PhysicalVolumesSearchScene::Findings
3253        (*iterWorld,*iterWorld));                 3244        (*iterWorld,*iterWorld));
3254     }                                            3245     }
3255                                                  3246 
3256   } else {  // Search all worlds...              3247   } else {  // Search all worlds...
3257                                                  3248 
3258     // Use the model's full extent. This assu    3249     // Use the model's full extent. This assumes the user wants these
3259     // volumes in the findings vector (there     3250     // volumes in the findings vector (there could be more than one) to
3260     // determine the scene's extent. Otherwis    3251     // determine the scene's extent. Otherwise G4PhysicalVolumeModel would
3261     // re-calculate each volume's extent base    3252     // re-calculate each volume's extent based on visibility, etc., which
3262     // could be time consuming.                  3253     // could be time consuming.
3263     useFullExtent = true;                        3254     useFullExtent = true;
3264                                                  3255 
3265     std::vector<G4VPhysicalVolume*>::iterator    3256     std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3266       transportationManager->GetWorldsIterato    3257       transportationManager->GetWorldsIterator();
3267     for (size_t i = 0; i < nWorlds; ++i, ++it    3258     for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3268       G4ModelingParameters mp;  // Default -     3259       G4ModelingParameters mp;  // Default - no culling.
3269       G4PhysicalVolumeModel searchModel          3260       G4PhysicalVolumeModel searchModel
3270       (*iterWorld,                               3261       (*iterWorld,
3271        requestedDepthOfDescent,               << 3262        G4PhysicalVolumeModel::UNLIMITED,
3272        G4Transform3D(),                          3263        G4Transform3D(),
3273        &mp,                                      3264        &mp,
3274        useFullExtent);                           3265        useFullExtent);
3275       G4PhysicalVolumesSearchScene searchScen << 3266       G4PhysicalVolumesSearchScene searchScene
                                                   >> 3267       (&searchModel, name, copyNo, requestedDepthOfDescent);
3276       searchModel.DescribeYourselfTo (searchS    3268       searchModel.DescribeYourselfTo (searchScene);  // Initiate search.
3277       for (const auto& findings: searchScene.    3269       for (const auto& findings: searchScene.GetFindings()) {
3278         findingsVector.push_back(findings);      3270         findingsVector.push_back(findings);
3279       }                                          3271       }
3280     }                                            3272     }
3281   }                                              3273   }
3282                                                  3274 
3283   for (const auto& findings: findingsVector)     3275   for (const auto& findings: findingsVector) {
3284     // Set copy number from search findings f    3276     // Set copy number from search findings for replicas and parameterisations.
3285     findings.fpFoundPV->SetCopyNo(findings.fF    3277     findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
3286     G4PhysicalVolumeModel* foundPVModel = new    3278     G4PhysicalVolumeModel* foundPVModel = new G4PhysicalVolumeModel
3287     (findings.fpFoundPV,                         3279     (findings.fpFoundPV,
3288      requestedDepthOfDescent,                    3280      requestedDepthOfDescent,
3289      findings.fFoundObjectTransformation,        3281      findings.fFoundObjectTransformation,
3290      0, // No modelling parameters (these are    3282      0, // No modelling parameters (these are set later by the scene handler).
3291      useFullExtent,                              3283      useFullExtent,
3292      findings.fFoundBasePVPath);                 3284      findings.fFoundBasePVPath);
3293     if (clippingSolid) {                         3285     if (clippingSolid) {
3294       foundPVModel->SetClippingSolid(clipping    3286       foundPVModel->SetClippingSolid(clippingSolid);
3295       foundPVModel->SetClippingMode(clippingM    3287       foundPVModel->SetClippingMode(clippingMode);
3296     }                                            3288     }
3297     if (!foundPVModel->Validate(warn)) return    3289     if (!foundPVModel->Validate(warn)) return;
3298     // ...so add it to the scene.                3290     // ...so add it to the scene.
3299     G4bool successful = pScene->AddRunDuratio    3291     G4bool successful = pScene->AddRunDurationModel(foundPVModel,warn);
3300     if (successful) {                            3292     if (successful) {
3301       if (verbosity >= G4VisManager::confirma    3293       if (verbosity >= G4VisManager::confirmations) {
3302         G4cout << "\"" << findings.fpFoundPV-    3294         G4cout << "\"" << findings.fpFoundPV->GetName()
3303         << "\", copy no. " << findings.fFound    3295         << "\", copy no. " << findings.fFoundPVCopyNo
3304         << ",\n  found in searched volume \""    3296         << ",\n  found in searched volume \""
3305         << findings.fpSearchPV->GetName()        3297         << findings.fpSearchPV->GetName()
3306         << "\" at depth " << findings.fFoundD    3298         << "\" at depth " << findings.fFoundDepth
3307         << ",\n  base path: \"" << findings.f    3299         << ",\n  base path: \"" << findings.fFoundBasePVPath
3308         << "\",\n  with a requested depth of     3300         << "\",\n  with a requested depth of further descent of ";
3309         if (requestedDepthOfDescent < 0) {       3301         if (requestedDepthOfDescent < 0) {
3310           G4cout << "<0 (unlimited)";            3302           G4cout << "<0 (unlimited)";
3311         }                                        3303         }
3312         else {                                   3304         else {
3313           G4cout << requestedDepthOfDescent;     3305           G4cout << requestedDepthOfDescent;
3314         }                                        3306         }
3315         G4cout << ",\n  has been added to sce    3307         G4cout << ",\n  has been added to scene \"" << pScene->GetName() << "\"."
3316         << G4endl;                               3308         << G4endl;
3317       }                                          3309       }
3318     } else {                                     3310     } else {
3319       G4VisCommandsSceneAddUnsuccessful(verbo    3311       G4VisCommandsSceneAddUnsuccessful(verbosity);
3320     }                                            3312     }
3321   }                                              3313   }
3322                                                  3314 
3323   if (findingsVector.empty()) {                  3315   if (findingsVector.empty()) {
3324     if (verbosity >= G4VisManager::errors) {     3316     if (verbosity >= G4VisManager::errors) {
3325       G4warn << "ERROR: Volume \"" << name << << 3317       G4cerr << "ERROR: Volume \"" << name << "\"";
3326       if (copyNo >= 0) {                         3318       if (copyNo >= 0) {
3327         G4warn << ", copy no. " << copyNo <<  << 3319         G4cerr << ", copy no. " << copyNo << ",";
3328       }                                          3320       }
3329       G4warn << " not found." << G4endl;      << 3321       G4cerr << " not found." << G4endl;
3330     }                                            3322     }
3331     G4VisCommandsSceneAddUnsuccessful(verbosi    3323     G4VisCommandsSceneAddUnsuccessful(verbosity);
3332     return;                                      3324     return;
3333   }                                              3325   }
3334                                                  3326 
3335   CheckSceneAndNotifyHandlers(pScene);           3327   CheckSceneAndNotifyHandlers(pScene);
3336 }                                                3328 }
3337                                                  3329 
3338 /////////////////////////////////////////////    3330 /////////////////////////////////////////////////////////////////////////////
3339 ////////////// /vis/scene/add/plotter ///////    3331 ////////////// /vis/scene/add/plotter ///////////////////////////////////////
3340 /////////////////////////////////////////////    3332 /////////////////////////////////////////////////////////////////////////////
3341 G4VisCommandSceneAddPlotter::G4VisCommandScen    3333 G4VisCommandSceneAddPlotter::G4VisCommandSceneAddPlotter () {
3342   fpCommand = new G4UIcommand("/vis/scene/add    3334   fpCommand = new G4UIcommand("/vis/scene/add/plotter", this);
3343   fpCommand -> SetGuidance ("Add a plotter to    3335   fpCommand -> SetGuidance ("Add a plotter to current scene.");
3344                                                  3336   
3345   G4UIparameter* parameter;                      3337   G4UIparameter* parameter;
3346   parameter =  new G4UIparameter ("plotter",     3338   parameter =  new G4UIparameter ("plotter", 's',false);
3347   fpCommand->SetParameter(parameter);            3339   fpCommand->SetParameter(parameter);
3348 }                                                3340 }
3349                                                  3341 
3350 G4VisCommandSceneAddPlotter::~G4VisCommandSce    3342 G4VisCommandSceneAddPlotter::~G4VisCommandSceneAddPlotter () {delete fpCommand;}
3351                                                  3343 
3352 G4String G4VisCommandSceneAddPlotter::GetCurr    3344 G4String G4VisCommandSceneAddPlotter::GetCurrentValue (G4UIcommand*) {return "";}
3353                                                  3345 
3354 void G4VisCommandSceneAddPlotter::SetNewValue    3346 void G4VisCommandSceneAddPlotter::SetNewValue (G4UIcommand*, G4String newValue)
3355 {                                                3347 {
3356   G4VisManager::Verbosity verbosity = fpVisMa    3348   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
3357   G4bool warn(verbosity >= G4VisManager::warn    3349   G4bool warn(verbosity >= G4VisManager::warnings);
3358                                                  3350 
3359   G4Scene* pScene = fpVisManager->GetCurrentS    3351   G4Scene* pScene = fpVisManager->GetCurrentScene();
3360   if (!pScene) {                                 3352   if (!pScene) {
3361     if (verbosity >= G4VisManager::errors) {     3353     if (verbosity >= G4VisManager::errors) {
3362       G4warn << "ERROR: No current scene.  Pl << 3354       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
3363     }                                            3355     }
3364     return;                                      3356     return;
3365   }                                              3357   }
3366                                                  3358 
3367   G4Plotter& _plotter = G4PlotterManager::Get    3359   G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(newValue);
3368   G4VModel* model = new G4PlotterModel(_plott << 3360   
                                                   >> 3361   G4VModel* model = new G4PlotterModel(_plotter);
3369                                                  3362 
3370   const G4String& currentSceneName = pScene -    3363   const G4String& currentSceneName = pScene -> GetName ();
3371   G4bool successful = pScene -> AddEndOfRunMo << 3364   G4bool successful = pScene -> AddRunDurationModel (model, warn);
3372   if (successful) {                              3365   if (successful) {
3373     if (verbosity >= G4VisManager::confirmati    3366     if (verbosity >= G4VisManager::confirmations) {
3374       G4cout                                  << 3367       G4cout << "Arrow has been added to scene \"" << currentSceneName << "\"." << G4endl;
3375       << "Plotter \"" << model->GetCurrentDes << 
3376       << "\" has been added to scene \"" << c << 
3377       << G4endl;                              << 
3378     }                                            3368     }
3379   }                                              3369   }
3380   else G4VisCommandsSceneAddUnsuccessful(verb    3370   else G4VisCommandsSceneAddUnsuccessful(verbosity);
3381                                                  3371 
3382   CheckSceneAndNotifyHandlers (pScene);          3372   CheckSceneAndNotifyHandlers (pScene);
3383 }                                                3373 }
3384                                                  3374 
3385                                                  3375