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


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