Geant4 Cross Reference

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


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27                                                    27 
 28 // /vis/set - John Allison  21st March 2012        28 // /vis/set - John Allison  21st March 2012
 29 // Set quantities for use in appropriate futur     29 // Set quantities for use in appropriate future commands.
 30                                                    30 
 31 #include "G4VisCommandsSet.hh"                     31 #include "G4VisCommandsSet.hh"
 32                                                    32 
 33 #include "G4UIcommand.hh"                          33 #include "G4UIcommand.hh"
 34 #include "G4UIcmdWithAnInteger.hh"                 34 #include "G4UIcmdWithAnInteger.hh"
 35 #include "G4UIcmdWithADouble.hh"                   35 #include "G4UIcmdWithADouble.hh"
 36 #include "G4UIcmdWithAString.hh"                   36 #include "G4UIcmdWithAString.hh"
 37 #include "G4UIcmdWithABool.hh"                 << 
 38 #include "G4TouchablePropertiesScene.hh"           37 #include "G4TouchablePropertiesScene.hh"
 39 #include "G4TransportationManager.hh"              38 #include "G4TransportationManager.hh"
 40 #include "G4BoundingExtentScene.hh"            << 
 41                                                << 
 42 #include <sstream>                                 39 #include <sstream>
 43 #include <utility>                             << 
 44                                                << 
 45 #define G4warn G4cout                          << 
 46                                                    40 
 47 ////////////// /vis/set/arrow3DLineSegmentsPer     41 ////////////// /vis/set/arrow3DLineSegmentsPerCircle ////////////////////////////////////
 48                                                    42 
 49 G4VisCommandSetArrow3DLineSegmentsPerCircle::G     43 G4VisCommandSetArrow3DLineSegmentsPerCircle::G4VisCommandSetArrow3DLineSegmentsPerCircle ()
 50 {                                                  44 {
 51   G4bool omitable;                                 45   G4bool omitable;
 52   fpCommand = new G4UIcmdWithAnInteger("/vis/s     46   fpCommand = new G4UIcmdWithAnInteger("/vis/set/arrow3DLineSegmentsPerCircle", this);
 53   fpCommand->SetGuidance                           47   fpCommand->SetGuidance
 54   ("Defines number of line segments per circle     48   ("Defines number of line segments per circle for drawing 3D arrows"
 55    " for future \"/vis/scene/add/\" commands."     49    " for future \"/vis/scene/add/\" commands.");
 56   fpCommand->SetParameterName ("number", omita     50   fpCommand->SetParameterName ("number", omitable = true);
 57   fpCommand->SetDefaultValue (6);                  51   fpCommand->SetDefaultValue (6);
 58   fpCommand->SetRange("number >= 3");              52   fpCommand->SetRange("number >= 3");
 59 }                                                  53 }
 60                                                    54 
 61 G4VisCommandSetArrow3DLineSegmentsPerCircle::~     55 G4VisCommandSetArrow3DLineSegmentsPerCircle::~G4VisCommandSetArrow3DLineSegmentsPerCircle ()
 62 {                                                  56 {
 63   delete fpCommand;                                57   delete fpCommand;
 64 }                                                  58 }
 65                                                    59 
 66 G4String G4VisCommandSetArrow3DLineSegmentsPer     60 G4String G4VisCommandSetArrow3DLineSegmentsPerCircle::GetCurrentValue (G4UIcommand*)
 67 {                                                  61 {
 68   return G4String();                               62   return G4String();
 69 }                                                  63 }
 70                                                    64 
 71 void G4VisCommandSetArrow3DLineSegmentsPerCirc     65 void G4VisCommandSetArrow3DLineSegmentsPerCircle::SetNewValue (G4UIcommand*, G4String newValue)
 72 {                                                  66 {
 73   G4VisManager::Verbosity verbosity = fpVisMan     67   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
 74                                                    68 
 75   fCurrentArrow3DLineSegmentsPerCircle = fpCom     69   fCurrentArrow3DLineSegmentsPerCircle = fpCommand->GetNewIntValue(newValue);
 76                                                    70 
 77   if (verbosity >= G4VisManager::confirmations     71   if (verbosity >= G4VisManager::confirmations) {
 78     G4cout <<                                      72     G4cout <<
 79     "Number of line segments per circle for dr     73     "Number of line segments per circle for drawing 3D arrows for future"
 80     "\n  \"/vis/scene/add/\" commands has been     74     "\n  \"/vis/scene/add/\" commands has been set to "
 81      << fCurrentArrow3DLineSegmentsPerCircle       75      << fCurrentArrow3DLineSegmentsPerCircle
 82      << G4endl;                                    76      << G4endl;
 83   }                                                77   }
 84 }                                                  78 }
 85                                                    79 
 86 ////////////// /vis/set/colour ///////////////     80 ////////////// /vis/set/colour ////////////////////////////////////
 87                                                    81 
 88 G4VisCommandSetColour::G4VisCommandSetColour (     82 G4VisCommandSetColour::G4VisCommandSetColour ()
 89 {                                                  83 {
 90   G4bool omitable;                                 84   G4bool omitable;
 91   fpCommand = new G4UIcommand("/vis/set/colour     85   fpCommand = new G4UIcommand("/vis/set/colour", this);
 92   fpCommand->SetGuidance                           86   fpCommand->SetGuidance
 93   ("Defines colour and opacity for future \"/v <<  87     ("Defines colour and opacity for future \"/vis/scene/add/\" commands.");
 94   fpCommand->SetGuidance                           88   fpCommand->SetGuidance
 95   ("(Except \"/vis/scene/add/text\" commands - <<  89     ("(Except \"/vis/scene/add/text\" commands - see \"/vis/set/textColour\".)");
 96   fpCommand->SetGuidance(ConvertToColourGuidan     90   fpCommand->SetGuidance(ConvertToColourGuidance());
 97   fpCommand->SetGuidance("Default: white and o     91   fpCommand->SetGuidance("Default: white and opaque.");
 98   G4UIparameter* parameter;                        92   G4UIparameter* parameter;
 99   parameter = new G4UIparameter ("red", 's', o     93   parameter = new G4UIparameter ("red", 's', omitable = true);
100   parameter->SetGuidance                           94   parameter->SetGuidance
101   ("Red component or a string, e.g., \"cyan\"  <<  95     ("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored).");
102   parameter->SetDefaultValue ("1.");               96   parameter->SetDefaultValue ("1.");
103   fpCommand->SetParameter (parameter);             97   fpCommand->SetParameter (parameter);
104   parameter = new G4UIparameter ("green", 'd',     98   parameter = new G4UIparameter ("green", 'd', omitable = true);
105   parameter->SetDefaultValue (1.);                 99   parameter->SetDefaultValue (1.);
106   fpCommand->SetParameter (parameter);            100   fpCommand->SetParameter (parameter);
107   parameter = new G4UIparameter ("blue", 'd',     101   parameter = new G4UIparameter ("blue", 'd', omitable = true);
108   parameter->SetDefaultValue (1.);                102   parameter->SetDefaultValue (1.);
109   fpCommand->SetParameter (parameter);            103   fpCommand->SetParameter (parameter);
110   parameter = new G4UIparameter ("alpha", 'd',    104   parameter = new G4UIparameter ("alpha", 'd', omitable = true);
111   parameter->SetDefaultValue (1.);                105   parameter->SetDefaultValue (1.);
112   parameter->SetGuidance ("Opacity");             106   parameter->SetGuidance ("Opacity");
113   fpCommand->SetParameter (parameter);            107   fpCommand->SetParameter (parameter);
114 }                                                 108 }
115                                                   109 
116 G4VisCommandSetColour::~G4VisCommandSetColour     110 G4VisCommandSetColour::~G4VisCommandSetColour ()
117 {                                                 111 {
118   delete fpCommand;                               112   delete fpCommand;
119 }                                                 113 }
120                                                   114 
121 G4String G4VisCommandSetColour::GetCurrentValu    115 G4String G4VisCommandSetColour::GetCurrentValue (G4UIcommand*)
122 {                                                 116 {
123   return G4String();                              117   return G4String();
124 }                                                 118 }
125                                                   119 
126 void G4VisCommandSetColour::SetNewValue (G4UIc    120 void G4VisCommandSetColour::SetNewValue (G4UIcommand*, G4String newValue)
127 {                                                 121 {
128   G4VisManager::Verbosity verbosity = fpVisMan    122   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
129                                                   123 
130   G4String redOrString;                           124   G4String redOrString;
131   G4double green, blue, opacity;                  125   G4double green, blue, opacity;
132   std::istringstream iss(newValue);               126   std::istringstream iss(newValue);
133   iss >> redOrString >> green >> blue >> opaci    127   iss >> redOrString >> green >> blue >> opacity;
134                                                   128 
135   ConvertToColour(fCurrentColour, redOrString,    129   ConvertToColour(fCurrentColour, redOrString, green, blue, opacity);
136                                                   130 
137   if (verbosity >= G4VisManager::confirmations    131   if (verbosity >= G4VisManager::confirmations) {
138     G4cout <<                                     132     G4cout <<
139     "Colour for future \"/vis/scene/add/\" com << 133       "Colour for future \"/vis/scene/add/\" commands has been set to "
140     << fCurrentColour <<                       << 134      << fCurrentColour <<
141     ".\n(Except \"/vis/scene/add/text\" comman << 135       ".\n(Except \"/vis/scene/add/text\" commands - use \"/vis/set/textColour\".)"
142     << G4endl;                                 << 136      << G4endl;
143   }                                            << 
144 }                                              << 
145                                                << 
146 ////////////// /vis/set/extentForField /////// << 
147                                                << 
148 G4VisCommandSetExtentForField::G4VisCommandSet << 
149 {                                              << 
150   G4bool omitable;                             << 
151   fpCommand = new G4UIcommand("/vis/set/extent << 
152   fpCommand->SetGuidance                       << 
153   ("Sets an extent for future \"/vis/scene/add << 
154   fpCommand->SetGuidance                       << 
155   ("The default is a null extent, which is int << 
156    "\nextent of the whole scene.");            << 
157   G4UIparameter* parameter;                    << 
158   parameter = new G4UIparameter ("xmin", 'd',  << 
159   fpCommand->SetParameter (parameter);         << 
160   parameter = new G4UIparameter ("xmax", 'd',  << 
161   fpCommand->SetParameter (parameter);         << 
162   parameter = new G4UIparameter ("ymin", 'd',  << 
163   fpCommand->SetParameter (parameter);         << 
164   parameter = new G4UIparameter ("ymax", 'd',  << 
165   fpCommand->SetParameter (parameter);         << 
166   parameter = new G4UIparameter ("zmin", 'd',  << 
167   fpCommand->SetParameter (parameter);         << 
168   parameter = new G4UIparameter ("zmax", 'd',  << 
169   fpCommand->SetParameter (parameter);         << 
170   parameter = new G4UIparameter ("unit", 's',  << 
171   fpCommand->SetParameter (parameter);         << 
172 }                                              << 
173                                                << 
174 G4VisCommandSetExtentForField::~G4VisCommandSe << 
175 {                                              << 
176   delete fpCommand;                            << 
177 }                                              << 
178                                                << 
179 G4String G4VisCommandSetExtentForField::GetCur << 
180 {                                              << 
181   return G4String();                           << 
182 }                                              << 
183                                                << 
184 void G4VisCommandSetExtentForField::SetNewValu << 
185 {                                              << 
186   G4VisManager::Verbosity verbosity = fpVisMan << 
187                                                << 
188   G4double xmin, xmax, ymin, ymax, zmin, zmax; << 
189   G4String unitString;                         << 
190   std::istringstream iss(newValue);            << 
191   iss >> xmin >> xmax >> ymin >> ymax >> zmin  << 
192   G4double unit = G4UIcommand::ValueOf(unitStr << 
193   xmin *= unit; xmax *= unit;                  << 
194   ymin *= unit; ymax *= unit;                  << 
195   zmin *= unit; zmax *= unit;                  << 
196                                                << 
197   fCurrentExtentForField = G4VisExtent(xmin,xm << 
198   fCurrrentPVFindingsForField.clear();         << 
199                                                << 
200   if (verbosity >= G4VisManager::confirmations << 
201     G4cout <<                                  << 
202     "Extent for future \"/vis/scene/add/*Field << 
203     << fCurrentExtentForField                  << 
204     << "\nVolume for field has been cleared."  << 
205     << G4endl;                                 << 
206   }                                               137   }
207 }                                                 138 }
208                                                   139 
209 ////////////// /vis/set/lineWidth ////////////    140 ////////////// /vis/set/lineWidth ////////////////////////////////////
210                                                   141 
211 G4VisCommandSetLineWidth::G4VisCommandSetLineW    142 G4VisCommandSetLineWidth::G4VisCommandSetLineWidth ()
212 {                                                 143 {
213   G4bool omitable;                                144   G4bool omitable;
214   fpCommand = new G4UIcmdWithADouble("/vis/set    145   fpCommand = new G4UIcmdWithADouble("/vis/set/lineWidth", this);
215   fpCommand->SetGuidance                          146   fpCommand->SetGuidance
216   ("Defines line width for future \"/vis/scene << 147   ("Defines line width for future \"/vis/scene/add/\" commands.");
217    "\nSee \"/vis/viewer/set/lineWidth\" for mo << 
218   fpCommand->SetParameterName ("lineWidth", om    148   fpCommand->SetParameterName ("lineWidth", omitable = true);
219   fpCommand->SetDefaultValue (1.);                149   fpCommand->SetDefaultValue (1.);
220   fpCommand->SetRange("lineWidth >= 1.");         150   fpCommand->SetRange("lineWidth >= 1.");
221 }                                                 151 }
222                                                   152 
223 G4VisCommandSetLineWidth::~G4VisCommandSetLine    153 G4VisCommandSetLineWidth::~G4VisCommandSetLineWidth ()
224 {                                                 154 {
225   delete fpCommand;                               155   delete fpCommand;
226 }                                                 156 }
227                                                   157 
228 G4String G4VisCommandSetLineWidth::GetCurrentV    158 G4String G4VisCommandSetLineWidth::GetCurrentValue (G4UIcommand*)
229 {                                                 159 {
230   return G4String();                              160   return G4String();
231 }                                                 161 }
232                                                   162 
233 void G4VisCommandSetLineWidth::SetNewValue (G4    163 void G4VisCommandSetLineWidth::SetNewValue (G4UIcommand*, G4String newValue)
234 {                                                 164 {
235   G4VisManager::Verbosity verbosity = fpVisMan    165   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
236                                                   166 
237   fCurrentLineWidth = fpCommand->GetNewDoubleV    167   fCurrentLineWidth = fpCommand->GetNewDoubleValue(newValue);
238                                                   168 
239   if (verbosity >= G4VisManager::warnings) {   << 169   if (verbosity >= G4VisManager::confirmations) {
240     G4warn <<                                  << 170     G4cout <<
241     "Line width for *future* \"/vis/scene/add/ << 171     "Line width for future \"/vis/scene/add/\" commands has been set to "
242     << fCurrentLineWidth <<                    << 172      << fCurrentLineWidth
243     "\nSee \"/vis/viewer/set/lineWidth\" for m << 173      << G4endl;
244     << G4endl;                                 << 
245   }                                               174   }
246 }                                                 175 }
247                                                   176 
248 ////////////// /vis/set/textColour ///////////    177 ////////////// /vis/set/textColour ////////////////////////////////////
249                                                   178 
250 G4VisCommandSetTextColour::G4VisCommandSetText    179 G4VisCommandSetTextColour::G4VisCommandSetTextColour ()
251 {                                                 180 {
252   G4bool omitable;                                181   G4bool omitable;
253   fpCommand = new G4UIcommand("/vis/set/textCo    182   fpCommand = new G4UIcommand("/vis/set/textColour", this);
254   fpCommand->SetGuidance                          183   fpCommand->SetGuidance
255     ("Defines colour and opacity for future \"    184     ("Defines colour and opacity for future \"/vis/scene/add/text\" commands.");
256   fpCommand->SetGuidance(ConvertToColourGuidan    185   fpCommand->SetGuidance(ConvertToColourGuidance());
257   fpCommand->SetGuidance("Default: blue and op    186   fpCommand->SetGuidance("Default: blue and opaque.");
258   G4UIparameter* parameter;                       187   G4UIparameter* parameter;
259   parameter = new G4UIparameter ("red", 's', o    188   parameter = new G4UIparameter ("red", 's', omitable = true);
260   parameter->SetGuidance                          189   parameter->SetGuidance
261     ("Red component or a string, e.g., \"cyan\    190     ("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored).");
262   parameter->SetDefaultValue ("0.");              191   parameter->SetDefaultValue ("0.");
263   fpCommand->SetParameter (parameter);            192   fpCommand->SetParameter (parameter);
264   parameter = new G4UIparameter ("green", 'd',    193   parameter = new G4UIparameter ("green", 'd', omitable = true);
265   parameter->SetDefaultValue (0.);                194   parameter->SetDefaultValue (0.);
266   fpCommand->SetParameter (parameter);            195   fpCommand->SetParameter (parameter);
267   parameter = new G4UIparameter ("blue", 'd',     196   parameter = new G4UIparameter ("blue", 'd', omitable = true);
268   parameter->SetDefaultValue (1.);                197   parameter->SetDefaultValue (1.);
269   fpCommand->SetParameter (parameter);            198   fpCommand->SetParameter (parameter);
270   parameter = new G4UIparameter ("alpha", 'd',    199   parameter = new G4UIparameter ("alpha", 'd', omitable = true);
271   parameter->SetDefaultValue (1.);                200   parameter->SetDefaultValue (1.);
272   parameter->SetGuidance ("Opacity");             201   parameter->SetGuidance ("Opacity");
273   fpCommand->SetParameter (parameter);            202   fpCommand->SetParameter (parameter);
274 }                                                 203 }
275                                                   204 
276 G4VisCommandSetTextColour::~G4VisCommandSetTex    205 G4VisCommandSetTextColour::~G4VisCommandSetTextColour ()
277 {                                                 206 {
278   delete fpCommand;                               207   delete fpCommand;
279 }                                                 208 }
280                                                   209 
281 G4String G4VisCommandSetTextColour::GetCurrent    210 G4String G4VisCommandSetTextColour::GetCurrentValue (G4UIcommand*)
282 {                                                 211 {
283   return G4String();                              212   return G4String();
284 }                                                 213 }
285                                                   214 
286 void G4VisCommandSetTextColour::SetNewValue (G    215 void G4VisCommandSetTextColour::SetNewValue (G4UIcommand*, G4String newValue)
287 {                                                 216 {
288   G4VisManager::Verbosity verbosity = fpVisMan    217   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
289                                                   218 
290   G4String redOrString;                           219   G4String redOrString;
291   G4double green, blue, opacity;                  220   G4double green, blue, opacity;
292   std::istringstream iss(newValue);               221   std::istringstream iss(newValue);
293   iss >> redOrString >> green >> blue >> opaci    222   iss >> redOrString >> green >> blue >> opacity;
294                                                   223 
295   ConvertToColour(fCurrentTextColour, redOrStr    224   ConvertToColour(fCurrentTextColour, redOrString, green, blue, opacity);
296                                                   225 
297   if (verbosity >= G4VisManager::confirmations    226   if (verbosity >= G4VisManager::confirmations) {
298     G4cout <<                                     227     G4cout <<
299       "Colour for future \"/vis/scene/add/text    228       "Colour for future \"/vis/scene/add/text\" commands has been set to "
300      << fCurrentTextColour << '.'                 229      << fCurrentTextColour << '.'
301      << G4endl;                                   230      << G4endl;
302   }                                               231   }
303 }                                                 232 }
304                                                   233 
305 ////////////// /vis/set/textLayout ///////////    234 ////////////// /vis/set/textLayout ////////////////////////////////////
306                                                   235 
307 G4VisCommandSetTextLayout::G4VisCommandSetText    236 G4VisCommandSetTextLayout::G4VisCommandSetTextLayout ()
308 {                                                 237 {
309   G4bool omitable;                                238   G4bool omitable;
310   fpCommand = new G4UIcmdWithAString("/vis/set    239   fpCommand = new G4UIcmdWithAString("/vis/set/textLayout", this);
311   fpCommand->SetGuidance                          240   fpCommand->SetGuidance
312     ("Defines layout future \"/vis/scene/add/t    241     ("Defines layout future \"/vis/scene/add/text\" commands.");
313   fpCommand->SetGuidance                          242   fpCommand->SetGuidance
314     ("\"left\" (default) for left justificatio    243     ("\"left\" (default) for left justification to provided coordinate.");
315   fpCommand->SetGuidance                          244   fpCommand->SetGuidance
316     ("\"centre\" or \"center\" for text center    245     ("\"centre\" or \"center\" for text centered on provided coordinate.");
317   fpCommand->SetGuidance                          246   fpCommand->SetGuidance
318     ("\"right\" for right justification to pro    247     ("\"right\" for right justification to provided coordinate.");
319   fpCommand->SetGuidance("Default: left.");       248   fpCommand->SetGuidance("Default: left.");
320   fpCommand->SetParameterName("layout", omitab    249   fpCommand->SetParameterName("layout", omitable = true);
321   fpCommand->SetCandidates ("left centre cente    250   fpCommand->SetCandidates ("left centre center right");
322   fpCommand->SetDefaultValue ("left");            251   fpCommand->SetDefaultValue ("left");
323 }                                                 252 }
324                                                   253 
325 G4VisCommandSetTextLayout::~G4VisCommandSetTex    254 G4VisCommandSetTextLayout::~G4VisCommandSetTextLayout ()
326 {                                                 255 {
327   delete fpCommand;                               256   delete fpCommand;
328 }                                                 257 }
329                                                   258 
330 G4String G4VisCommandSetTextLayout::GetCurrent    259 G4String G4VisCommandSetTextLayout::GetCurrentValue (G4UIcommand*)
331 {                                                 260 {
332   return G4String();                              261   return G4String();
333 }                                                 262 }
334                                                   263 
335 void G4VisCommandSetTextLayout::SetNewValue (G    264 void G4VisCommandSetTextLayout::SetNewValue (G4UIcommand*, G4String newValue)
336 {                                                 265 {
337   G4Text::Layout layout = G4Text::left;           266   G4Text::Layout layout = G4Text::left;
338   if (newValue == "left") layout = G4Text::lef    267   if (newValue == "left") layout = G4Text::left;
339   else if (newValue == "centre" || newValue ==    268   else if (newValue == "centre" || newValue == "center")
340     layout = G4Text::centre;                      269     layout = G4Text::centre;
341   else if (newValue == "right") layout = G4Tex    270   else if (newValue == "right") layout = G4Text::right;
342                                                   271 
343   fCurrentTextLayout = layout;                    272   fCurrentTextLayout = layout;
344                                                   273 
345   G4VisManager::Verbosity verbosity = fpVisMan    274   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
346   if (verbosity >= G4VisManager::confirmations    275   if (verbosity >= G4VisManager::confirmations) {
347     G4cout << "Text layout (for future \"text\    276     G4cout << "Text layout (for future \"text\" commands) has been set to \""
348      << fCurrentTextLayout << "\"."               277      << fCurrentTextLayout << "\"."
349      << G4endl;                                   278      << G4endl;
350   }                                               279   }
351 }                                                 280 }
352                                                   281 
353 ////////////// /vis/set/textSize /////////////    282 ////////////// /vis/set/textSize ////////////////////////////////////
354                                                   283 
355 G4VisCommandSetTextSize::G4VisCommandSetTextSi    284 G4VisCommandSetTextSize::G4VisCommandSetTextSize ()
356 {                                                 285 {
357   G4bool omitable;                                286   G4bool omitable;
358   fpCommand = new G4UIcmdWithADouble("/vis/set    287   fpCommand = new G4UIcmdWithADouble("/vis/set/textSize", this);
359   fpCommand->SetGuidance                          288   fpCommand->SetGuidance
360   ("Defines text size (pixels) for future \"/v    289   ("Defines text size (pixels) for future \"/vis/scene/add/\" commands.");
361   fpCommand->SetParameterName ("textSize", omi    290   fpCommand->SetParameterName ("textSize", omitable = true);
362   fpCommand->SetDefaultValue (12.);  // pixels    291   fpCommand->SetDefaultValue (12.);  // pixels
363   fpCommand->SetRange("textSize >= 8.");       << 292   fpCommand->SetRange("textSize >= 1.");
364 }                                                 293 }
365                                                   294 
366 G4VisCommandSetTextSize::~G4VisCommandSetTextS    295 G4VisCommandSetTextSize::~G4VisCommandSetTextSize ()
367 {                                                 296 {
368   delete fpCommand;                               297   delete fpCommand;
369 }                                                 298 }
370                                                   299 
371 G4String G4VisCommandSetTextSize::GetCurrentVa    300 G4String G4VisCommandSetTextSize::GetCurrentValue (G4UIcommand*)
372 {                                                 301 {
373   return G4String();                              302   return G4String();
374 }                                                 303 }
375                                                   304 
376 void G4VisCommandSetTextSize::SetNewValue (G4U    305 void G4VisCommandSetTextSize::SetNewValue (G4UIcommand*, G4String newValue)
377 {                                                 306 {
378   G4VisManager::Verbosity verbosity = fpVisMan    307   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
379                                                   308 
380   fCurrentTextSize = fpCommand->GetNewDoubleVa    309   fCurrentTextSize = fpCommand->GetNewDoubleValue(newValue);
381                                                   310 
382   if (verbosity >= G4VisManager::confirmations    311   if (verbosity >= G4VisManager::confirmations) {
383     G4cout <<                                     312     G4cout <<
384     "Text size for future \"/vis/scene/add/\"     313     "Text size for future \"/vis/scene/add/\" commands has been set to "
385     << fCurrentTextSize                           314     << fCurrentTextSize
386     << G4endl;                                    315     << G4endl;
387   }                                               316   }
388 }                                                 317 }
389                                                   318 
390 ////////////// /vis/set/touchable ////////////    319 ////////////// /vis/set/touchable ////////////////////////////////////
391                                                   320 
392 G4VisCommandSetTouchable::G4VisCommandSetTouch    321 G4VisCommandSetTouchable::G4VisCommandSetTouchable ()
393 {                                                 322 {
394   G4bool omitable;                                323   G4bool omitable;
395   G4UIparameter* parameter;                       324   G4UIparameter* parameter;
396   fpCommand = new G4UIcommand("/vis/set/toucha    325   fpCommand = new G4UIcommand("/vis/set/touchable", this);
397   fpCommand->SetGuidance                          326   fpCommand->SetGuidance
398   ("Defines touchable for future \"/vis/toucha    327   ("Defines touchable for future \"/vis/touchable/set/\" commands.");
399   fpCommand->SetGuidance                          328   fpCommand->SetGuidance
400   ("Please provide a list of space-separated p    329   ("Please provide a list of space-separated physical volume names and"
401    "\ncopy number pairs starting at the world     330    "\ncopy number pairs starting at the world volume, e.g:"
402    "\n  /vis/set/touchable World 0 Envelope 0     331    "\n  /vis/set/touchable World 0 Envelope 0 Shape1 0"
403    "\n(To get list of touchables, use \"/vis/d    332    "\n(To get list of touchables, use \"/vis/drawTree\")"
404    "\n(To save, use \"/vis/viewer/save\")");      333    "\n(To save, use \"/vis/viewer/save\")");
405   parameter = new G4UIparameter ("list", 's',  << 334   parameter = new G4UIparameter ("list", 's', omitable = false);
406   parameter->SetGuidance                          335   parameter->SetGuidance
407   ("List of physical volume names and copy num    336   ("List of physical volume names and copy number pairs");
408   fpCommand->SetParameter (parameter);            337   fpCommand->SetParameter (parameter);
409 }                                                 338 }
410                                                   339 
411 G4VisCommandSetTouchable::~G4VisCommandSetTouc    340 G4VisCommandSetTouchable::~G4VisCommandSetTouchable ()
412 {                                                 341 {
413   delete fpCommand;                               342   delete fpCommand;
414 }                                                 343 }
415                                                   344 
416 G4String G4VisCommandSetTouchable::GetCurrentV    345 G4String G4VisCommandSetTouchable::GetCurrentValue (G4UIcommand*)
417 {                                                 346 {
418   return G4String();                              347   return G4String();
419 }                                                 348 }
420                                                   349 
421 void G4VisCommandSetTouchable::SetNewValue (G4    350 void G4VisCommandSetTouchable::SetNewValue (G4UIcommand*, G4String newValue)
422 {                                                 351 {
423   G4VisManager::Verbosity verbosity = fpVisMan    352   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
424                                                << 
425   if (newValue.empty()) {                      << 
426     fCurrentTouchableProperties = G4PhysicalVo << 
427     if (verbosity >= G4VisManager::confirmatio << 
428       G4cout <<                                << 
429       "Current touchable reset to: " << fCurre << 
430       << G4endl;                               << 
431     }                                          << 
432     return;                                    << 
433   }                                            << 
434                                                   353   
435   G4ModelingParameters::PVNameCopyNoPath curre    354   G4ModelingParameters::PVNameCopyNoPath currentTouchablePath;
436                                                << 355   
437   // Algorithm from Josuttis p.476.               356   // Algorithm from Josuttis p.476.
438   G4String::size_type iBegin, iEnd;               357   G4String::size_type iBegin, iEnd;
439   iBegin = newValue.find_first_not_of(' ');       358   iBegin = newValue.find_first_not_of(' ');
440   while (iBegin != G4String::npos) {              359   while (iBegin != G4String::npos) {
441     iEnd = newValue.find_first_of(' ',iBegin);    360     iEnd = newValue.find_first_of(' ',iBegin);
442     if (iEnd == G4String::npos) {                 361     if (iEnd == G4String::npos) {
443       iEnd = newValue.length();                   362       iEnd = newValue.length();
444     }                                             363     }
445     const G4String& name(newValue.substr(iBegi << 364     G4String name(newValue.substr(iBegin,iEnd-iBegin));
446     iBegin = newValue.find_first_not_of(' ',iE    365     iBegin = newValue.find_first_not_of(' ',iEnd);
447     if (iBegin == G4String::npos) {               366     if (iBegin == G4String::npos) {
448       if (verbosity >= G4VisManager::warnings)    367       if (verbosity >= G4VisManager::warnings) {
449         G4warn <<                              << 368         G4cout <<
450         "WARNING: G4VisCommandSetTouchable::Se    369         "WARNING: G4VisCommandSetTouchable::SetNewValue"
451   "\n  A pair not found.  (There should be an  << 370         "\n  A pair not found.  (Did you have an even number of parameters?)"
452         "\n  Command ignored."                    371         "\n  Command ignored."
453         << G4endl;                                372         << G4endl;
454         return;                                   373         return;
455       }                                           374       }
456     }                                             375     }
457     iEnd = newValue.find_first_of(' ',iBegin);    376     iEnd = newValue.find_first_of(' ',iBegin);
458     if (iEnd == G4String::npos) {                 377     if (iEnd == G4String::npos) {
459       iEnd = newValue.length();                   378       iEnd = newValue.length();
460     }                                             379     }
461     G4int copyNo;                                 380     G4int copyNo;
462     std::istringstream iss(newValue.substr(iBe    381     std::istringstream iss(newValue.substr(iBegin,iEnd-iBegin));
463     if (!(iss >> copyNo)) {                       382     if (!(iss >> copyNo)) {
464       if (verbosity >= G4VisManager::warnings)    383       if (verbosity >= G4VisManager::warnings) {
465         G4warn <<                              << 384         G4cout <<
466         "WARNING: G4VisCommandSetTouchable::Se    385         "WARNING: G4VisCommandSetTouchable::SetNewValue"
467         "\n  Error reading copy number - it wa    386         "\n  Error reading copy number - it was not numeric?"
468         "\n  Command ignored."                    387         "\n  Command ignored."
469         << G4endl;                                388         << G4endl;
470         return;                                   389         return;
471       }                                           390       }
472     }                                             391     }
473     currentTouchablePath.push_back                392     currentTouchablePath.push_back
474     (G4ModelingParameters::PVNameCopyNo(name,c    393     (G4ModelingParameters::PVNameCopyNo(name,copyNo));
475     iBegin = newValue.find_first_not_of(' ',iE    394     iBegin = newValue.find_first_not_of(' ',iEnd);
476   }                                               395   }
477                                                   396 
478   // Check validity                               397   // Check validity
479   G4bool successful = false;                      398   G4bool successful = false;
480   G4TransportationManager* transportationManag    399   G4TransportationManager* transportationManager =
481   G4TransportationManager::GetTransportationMa    400   G4TransportationManager::GetTransportationManager ();
482   size_t nWorlds = transportationManager->GetN    401   size_t nWorlds = transportationManager->GetNoWorlds();
483   std::vector<G4VPhysicalVolume*>::iterator it    402   std::vector<G4VPhysicalVolume*>::iterator iterWorld =
484   transportationManager->GetWorldsIterator();     403   transportationManager->GetWorldsIterator();
485   for (size_t i = 0; i < nWorlds; ++i, ++iterW    404   for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
486     G4PhysicalVolumeModel pvModel (*iterWorld)    405     G4PhysicalVolumeModel pvModel (*iterWorld);  // Unlimited depth.
487     G4ModelingParameters mp;  // Default - no     406     G4ModelingParameters mp;  // Default - no culling.
488     pvModel.SetModelingParameters (&mp);          407     pvModel.SetModelingParameters (&mp);
489     G4TouchablePropertiesScene scene (&pvModel    408     G4TouchablePropertiesScene scene (&pvModel,currentTouchablePath);
490     pvModel.DescribeYourselfTo (scene);  // In    409     pvModel.DescribeYourselfTo (scene);  // Initiate geometry tree traversal.
491     if (scene.GetFoundTouchableProperties().fp    410     if (scene.GetFoundTouchableProperties().fpTouchablePV) {
492       successful = true;                          411       successful = true;
493       fCurrentTouchableProperties = scene.GetF    412       fCurrentTouchableProperties = scene.GetFoundTouchableProperties();
494       break;  // Found, so no need to scan mor    413       break;  // Found, so no need to scan more worlds.
495     }                                             414     }
496   }                                               415   }
497                                                   416 
498   if (successful) {                               417   if (successful) {
499     if (verbosity >= G4VisManager::confirmatio    418     if (verbosity >= G4VisManager::confirmations) {
500       G4cout <<                                   419       G4cout <<
501       "Current touchable: " << fCurrentTouchab    420       "Current touchable: " << fCurrentTouchableProperties.fTouchablePath
502       << G4endl;                                  421       << G4endl;
503       return;                                     422       return;
504     }                                             423     }
505   } else {                                        424   } else {
506     if (verbosity >= G4VisManager::warnings) {    425     if (verbosity >= G4VisManager::warnings) {
507       G4warn <<                                << 426       G4cout <<
508       "WARNING: G4VisCommandSetTouchable::SetN    427       "WARNING: G4VisCommandSetTouchable::SetNewValue"
509       "\n  Touchable not found."                  428       "\n  Touchable not found."
510       << G4endl;                                  429       << G4endl;
511       return;                                     430       return;
512     }                                          << 
513   }                                            << 
514 }                                              << 
515                                                << 
516 ////////////// /vis/set/volumeForField /////// << 
517                                                << 
518 G4VisCommandSetVolumeForField::G4VisCommandSet << 
519 {                                              << 
520   G4bool omitable;                             << 
521   G4UIparameter* parameter;                    << 
522   fpCommand = new G4UIcommand("/vis/set/volume << 
523   fpCommand->SetGuidance                       << 
524   ("Sets a volume for \"/vis/scene/add/*Field\ << 
525   fpCommand->SetGuidance                       << 
526   ("Takes a volume name or a /regular expressi << 
527    "\n\"/vis/drawVolume\"");                   << 
528   parameter = new G4UIparameter ("physical-vol << 
529   fpCommand -> SetParameter (parameter);       << 
530   parameter = new G4UIparameter ("copy-no", 'i << 
531   parameter -> SetGuidance ("If negative, matc << 
532   parameter -> SetDefaultValue (-1);           << 
533   fpCommand -> SetParameter (parameter);       << 
534   parameter = new G4UIparameter ("draw", 'b',  << 
535   parameter -> SetGuidance ("If true, draw ext << 
536   parameter -> SetDefaultValue (false);        << 
537   fpCommand -> SetParameter (parameter);       << 
538 }                                              << 
539                                                << 
540 G4VisCommandSetVolumeForField::~G4VisCommandSe << 
541 {                                              << 
542   delete fpCommand;                            << 
543 }                                              << 
544                                                << 
545 G4String G4VisCommandSetVolumeForField::GetCur << 
546 {                                              << 
547   return G4String();                           << 
548 }                                              << 
549                                                << 
550 void G4VisCommandSetVolumeForField::SetNewValu << 
551 {                                              << 
552   G4VisManager::Verbosity verbosity = fpVisMan << 
553                                                << 
554   G4String name, drawString;                   << 
555   G4int copyNo;                                << 
556   std::istringstream is (newValue);            << 
557   is >> name >> copyNo >> drawString;          << 
558   G4bool draw = G4UIcmdWithABool::ConvertToBoo << 
559                                                << 
560   G4TransportationManager* transportationManag << 
561   G4TransportationManager::GetTransportationMa << 
562   size_t nWorlds = transportationManager->GetN << 
563   std::vector<G4VPhysicalVolume*>::iterator it << 
564   transportationManager->GetWorldsIterator();  << 
565   fCurrrentPVFindingsForField.clear();         << 
566   G4BoundingExtentScene extentScene;           << 
567   for (size_t i = 0; i < nWorlds; ++i, ++iterW << 
568     G4PhysicalVolumeModel searchModel (*iterWo << 
569     G4ModelingParameters mp;  // Default - no  << 
570     searchModel.SetModelingParameters (&mp);   << 
571     // Find all instances at any position in t << 
572     G4PhysicalVolumesSearchScene searchScene ( << 
573     searchModel.DescribeYourselfTo (searchScen << 
574     for (const auto& findings: searchScene.Get << 
575       fCurrrentPVFindingsForField.push_back(fi << 
576       G4VisExtent extent = findings.fpFoundPV- << 
577       extent.Transform(findings.fFoundObjectTr << 
578       extentScene.AccrueBoundingExtent(extent) << 
579     }                                          << 
580   }                                            << 
581                                                << 
582   if (fCurrrentPVFindingsForField.empty()) {   << 
583     if (verbosity >= G4VisManager::errors) {   << 
584       G4warn << "ERROR: Volume \"" << name <<  << 
585       if (copyNo >= 0) {                       << 
586         G4warn << ", copy no. " << copyNo << " << 
587       }                                        << 
588       G4warn << " not found." << G4endl;       << 
589     }                                          << 
590     return;                                    << 
591   }                                            << 
592                                                << 
593   fCurrentExtentForField = extentScene.GetExte << 
594                                                << 
595   if (draw) DrawExtent(fCurrentExtentForField) << 
596                                                << 
597   if (verbosity >= G4VisManager::confirmations << 
598     for (const auto& findings: fCurrrentPVFind << 
599       G4cout                                   << 
600       << "\"" << findings.fpFoundPV->GetName() << 
601       << "\", copy no. " << findings.fFoundPVC << 
602       << ", found\nin searched volume \""      << 
603       << findings.fpSearchPV->GetName()        << 
604       << "\" at depth " << findings.fFoundDept << 
605       << ",\nbase path: \"" << findings.fFound << 
606       << "\",\nand has been set as volume for  << 
607       << G4endl;                               << 
608     }                                             431     }
609   }                                               432   }
610 }                                                 433 }
611                                                   434