Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisCommandsViewerSet.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id$
28 
29 // /vis/viewer/set commands - John Allison 16th May 2000
30 
32 
33 #include "G4UIcommand.hh"
34 #include "G4UIcmdWithAString.hh"
35 #include "G4UIcmdWithABool.hh"
36 #include "G4UIcmdWithAnInteger.hh"
37 #include "G4UIcmdWithADouble.hh"
39 #include "G4UnitsTable.hh"
40 #include "G4VisManager.hh"
41 #include "G4Polyhedron.hh"
42 #include "G4SystemOfUnits.hh"
43 
44 #include <sstream>
45 #include <cctype>
46 
48  fLightsVector (G4ThreeVector(1.,1.,1.)),
49  fUpVector (G4ThreeVector(0.,1.,0.)),
50  fViewpointVector (G4ThreeVector(0.,0.,1.))
51 {
52  G4bool omitable;
53  G4UIparameter* parameter;
54 
55  fpCommandAll = new G4UIcmdWithAString ("/vis/viewer/set/all",this);
56  fpCommandAll->SetGuidance
57  ("Copies view parameters.");
58  fpCommandAll->SetGuidance
59  ("Copies view parameters (except the autoRefresh status) from"
60  "\nfrom-viewer to current viewer.");
61  fpCommandAll->SetParameterName ("from-viewer-name",omitable = false);
62 
63  fpCommandAutoRefresh = new G4UIcmdWithABool
64  ("/vis/viewer/set/autoRefresh",this);
65  fpCommandAutoRefresh->SetGuidance("Sets auto-refresh.");
66  fpCommandAutoRefresh->SetGuidance
67  ("If true, view is automatically refreshed after a change of"
68  "\nview parameters.");
69  fpCommandAutoRefresh->SetParameterName("auto-refresh",omitable = true);
70  fpCommandAutoRefresh->SetDefaultValue(true);
71 
72  fpCommandAuxEdge = new G4UIcmdWithABool
73  ("/vis/viewer/set/auxiliaryEdge",this);
74  fpCommandAuxEdge->SetGuidance("Sets visibility of auxiliary edges");
75  fpCommandAuxEdge->SetGuidance
76  ("Auxiliary edges, i.e., those that are part of a curved surface,"
77  "\nsometimes called soft edges, become visible/invisible.");
78  fpCommandAuxEdge->SetParameterName("edge",omitable = true);
79  fpCommandAuxEdge->SetDefaultValue(true);
80 
81  fpCommandBackground = new G4UIcommand
82  ("/vis/viewer/set/background",this);
83  fpCommandBackground->SetGuidance
84  ("Set background colour and transparency (default black and opaque).");
85  fpCommandBackground->SetGuidance
86  ("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
87  "\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
88  "\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
89  "\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
90  "\n e.g. \"! ! ! 0.\" for a transparent background.");
91  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
92  parameter -> SetDefaultValue ("0.");
93  fpCommandBackground -> SetParameter (parameter);
94  parameter = new G4UIparameter("green", 'd', omitable = true);
95  parameter -> SetDefaultValue (0.);
96  fpCommandBackground -> SetParameter (parameter);
97  parameter = new G4UIparameter ("blue", 'd', omitable = true);
98  parameter -> SetDefaultValue (0.);
99  fpCommandBackground -> SetParameter (parameter);
100  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
101  parameter -> SetDefaultValue (1.);
102  fpCommandBackground -> SetParameter (parameter);
103 
104  fpCommandCulling = new G4UIcommand("/vis/viewer/set/culling",this);
105  fpCommandCulling->SetGuidance ("Set culling options.");
106  fpCommandCulling->SetGuidance
107  ("\"global\": enables/disables all other culling options.");
108  fpCommandCulling->SetGuidance
109  ("\"coveredDaughters\": culls, i.e., eliminates, volumes that would not"
110  "\nbe seen because covered by ancester volumes in surface drawing mode,"
111  "\nand then only if the ancesters are visible and opaque, and then only"
112  "\nif no sections or cutaways are in operation. Intended solely to"
113  "\nimprove the speed of rendering visible volumes.");
114  fpCommandCulling->SetGuidance
115  ("\"invisible\": culls objects with the invisible attribute set.");
116  fpCommandCulling->SetGuidance
117  ("\"density\": culls volumes with density lower than threshold. Useful"
118  "\nfor eliminating \"container volumes\" with no physical correspondence,"
119  "\nwhose material is usually air. If this is selected, provide threshold"
120  "\ndensity and unit (g/cm3 mg/cm3 or kg/m3)."
121  );
122  parameter = new G4UIparameter("culling-option",'s',omitable = false);
123  parameter->SetParameterCandidates
124  ("global coveredDaughters invisible density");
125  fpCommandCulling->SetParameter(parameter);
126  parameter = new G4UIparameter("action",'b',omitable = true);
127  parameter->SetDefaultValue(1);
128  fpCommandCulling->SetParameter(parameter);
129  parameter = new G4UIparameter("density-threshold",'d',omitable = true);
130  parameter->SetDefaultValue("0.01");
131  fpCommandCulling->SetParameter(parameter);
132  parameter = new G4UIparameter("unit",'s',omitable = true);
133  parameter->SetParameterCandidates ("g/cm3, mg/cm3 kg/m3");
134  parameter->SetDefaultValue("g/cm3");
135  fpCommandCulling->SetParameter(parameter);
136 
137  fpCommandCutawayMode =
138  new G4UIcmdWithAString ("/vis/viewer/set/cutawayMode", this);
139  fpCommandCutawayMode->SetGuidance
140  ("Sets cutaway mode - add (union) or multiply (intersection).");
141  fpCommandCutawayMode->SetParameterName ("cutaway-mode",omitable = false);
142  fpCommandCutawayMode->SetCandidates ("add union multiply intersection");
143  fpCommandCutawayMode->SetDefaultValue("union");
144 
145  fpCommandDefaultColour = new G4UIcommand
146  ("/vis/viewer/set/defaultColour",this);
147  fpCommandDefaultColour->SetGuidance
148  ("Set defaultColour colour and transparency (default white and opaque).");
149  fpCommandDefaultColour->SetGuidance
150  ("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
151  "\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
152  "\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
153  "\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
154  "\n e.g. \"! ! ! 0.\" for a transparent colour.");
155  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
156  parameter -> SetDefaultValue ("1.");
157  fpCommandDefaultColour -> SetParameter (parameter);
158  parameter = new G4UIparameter("green", 'd', omitable = true);
159  parameter -> SetDefaultValue (1.);
160  fpCommandDefaultColour -> SetParameter (parameter);
161  parameter = new G4UIparameter ("blue", 'd', omitable = true);
162  parameter -> SetDefaultValue (1.);
163  fpCommandDefaultColour -> SetParameter (parameter);
164  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
165  parameter -> SetDefaultValue (1.);
166  fpCommandDefaultColour -> SetParameter (parameter);
167 
168  fpCommandDefaultTextColour = new G4UIcommand
169  ("/vis/viewer/set/defaultTextColour",this);
170  fpCommandDefaultTextColour->SetGuidance
171  ("Set defaultTextColour colour and transparency (default white and opaque).");
172  fpCommandDefaultTextColour->SetGuidance
173  ("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
174  "\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
175  "\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
176  "\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
177  "\n e.g. \"! ! ! 0.\" for a transparent colour.");
178  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
179  parameter -> SetDefaultValue ("1.");
180  fpCommandDefaultTextColour -> SetParameter (parameter);
181  parameter = new G4UIparameter("green", 'd', omitable = true);
182  parameter -> SetDefaultValue (1.);
183  fpCommandDefaultTextColour -> SetParameter (parameter);
184  parameter = new G4UIparameter ("blue", 'd', omitable = true);
185  parameter -> SetDefaultValue (1.);
186  fpCommandDefaultTextColour -> SetParameter (parameter);
187  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
188  parameter -> SetDefaultValue (1.);
189  fpCommandDefaultTextColour -> SetParameter (parameter);
190 
191  fpCommandEdge = new G4UIcmdWithABool("/vis/viewer/set/edge",this);
192  fpCommandEdge->SetGuidance
193  ("Edges become visible/invisible in surface mode.");
194  fpCommandEdge->SetParameterName("edge",omitable = true);
195  fpCommandEdge->SetDefaultValue(true);
196 
197  fpCommandExplodeFactor = new G4UIcommand
198  ("/vis/viewer/set/explodeFactor", this);
199  fpCommandExplodeFactor->SetGuidance
200  ("Moves top-level drawn volumes by this factor from this centre.");
201  parameter = new G4UIparameter("explodeFactor", 'd', omitable=true);
202  parameter->SetParameterRange("explodeFactor>=1.");
203  parameter->SetDefaultValue(1.);
204  fpCommandExplodeFactor->SetParameter(parameter);
205  parameter = new G4UIparameter("x",'d',omitable = true);
206  parameter->SetDefaultValue (0);
207  parameter->SetGuidance ("Coordinate of explode centre.");
208  fpCommandExplodeFactor->SetParameter(parameter);
209  parameter = new G4UIparameter("y",'d',omitable = true);
210  parameter->SetDefaultValue (0);
211  parameter->SetGuidance ("Coordinate of explode centre.");
212  fpCommandExplodeFactor->SetParameter(parameter);
213  parameter = new G4UIparameter("z",'d',omitable = true);
214  parameter->SetDefaultValue (0);
215  parameter->SetGuidance ("Coordinate of explode centre.");
216  fpCommandExplodeFactor->SetParameter(parameter);
217  parameter = new G4UIparameter("unit",'s',omitable = true);
218  parameter->SetDefaultValue ("m");
219  parameter->SetGuidance ("Unit of explode centre.");
220  fpCommandExplodeFactor->SetParameter(parameter);
221 
222  fpCommandGlobalLineWidthScale = new G4UIcmdWithADouble
223  ("/vis/viewer/set/globalLineWidthScale", this);
224  fpCommandGlobalLineWidthScale->SetGuidance
225  ("Multiplies line widths by this factor.");
226  fpCommandGlobalLineWidthScale->
227  SetParameterName("scale-factor", omitable=true);
228  fpCommandGlobalLineWidthScale->SetDefaultValue(1.);
229 
230  fpCommandGlobalMarkerScale = new G4UIcmdWithADouble
231  ("/vis/viewer/set/globalMarkerScale", this);
232  fpCommandGlobalMarkerScale->SetGuidance
233  ("Multiplies marker sizes by this factor.");
234  fpCommandGlobalMarkerScale->
235  SetParameterName("scale-factor", omitable=true);
236  fpCommandGlobalMarkerScale->SetDefaultValue(1.);
237 
238  fpCommandHiddenEdge =
239  new G4UIcmdWithABool("/vis/viewer/set/hiddenEdge",this);
240  fpCommandHiddenEdge->SetGuidance
241  ("Edges become hidden/seen in wireframe or surface mode.");
242  fpCommandHiddenEdge->SetParameterName("hidden-edge",omitable = true);
243  fpCommandHiddenEdge->SetDefaultValue(true);
244 
245  fpCommandHiddenMarker =
246  new G4UIcmdWithABool("/vis/viewer/set/hiddenMarker",this);
247  fpCommandHiddenMarker->SetGuidance
248  ("If true, closer objects hide markers. Otherwise, markers always show.");
249  fpCommandHiddenMarker->SetParameterName("hidden-marker",omitable = true);
250  fpCommandHiddenMarker->SetDefaultValue(true);
251 
252  fpCommandLightsMove = new G4UIcmdWithAString
253  ("/vis/viewer/set/lightsMove",this);
254  fpCommandLightsMove->SetGuidance
255  ("Lights move with camera or with object");
256  fpCommandLightsMove->SetParameterName("lightsMove",omitable = false);
257  fpCommandLightsMove->SetCandidates
258  ("cam camera with-camera obj object with-object");
259 
260  fpCommandLightsThetaPhi = new G4UIcommand
261  ("/vis/viewer/set/lightsThetaPhi", this);
262  fpCommandLightsThetaPhi->SetGuidance
263  ("Set direction from target to lights.");
264  parameter = new G4UIparameter("theta", 'd', omitable = true);
265  parameter -> SetDefaultValue(60.);
266  fpCommandLightsThetaPhi -> SetParameter (parameter);
267  parameter = new G4UIparameter("phi", 'd', omitable = true);
268  parameter -> SetDefaultValue(45.);
269  fpCommandLightsThetaPhi -> SetParameter (parameter);
270  parameter = new G4UIparameter ("unit", 's', omitable = true);
271  parameter -> SetDefaultValue ("deg");
272  fpCommandLightsThetaPhi -> SetParameter (parameter);
273 
274  fpCommandLightsVector = new G4UIcommand
275  ("/vis/viewer/set/lightsVector", this);
276  fpCommandLightsVector->SetGuidance
277  ("Set direction from target to lights.");
278  parameter = new G4UIparameter("x", 'd', omitable = true);
279  parameter -> SetDefaultValue (1);
280  fpCommandLightsVector -> SetParameter (parameter);
281  parameter = new G4UIparameter("y", 'd', omitable = true);
282  parameter -> SetDefaultValue (1);
283  fpCommandLightsVector -> SetParameter (parameter);
284  parameter = new G4UIparameter ("z", 'd', omitable = true);
285  parameter -> SetDefaultValue (1);
286  fpCommandLightsVector -> SetParameter (parameter);
287 
288  fpCommandLineSegments = new G4UIcmdWithAnInteger
289  ("/vis/viewer/set/lineSegmentsPerCircle",this);
290  fpCommandLineSegments->SetGuidance
291  ("Set number of sides per circle for polygon/polyhedron drawing.");
292  fpCommandLineSegments->SetGuidance
293  ("Refers to graphical representation of objects with curved lines/surfaces.");
294  fpCommandLineSegments->SetParameterName("line-segments",omitable = true);
295  fpCommandLineSegments->SetDefaultValue(24);
296 
297  fpCommandPicking = new G4UIcmdWithABool
298  ("/vis/viewer/set/picking",this);
299  fpCommandPicking->SetGuidance("Sets picking, if available.");
300  fpCommandPicking->SetGuidance
301  ("If true, view is set up for picking, if available.");
302  fpCommandPicking->SetGuidance
303  ("You may need to issue \"/vis/viewer/update\".");
304  fpCommandPicking->SetGuidance
305  ("For required actions, watch for instructions for viewer.");
306  fpCommandPicking->SetParameterName("picking",omitable = true);
307  fpCommandPicking->SetDefaultValue(true);
308 
309  fpCommandProjection = new G4UIcommand("/vis/viewer/set/projection",this);
310  fpCommandProjection->SetGuidance
311  ("Orthogonal or perspective projection.");
312  parameter = new G4UIparameter("projection",'s',omitable = true);
313  parameter->SetParameterCandidates("o orthogonal p perspective");
314  parameter->SetDefaultValue("orthogonal");
315  fpCommandProjection->SetParameter(parameter);
316  parameter = new G4UIparameter("field-half-angle",'d',omitable = true);
317  parameter->SetDefaultValue(30.);
318  //parameter->SetCurrentAsDefault(true);
319  fpCommandProjection->SetParameter(parameter);
320  parameter = new G4UIparameter("unit",'s',omitable = true);
321  parameter->SetDefaultValue("deg");
322  //parameter->SetCurrentAsDefault(true);
323  fpCommandProjection->SetParameter(parameter);
324 
325  fpCommandRotationStyle = new G4UIcmdWithAString
326  ("/vis/viewer/set/rotationStyle",this);
327  fpCommandRotationStyle->SetGuidance
328  ("Set style of rotation - constrainUpDirection or freeRotation.");
329  fpCommandRotationStyle->SetGuidance
330  ("constrainUpDirection: conventional HEP view.");
331  fpCommandRotationStyle->SetGuidance
332  ("freeRotation: Google-like rotation, using mouse-grab.");
333  fpCommandRotationStyle->SetParameterName ("style",omitable = false);
334  fpCommandRotationStyle->SetCandidates("constrainUpDirection freeRotation");
335 
336  fpCommandSectionPlane = new G4UIcommand("/vis/viewer/set/sectionPlane",this);
337  fpCommandSectionPlane -> SetGuidance
338  ("Set plane for drawing section (DCUT).");
339  fpCommandSectionPlane -> SetGuidance
340  ("E.g., for a y-z plane at x = 1 cm:"
341  "\n\"/vis/viewer/set/sectionPlane on 1 0 0 cm 1 0 0\"."
342  "\nTo turn off: /vis/viewer/set/sectionPlane off");
343  parameter = new G4UIparameter("Selector",'c',true);
344  parameter -> SetDefaultValue ("on");
345  fpCommandSectionPlane->SetParameter(parameter);
346  parameter = new G4UIparameter("x",'d',omitable = true);
347  parameter -> SetDefaultValue (0);
348  parameter -> SetGuidance ("Coordinate of point on the plane.");
349  fpCommandSectionPlane->SetParameter(parameter);
350  parameter = new G4UIparameter("y",'d',omitable = true);
351  parameter -> SetDefaultValue (0);
352  parameter -> SetGuidance ("Coordinate of point on the plane.");
353  fpCommandSectionPlane->SetParameter(parameter);
354  parameter = new G4UIparameter("z",'d',omitable = true);
355  parameter -> SetDefaultValue (0);
356  parameter -> SetGuidance ("Coordinate of point on the plane.");
357  fpCommandSectionPlane->SetParameter(parameter);
358  parameter = new G4UIparameter("unit",'s',omitable = true);
359  parameter -> SetDefaultValue ("m");
360  parameter -> SetGuidance ("Unit of point on the plane.");
361  fpCommandSectionPlane->SetParameter(parameter);
362  parameter = new G4UIparameter("nx",'d',omitable = true);
363  parameter -> SetDefaultValue (1);
364  parameter -> SetGuidance ("Component of plane normal.");
365  fpCommandSectionPlane->SetParameter(parameter);
366  parameter = new G4UIparameter("ny",'d',omitable = true);
367  parameter -> SetDefaultValue (0);
368  parameter -> SetGuidance ("Component of plane normal.");
369  fpCommandSectionPlane->SetParameter(parameter);
370  parameter = new G4UIparameter("nz",'d',omitable = true);
371  parameter -> SetDefaultValue (0);
372  parameter -> SetGuidance ("Component of plane normal.");
373  fpCommandSectionPlane->SetParameter(parameter);
374 
375  fpCommandStyle = new G4UIcmdWithAString ("/vis/viewer/set/style",this);
376  fpCommandStyle->SetGuidance
377  ("Set style of drawing - w[ireframe] or s[urface].");
378  fpCommandStyle->SetGuidance
379  ("(Hidden line drawing is controlled by \"/vis/viewer/set/hiddenEdge\".)");
380  fpCommandStyle->SetParameterName ("style",omitable = false);
381 
382  fpCommandTargetPoint = new G4UIcmdWith3VectorAndUnit
383  ("/vis/viewer/set/targetPoint", this);
384  fpCommandTargetPoint->SetGuidance
385  ("Set target point.");
386  fpCommandTargetPoint->SetGuidance
387  ("This sets the \"Current Target Point\" relative to the \"Standard");
388  fpCommandTargetPoint->SetGuidance
389  ("Target Point\" so that the actual target point is as requested.");
390  fpCommandTargetPoint->SetGuidance
391  ("(See G4ViewParameters.hh for an explanation of target points.)");
392  fpCommandTargetPoint->SetParameterName("x", "y", "z", omitable = false);
393  fpCommandTargetPoint->SetUnitCategory("Length");
394 
395  fpCommandUpThetaPhi = new G4UIcommand
396  ("/vis/viewer/set/upThetaPhi", this);
397  fpCommandUpThetaPhi -> SetGuidance ("Set up vector.");
398  fpCommandUpThetaPhi -> SetGuidance
399  ("Viewer will attempt always to show this direction upwards.");
400  parameter = new G4UIparameter("theta", 'd', omitable = true);
401  parameter -> SetDefaultValue (90.);
402  fpCommandUpThetaPhi -> SetParameter (parameter);
403  parameter = new G4UIparameter("phi", 'd', omitable = true);
404  parameter -> SetDefaultValue (90.);
405  fpCommandUpThetaPhi -> SetParameter (parameter);
406  parameter = new G4UIparameter ("unit", 's', omitable = true);
407  parameter -> SetDefaultValue ("deg");
408  fpCommandUpThetaPhi -> SetParameter (parameter);
409 
410  fpCommandUpVector = new G4UIcommand
411  ("/vis/viewer/set/upVector", this);
412  fpCommandUpVector -> SetGuidance ("Set up vector.");
413  fpCommandUpVector -> SetGuidance
414  ("Viewer will attempt always to show this direction upwards.");
415  parameter = new G4UIparameter("x", 'd', omitable = true);
416  parameter -> SetDefaultValue (0.);
417  fpCommandUpVector -> SetParameter (parameter);
418  parameter = new G4UIparameter("y", 'd', omitable = true);
419  parameter -> SetDefaultValue (1.);
420  fpCommandUpVector -> SetParameter (parameter);
421  parameter = new G4UIparameter ("z", 'd', omitable = true);
422  parameter -> SetDefaultValue (0.);
423  fpCommandUpVector -> SetParameter (parameter);
424 
425  fpCommandViewpointThetaPhi = new G4UIcommand
426  ("/vis/viewer/set/viewpointThetaPhi", this);
427  fpCommandViewpointThetaPhi -> SetGuidance
428  ("Set direction from target to camera.");
429  fpCommandViewpointThetaPhi -> SetGuidance
430  ("Also changes lightpoint direction if lights are set to move with camera.");
431  parameter = new G4UIparameter("theta", 'd', omitable = true);
432  parameter -> SetDefaultValue (60.);
433  fpCommandViewpointThetaPhi -> SetParameter (parameter);
434  parameter = new G4UIparameter("phi", 'd', omitable = true);
435  parameter -> SetDefaultValue (45.);
436  fpCommandViewpointThetaPhi -> SetParameter (parameter);
437  parameter = new G4UIparameter ("unit", 's', omitable = true);
438  parameter -> SetDefaultValue ("deg");
439  fpCommandViewpointThetaPhi -> SetParameter (parameter);
440 
441  fpCommandViewpointVector = new G4UIcommand
442  ("/vis/viewer/set/viewpointVector", this);
443  fpCommandViewpointVector -> SetGuidance
444  ("Set direction from target to camera.");
445  fpCommandViewpointVector -> SetGuidance
446  ("Also changes lightpoint direction if lights are set to move with camera.");
447  parameter = new G4UIparameter("x", 'd', omitable = true);
448  parameter -> SetDefaultValue (1.);
449  fpCommandViewpointVector -> SetParameter (parameter);
450  parameter = new G4UIparameter("y", 'd', omitable = true);
451  parameter -> SetDefaultValue (1.);
452  fpCommandViewpointVector -> SetParameter (parameter);
453  parameter = new G4UIparameter ("z", 'd', omitable = true);
454  parameter -> SetDefaultValue (1.);
455  fpCommandViewpointVector -> SetParameter (parameter);
456 }
457 
459  delete fpCommandAll;
460  delete fpCommandAuxEdge;
461  delete fpCommandAutoRefresh;
462  delete fpCommandBackground;
463  delete fpCommandCulling;
464  delete fpCommandCutawayMode;
465  delete fpCommandDefaultColour;
466  delete fpCommandDefaultTextColour;
467  delete fpCommandEdge;
468  delete fpCommandExplodeFactor;
469  delete fpCommandGlobalLineWidthScale;
470  delete fpCommandGlobalMarkerScale;
471  delete fpCommandHiddenEdge;
472  delete fpCommandHiddenMarker;
473  delete fpCommandLineSegments;
474  delete fpCommandLightsMove;
475  delete fpCommandLightsThetaPhi;
476  delete fpCommandLightsVector;
477  delete fpCommandPicking;
478  delete fpCommandProjection;
479  delete fpCommandRotationStyle;
480  delete fpCommandSectionPlane;
481  delete fpCommandStyle;
482  delete fpCommandTargetPoint;
483  delete fpCommandUpThetaPhi;
484  delete fpCommandUpVector;
485  delete fpCommandViewpointThetaPhi;
486  delete fpCommandViewpointVector;
487 }
488 
490  return "";
491 }
492 
494 (G4UIcommand* command,G4String newValue) {
495 
496  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
497 
498  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
499  if (!currentViewer) {
500  if (verbosity >= G4VisManager::errors) {
501  G4cout <<
502  "ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer."
503  << G4endl;
504  }
505  return;
506  }
507 
508  G4ViewParameters vp = currentViewer->GetViewParameters();
509 
510  if (command == fpCommandAll) {
511  G4VViewer* fromViewer = fpVisManager->GetViewer(newValue);
512  if (!fromViewer) {
513  if (verbosity >= G4VisManager::errors) {
514  G4cout <<
515  "ERROR: G4VisCommandsViewerSet::SetNewValue: all:"
516  "\n unrecognised from-viewer."
517  << G4endl;
518  }
519  return;
520  }
521  if (fromViewer == currentViewer) {
522  if (verbosity >= G4VisManager::warnings) {
523  G4cout <<
524  "WARNING: G4VisCommandsViewerSet::SetNewValue: all:"
525  "\n from-viewer and current viewer are identical."
526  << G4endl;
527  }
528  return;
529  }
530  // Copy view parameters except for autoRefresh...
531  G4bool currentAutoRefresh =
532  currentViewer->GetViewParameters().IsAutoRefresh();
533  vp = fromViewer->GetViewParameters();
534  vp.SetAutoRefresh(currentAutoRefresh);
535  if (verbosity >= G4VisManager::confirmations) {
536  G4cout << "View parameters of viewer \"" << currentViewer->GetName()
537  << "\"\n set to those of viewer \"" << fromViewer->GetName()
538  << "\"."
539  << G4endl;
540  }
541  }
542 
543  else if (command == fpCommandAutoRefresh) {
544  G4bool autoRefresh = G4UIcommand::ConvertToBool(newValue);
545  const G4ViewParameters& defaultVP =
546  currentViewer->GetDefaultViewParameters();
547  if (autoRefresh && !defaultVP.IsAutoRefresh()) {
548  if (verbosity >= G4VisManager::warnings) {
549  G4cout
550  << "WARNING: "
551  << currentViewer->GetName() << " is NOT auto-refesh by default"
552  << "\n so cannot be set to auto-refresh."
553  << G4endl;
554  return;
555  }
556  }
557  vp.SetAutoRefresh(autoRefresh);
558  if (verbosity >= G4VisManager::confirmations) {
559  G4cout << "Views will ";
560  if (!vp.IsAutoRefresh()) G4cout << "not ";
561  G4cout << "be automatically refreshed after a change of view parameters."
562  << G4endl;
563  }
564  if (!vp.IsAutoRefresh()) {
565  currentViewer->SetViewParameters(vp);
566  return; // Avoid a refresh if auto-refresh has been set to off...
567  } // ...otherwise take normal action.
568  }
569 
570  else if (command == fpCommandAuxEdge) {
572  if (verbosity >= G4VisManager::confirmations) {
573  G4cout << "Auxiliary edges will ";
574  if (!vp.IsAuxEdgeVisible()) G4cout << "not ";
575  G4cout << "be visible." << G4endl;
576  }
577  }
578 
579  else if (command == fpCommandBackground) {
580  G4String redOrString;
581  G4double green, blue, opacity;
582  std::istringstream iss(newValue);
583  iss >> redOrString >> green >> blue >> opacity;
584  G4Colour colour(0.,0.,0.); // Default black and opaque.
585  const size_t iPos0 = 0;
586  if (std::isalpha(redOrString[iPos0])) {
587  if (!G4Colour::GetColour(redOrString, colour)) {
588  if (verbosity >= G4VisManager::warnings) {
589  G4cout << "WARNING: Text colour \"" << redOrString
590  << "\" not found. Defaulting to black and opaque."
591  << G4endl;
592  }
593  }
594  } else {
595  colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
596  }
597  // Add opacity
598  colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
599  vp.SetBackgroundColour(colour);
600  if (verbosity >= G4VisManager::confirmations) {
601  G4cout << "Background colour "
602  << vp.GetBackgroundColour()
603  << " requested."
604  << G4endl;
605  }
606  }
607 
608  else if (command == fpCommandCulling) {
609  G4String cullingOption, stringFlag, unit;
611  std::istringstream is (newValue);
612  is >> cullingOption >> stringFlag >> density >> unit;
613  G4bool boolFlag = G4UIcommand::ConvertToBool(stringFlag);
614  if (cullingOption == "global") {
615  vp.SetCulling(boolFlag);
616  if (verbosity >= G4VisManager::confirmations) {
617  G4cout <<
618  "G4VisCommandsViewerSet::SetNewValue: culling: global culling flag"
619  " set to " << G4UIcommand::ConvertToString(boolFlag) <<
620  ".\n Does not change specific culling flags."
621  << G4endl;
622  }
623  }
624  else if (cullingOption == "coveredDaughters") {
625  vp.SetCullingCovered(boolFlag);
626  if (verbosity >= G4VisManager::confirmations) {
627  G4cout <<
628  "G4VisCommandsViewerSet::SetNewValue: culling: culling covered"
629  "\n daughters flag set to "
630  << G4UIcommand::ConvertToString(boolFlag) <<
631  ". Daughters covered by opaque mothers"
632  "\n will be culled, i.e., not drawn, if this flag is true."
633  "\n Note: this is only effective in surface drawing style,"
634  "\n and then only if the volumes are visible and opaque, and then"
635  "\n only if no sections or cutaways are in operation."
636  << G4endl;
637  }
638  }
639  else if (cullingOption == "invisible") {
640  vp.SetCullingInvisible(boolFlag);
641  if (verbosity >= G4VisManager::confirmations) {
642  G4cout <<
643  "G4VisCommandsViewerSet::SetNewValue: culling: culling invisible"
644  "\n flag set to "
645  << boolFlag << G4UIcommand::ConvertToString(boolFlag) <<
646  ". Volumes marked invisible will be culled,"
647  "\n i.e., not drawn, if this flag is true."
648  << G4endl;
649  }
650  }
651  else if (cullingOption == "density") {
652  vp.SetDensityCulling(boolFlag);
653  if (boolFlag) {
654  density *= G4UnitDefinition::GetValueOf(unit);
655  vp.SetVisibleDensity(density);
656  }
657  else {
658  density = vp.GetVisibleDensity();
659  }
660  if (verbosity >= G4VisManager::confirmations) {
661  G4cout <<
662  "G4VisCommandsViewerSet::SetNewValue: culling: culling by density"
663  "\n flag set to " << G4UIcommand::ConvertToString(boolFlag) <<
664  ". Volumes with density less than " <<
665  G4BestUnit(density,"Volumic Mass") <<
666  "\n will be culled, i.e., not drawn, if this flag is true."
667  << G4endl;
668  }
669  }
670  else {
671  if (verbosity >= G4VisManager::errors) {
672  G4cout <<
673  "ERROR: G4VisCommandsViewerSet::SetNewValue: culling:"
674  "\n option not recognised."
675  << G4endl;
676  }
677  }
678  }
679 
680  else if (command == fpCommandCutawayMode) {
681  if (newValue == "add" || newValue == "union")
683  if (newValue == "multiply" || newValue == "intersection")
685 
686  if (verbosity >= G4VisManager::confirmations) {
687  G4cout << "Cutaway mode set to ";
689  G4cout << "cutawayUnion";
691  G4cout << "cutawayIntersection";
692  G4cout << G4endl;
693  }
694  }
695 
696  else if (command == fpCommandDefaultColour) {
697  G4String redOrString;
698  G4double green, blue, opacity;
699  std::istringstream iss(newValue);
700  iss >> redOrString >> green >> blue >> opacity;
701  G4Colour colour(1.,1.,1.); // Default white and opaque.
702  const size_t iPos0 = 0;
703  if (std::isalpha(redOrString[iPos0])) {
704  if (!G4Colour::GetColour(redOrString, colour)) {
705  if (verbosity >= G4VisManager::warnings) {
706  G4cout << "WARNING: Text colour \"" << redOrString
707  << "\" not found. Defaulting to white and opaque."
708  << G4endl;
709  }
710  }
711  } else {
712  colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
713  }
714  // Add opacity
715  colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
717  va.SetColour(colour);
719  if (verbosity >= G4VisManager::confirmations) {
720  G4cout << "Default colour "
722  << " requested."
723  << G4endl;
724  }
725  }
726 
727  else if (command == fpCommandDefaultTextColour) {
728  G4String redOrString;
729  G4double green, blue, opacity;
730  std::istringstream iss(newValue);
731  iss >> redOrString >> green >> blue >> opacity;
732  G4Colour colour(1.,1.,1.); // Default white and opaque.
733  const size_t iPos0 = 0;
734  if (std::isalpha(redOrString[iPos0])) {
735  if (!G4Colour::GetColour(redOrString, colour)) {
736  if (verbosity >= G4VisManager::warnings) {
737  G4cout << "WARNING: Text colour \"" << redOrString
738  << "\" not found. Defaulting to white and opaque."
739  << G4endl;
740  }
741  }
742  } else {
743  colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
744  }
745  // Add opacity
746  colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
748  va.SetColour(colour);
750  if (verbosity >= G4VisManager::confirmations) {
751  G4cout << "Default colour "
753  << " requested."
754  << G4endl;
755  }
756  }
757 
758  else if (command == fpCommandEdge) {
759  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
760  if (G4UIcommand::ConvertToBool(newValue)) {
761  switch (existingStyle) {
763  break;
765  break;
768  break;
770  break;
771  }
772  }
773  else {
774  switch (existingStyle) {
776  break;
778  break;
780  break;
783  break;
784  }
785  }
786  if (verbosity >= G4VisManager::confirmations) {
787  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
788  << "\" set to " << vp.GetDrawingStyle()
789  << G4endl;
790  }
791  }
792 
793  else if (command == fpCommandExplodeFactor) {
794  G4double explodeFactor, x, y, z;
795  G4String unitString;
796  std::istringstream is (newValue);
797  is >> explodeFactor >> x >> y >> z >> unitString;
798  G4double unit = G4UIcommand::ValueOf(unitString);
799  vp.SetExplodeFactor(explodeFactor);
800  vp.SetExplodeCentre(G4Point3D(x * unit, y * unit, z * unit));
801  if (verbosity >= G4VisManager::confirmations) {
802  G4cout << "Explode factor changed to " << vp.GetExplodeFactor()
803  << " from centre " << vp.GetExplodeCentre()
804  << G4endl;
805  }
806  }
807 
808  else if (command == fpCommandGlobalLineWidthScale) {
809  G4double globalLineWidthScale
810  = fpCommandGlobalLineWidthScale->GetNewDoubleValue(newValue);
811  vp.SetGlobalLineWidthScale(globalLineWidthScale);
812  if (verbosity >= G4VisManager::confirmations) {
813  G4cout << "Global Line Width Scale changed to "
814  << vp.GetGlobalLineWidthScale() << G4endl;
815  }
816  }
817 
818  else if (command == fpCommandGlobalMarkerScale) {
819  G4double globalMarkerScale
820  = fpCommandGlobalMarkerScale->GetNewDoubleValue(newValue);
821  vp.SetGlobalMarkerScale(globalMarkerScale);
822  if (verbosity >= G4VisManager::confirmations) {
823  G4cout << "Global Marker Scale changed to "
824  << vp.GetGlobalMarkerScale() << G4endl;
825  }
826  }
827 
828  else if (command == fpCommandHiddenEdge) {
829  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
830  if (G4UIcommand::ConvertToBool(newValue)) {
831  switch (existingStyle) {
834  break;
836  break;
839  break;
841  break;
842  }
843  }
844  else {
845  switch (existingStyle) {
847  break;
850  break;
852  break;
855  break;
856  }
857  }
858  if (verbosity >= G4VisManager::confirmations) {
859  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
860  << "\" set to " << vp.GetDrawingStyle()
861  << G4endl;
862  }
863  }
864 
865  else if (command == fpCommandHiddenMarker) {
866  G4bool hidden = G4UIcommand::ConvertToBool(newValue);
867  if (hidden) vp.SetMarkerHidden();
868  else vp.SetMarkerNotHidden();
869  if (verbosity >= G4VisManager::confirmations) {
870  G4cout << "Markers will ";
871  if (vp.IsMarkerNotHidden()) G4cout << "not ";
872  G4cout << "be hidden under solid objects." << G4endl;
873  }
874  }
875 
876  else if (command == fpCommandLightsMove) {
877  if (newValue.find("cam") != G4String::npos)
878  vp.SetLightsMoveWithCamera(true);
879  else if(newValue.find("obj") != G4String::npos)
880  vp.SetLightsMoveWithCamera(false);
881  else {
882  if (verbosity >= G4VisManager::errors) {
883  G4cout << "ERROR: \"" << newValue << "\" not recognised."
884  " Looking for \"cam\" or \"obj\" in string." << G4endl;
885  }
886  }
887  if (verbosity >= G4VisManager::confirmations) {
888  G4cout << "Lights move with ";
889  if (vp.GetLightsMoveWithCamera())
890  G4cout << "camera (object appears to rotate).";
891  else G4cout << "object (the viewer appears to be moving).";
892  G4cout << G4endl;
893  }
894  }
895 
896  else if (command == fpCommandLightsThetaPhi) {
897  G4double theta, phi;
898  ConvertToDoublePair(newValue, theta, phi);
899  G4double x = std::sin (theta) * std::cos (phi);
900  G4double y = std::sin (theta) * std::sin (phi);
901  G4double z = std::cos (theta);
902  fLightsVector = G4ThreeVector (x, y, z);
903  vp.SetLightpointDirection(fLightsVector);
904  if (verbosity >= G4VisManager::confirmations) {
905  G4cout << "Lights direction set to "
906  << vp.GetLightpointDirection() << G4endl;
907  }
908  }
909 
910  else if (command == fpCommandLightsVector) {
911  fLightsVector = G4UIcommand::ConvertTo3Vector(newValue);
912  vp.SetLightpointDirection(fLightsVector);
913  if (verbosity >= G4VisManager::confirmations) {
914  G4cout << "Lights direction set to "
915  << vp.GetLightpointDirection() << G4endl;
916  }
917  }
918 
919  else if (command == fpCommandLineSegments) {
920  G4int nSides = G4UIcommand::ConvertToInt(newValue);
921  nSides = vp.SetNoOfSides(nSides);
922  if (verbosity >= G4VisManager::confirmations) {
923  G4cout <<
924  "Number of line segements per circle in polygon approximation is "
925  << nSides << G4endl;
926  }
927  }
928 
929  else if (command == fpCommandPicking) {
931  if (verbosity >= G4VisManager::confirmations) {
932  G4cout << "Picking ";
933  if (vp.IsPicking()) G4cout << "requested.";
934  else G4cout << "inhibited.";
935  G4cout << G4endl;
936  }
937  if (verbosity >= G4VisManager::warnings) {
938  G4cout << "You may need to issue \"/vis/viewer/update\"."
939  << G4endl;
940  }
941  }
942 
943  else if (command == fpCommandProjection) {
944  G4double fieldHalfAngle;
945  const size_t iPos0 = 0;
946  if (newValue[iPos0] == 'o') { // "orthogonal"
947  fieldHalfAngle = 0.;
948  }
949  else if (newValue[iPos0] == 'p') { // "perspective"
950  G4String dummy;
951  G4String unit;
952  std::istringstream is (newValue);
953  is >> dummy >> fieldHalfAngle >> unit;
954  fieldHalfAngle *= G4UIcommand::ValueOf(unit);
955  if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
956  if (verbosity >= G4VisManager::errors) {
957  G4cout <<
958  "ERROR: Field half angle should be 0 < angle <= 89.5 degrees.";
959  G4cout << G4endl;
960  }
961  return;
962  }
963  }
964  else {
965  if (verbosity >= G4VisManager::errors) {
966  G4cout << "ERROR: \"" << newValue << "\" not recognised."
967  " Looking for 'o' or 'p' first character." << G4endl;
968  }
969  return;
970  }
971  vp.SetFieldHalfAngle(fieldHalfAngle);
972  if (verbosity >= G4VisManager::confirmations) {
973  G4cout << "Projection style of viewer \"" << currentViewer->GetName()
974  << "\" set to ";
975  if (fieldHalfAngle == 0.) {
976  G4cout << "orthogonal.";
977  }
978  else {
979  G4cout << "perspective\n with half angle " << fieldHalfAngle / deg
980  << " degrees.";
981  }
982  G4cout << G4endl;
983  }
984  }
985 
986  else if (command == fpCommandSectionPlane) {
987  G4String choice, unit;
988  G4double x, y, z, nx, ny, nz;
989  std::istringstream is (newValue);
990  is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
991 
992  G4int iSelector = -1;
993  if (choice.compareTo("off",G4String::ignoreCase) == 0 ||
994  !G4UIcommand::ConvertToBool(choice)) iSelector = 0;
995  if (choice.compareTo("on",G4String::ignoreCase) == 0 ||
996  G4UIcommand::ConvertToBool(choice)) iSelector = 1;
997  if (iSelector < 0) {
998  if (verbosity >= G4VisManager::errors) {
999  G4cout << "Choice not recognised (on/true or off/false)." << G4endl;
1000  G4cout << "Section drawing is currently: ";
1001  if (vp.IsSection ()) G4cout << "on";
1002  else G4cout << "off";
1003  G4cout << ".\nSection plane is currently: "
1004  << vp.GetSectionPlane ();
1005  G4cout << G4endl;
1006  }
1007  return;
1008  }
1009 
1010  G4double F = 1.;
1011  // iSelector can only be 0 or 1
1012  switch (iSelector) {
1013  case 0:
1014  vp.UnsetSectionPlane();
1015  break;
1016  case 1:
1017  F = G4UIcommand::ValueOf(unit);
1018  x *= F; y *= F; z *= F;
1019  vp.SetSectionPlane(G4Plane3D(G4Normal3D(nx,ny,nz), G4Point3D(x,y,z)));
1020  vp.SetViewpointDirection(G4Normal3D(nx,ny,nz));
1021  break;
1022  }
1023 
1024  if (verbosity >= G4VisManager::confirmations) {
1025  G4cout << "Section drawing is now: ";
1026  if (vp.IsSection ()) G4cout << "on";
1027  else G4cout << "off";
1028  G4cout << ".\nSection plane is now: "
1029  << vp.GetSectionPlane ();
1030  G4cout << G4endl;
1031  }
1032  }
1033 
1034  else if (command == fpCommandRotationStyle) {
1036  if (newValue == "constrainUpDirection")
1038  else if (newValue == "freeRotation")
1040  else {
1041  if (verbosity >= G4VisManager::errors) {
1042  G4cout << "ERROR: \"" << newValue << "\" not recognised." << G4endl;
1043  }
1044  return;
1045  }
1046  vp.SetRotationStyle(style);
1047  if (verbosity >= G4VisManager::confirmations) {
1048  G4cout << "Rotation style of viewer \"" << currentViewer->GetName()
1049  << "\" set to " << vp.GetRotationStyle()
1050  << G4endl;
1051  }
1052  }
1053 
1054  else if (command == fpCommandStyle) {
1055  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
1056  const size_t iPos0 = 0;
1057  if (newValue[iPos0] == 'w') { // "wireframe"
1058  switch (existingStyle) {
1060  break;
1061  case G4ViewParameters::hlr:
1062  break;
1063  case G4ViewParameters::hsr:
1065  break;
1068  break;
1069  }
1070  }
1071  else if (newValue[iPos0] == 's') { // "surface"
1072  switch (existingStyle) {
1075  break;
1076  case G4ViewParameters::hlr:
1078  break;
1079  case G4ViewParameters::hsr:
1080  break;
1082  break;
1083  }
1084  }
1085  else {
1086  if (verbosity >= G4VisManager::errors) {
1087  G4cout << "ERROR: \"" << newValue << "\" not recognised."
1088  " Looking for 'w' or 's' first character." << G4endl;
1089  }
1090  return;
1091  }
1092  if (verbosity >= G4VisManager::confirmations) {
1093  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
1094  << "\" set to " << vp.GetDrawingStyle()
1095  << G4endl;
1096  }
1097  }
1098 
1099  else if (command == fpCommandTargetPoint) {
1100  G4ThreeVector targetPoint =
1101  fpCommandTargetPoint->GetNew3VectorValue(newValue);
1102  const G4Point3D& standardTargetPoint =
1103  currentViewer->GetSceneHandler()->GetScene()->GetStandardTargetPoint();
1104  vp.SetCurrentTargetPoint(targetPoint - standardTargetPoint);
1105  if (verbosity >= G4VisManager::confirmations) {
1106  G4cout << "Target point set to "
1107  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1108  (targetPoint)
1109  << "\n\"Current Target Point\" set to "
1110  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1111  (vp.GetCurrentTargetPoint())
1112  << "\n\"Standard Target Point\" is "
1113  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1114  (standardTargetPoint)
1115  << G4endl;
1116  }
1117  }
1118 
1119  else if (command == fpCommandUpThetaPhi) {
1120  G4double theta, phi;
1121  ConvertToDoublePair(newValue, theta, phi);
1122  G4double x = std::sin (theta) * std::cos (phi);
1123  G4double y = std::sin (theta) * std::sin (phi);
1124  G4double z = std::cos (theta);
1125  fUpVector = G4ThreeVector (x, y, z);
1126  vp.SetUpVector(fUpVector);
1127  if (verbosity >= G4VisManager::confirmations) {
1128  G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1129  }
1130  }
1131 
1132  else if (command == fpCommandUpVector) {
1133  fUpVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
1134  vp.SetUpVector(fUpVector);
1135  if (verbosity >= G4VisManager::confirmations) {
1136  G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1137  }
1138  }
1139 
1140  else if (command == fpCommandViewpointThetaPhi) {
1141  G4double theta, phi;
1142  ConvertToDoublePair(newValue, theta, phi);
1143  G4double x = std::sin (theta) * std::cos (phi);
1144  G4double y = std::sin (theta) * std::sin (phi);
1145  G4double z = std::cos (theta);
1146  fViewpointVector = G4ThreeVector (x, y, z);
1147  vp.SetViewAndLights(fViewpointVector);
1148  if (verbosity >= G4VisManager::confirmations) {
1149  G4cout << "Viewpoint direction set to "
1150  << vp.GetViewpointDirection() << G4endl;
1151  if (vp.GetLightsMoveWithCamera ()) {
1152  G4cout << "Lightpoint direction set to "
1154  }
1155  }
1156  }
1157 
1158  else if (command == fpCommandViewpointVector) {
1159  fViewpointVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
1160  vp.SetViewAndLights(fViewpointVector);
1161  if (verbosity >= G4VisManager::confirmations) {
1162  G4cout << "Viewpoint direction set to "
1163  << vp.GetViewpointDirection() << G4endl;
1164  if (vp.GetLightsMoveWithCamera ()) {
1165  G4cout << "Lightpoint direction set to "
1167  }
1168  }
1169  }
1170 
1171  else {
1172  if (verbosity >= G4VisManager::errors) {
1173  G4cout <<
1174  "ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command."
1175  << G4endl;
1176  }
1177  return;
1178  }
1179 
1180  SetViewParameters(currentViewer,vp);
1181 }