Geant4  10.03.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: G4VisCommandsViewerSet.cc 101035 2016-11-04 08:48:17Z gcosmo $
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(72);
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  ("Set projection style - o[rthogonal] or p[erspective]."
312  "\nIf p[erspective], also set field half angle.");
313  parameter = new G4UIparameter("projection",'s',omitable = true);
314  parameter->SetParameterCandidates("o orthogonal p perspective");
315  parameter->SetDefaultValue("orthogonal");
316  fpCommandProjection->SetParameter(parameter);
317  parameter = new G4UIparameter("field-half-angle",'d',omitable = true);
318  parameter->SetDefaultValue(30.);
319  //parameter->SetCurrentAsDefault(true);
320  fpCommandProjection->SetParameter(parameter);
321  parameter = new G4UIparameter("unit",'s',omitable = true);
322  parameter->SetDefaultValue("deg");
323  //parameter->SetCurrentAsDefault(true);
324  fpCommandProjection->SetParameter(parameter);
325 
326  fpCommandRotationStyle = new G4UIcmdWithAString
327  ("/vis/viewer/set/rotationStyle",this);
328  fpCommandRotationStyle->SetGuidance
329  ("Set style of rotation - constrainUpDirection or freeRotation.");
330  fpCommandRotationStyle->SetGuidance
331  ("constrainUpDirection: conventional HEP view.");
332  fpCommandRotationStyle->SetGuidance
333  ("freeRotation: Google-like rotation, using mouse-grab.");
334  fpCommandRotationStyle->SetParameterName ("style",omitable = false);
335  fpCommandRotationStyle->SetCandidates("constrainUpDirection freeRotation");
336 
337  fpCommandSectionPlane = new G4UIcommand("/vis/viewer/set/sectionPlane",this);
338  fpCommandSectionPlane -> SetGuidance
339  ("Set plane for drawing section (DCUT).");
340  fpCommandSectionPlane -> SetGuidance
341  ("E.g., for a y-z plane at x = 1 cm:"
342  "\n\"/vis/viewer/set/sectionPlane on 1 0 0 cm 1 0 0\"."
343  "\nTo turn off: /vis/viewer/set/sectionPlane off");
344  parameter = new G4UIparameter("Selector",'c',true);
345  parameter -> SetDefaultValue ("on");
346  fpCommandSectionPlane->SetParameter(parameter);
347  parameter = new G4UIparameter("x",'d',omitable = true);
348  parameter -> SetDefaultValue (0);
349  parameter -> SetGuidance ("Coordinate of point on the plane.");
350  fpCommandSectionPlane->SetParameter(parameter);
351  parameter = new G4UIparameter("y",'d',omitable = true);
352  parameter -> SetDefaultValue (0);
353  parameter -> SetGuidance ("Coordinate of point on the plane.");
354  fpCommandSectionPlane->SetParameter(parameter);
355  parameter = new G4UIparameter("z",'d',omitable = true);
356  parameter -> SetDefaultValue (0);
357  parameter -> SetGuidance ("Coordinate of point on the plane.");
358  fpCommandSectionPlane->SetParameter(parameter);
359  parameter = new G4UIparameter("unit",'s',omitable = true);
360  parameter -> SetDefaultValue ("m");
361  parameter -> SetGuidance ("Unit of point on the plane.");
362  fpCommandSectionPlane->SetParameter(parameter);
363  parameter = new G4UIparameter("nx",'d',omitable = true);
364  parameter -> SetDefaultValue (1);
365  parameter -> SetGuidance ("Component of plane normal.");
366  fpCommandSectionPlane->SetParameter(parameter);
367  parameter = new G4UIparameter("ny",'d',omitable = true);
368  parameter -> SetDefaultValue (0);
369  parameter -> SetGuidance ("Component of plane normal.");
370  fpCommandSectionPlane->SetParameter(parameter);
371  parameter = new G4UIparameter("nz",'d',omitable = true);
372  parameter -> SetDefaultValue (0);
373  parameter -> SetGuidance ("Component of plane normal.");
374  fpCommandSectionPlane->SetParameter(parameter);
375 
376  fpCommandStyle = new G4UIcmdWithAString ("/vis/viewer/set/style",this);
377  fpCommandStyle->SetGuidance
378  ("Set style of drawing - w[ireframe] or s[urface].");
379  fpCommandStyle->SetGuidance
380  ("(Hidden line drawing is controlled by \"/vis/viewer/set/hiddenEdge\".)");
381  fpCommandStyle->SetParameterName ("style",omitable = false);
382  fpCommandStyle->SetCandidates("w wireframe s surface");
383 
384  fpCommandTargetPoint = new G4UIcmdWith3VectorAndUnit
385  ("/vis/viewer/set/targetPoint", this);
386  fpCommandTargetPoint->SetGuidance
387  ("Set target point.");
388  fpCommandTargetPoint->SetGuidance
389  ("This sets the \"Current Target Point\" relative to the \"Standard");
390  fpCommandTargetPoint->SetGuidance
391  ("Target Point\" so that the actual target point is as requested.");
392  fpCommandTargetPoint->SetGuidance
393  ("(See G4ViewParameters.hh for an explanation of target points.)");
394  fpCommandTargetPoint->SetParameterName("x", "y", "z", omitable = false);
395  fpCommandTargetPoint->SetUnitCategory("Length");
396 
397  fpCommandUpThetaPhi = new G4UIcommand
398  ("/vis/viewer/set/upThetaPhi", this);
399  fpCommandUpThetaPhi -> SetGuidance ("Set up vector.");
400  fpCommandUpThetaPhi -> SetGuidance
401  ("Viewer will attempt always to show this direction upwards.");
402  parameter = new G4UIparameter("theta", 'd', omitable = true);
403  parameter -> SetDefaultValue (90.);
404  fpCommandUpThetaPhi -> SetParameter (parameter);
405  parameter = new G4UIparameter("phi", 'd', omitable = true);
406  parameter -> SetDefaultValue (90.);
407  fpCommandUpThetaPhi -> SetParameter (parameter);
408  parameter = new G4UIparameter ("unit", 's', omitable = true);
409  parameter -> SetDefaultValue ("deg");
410  fpCommandUpThetaPhi -> SetParameter (parameter);
411 
412  fpCommandUpVector = new G4UIcommand
413  ("/vis/viewer/set/upVector", this);
414  fpCommandUpVector -> SetGuidance ("Set up vector.");
415  fpCommandUpVector -> SetGuidance
416  ("Viewer will attempt always to show this direction upwards.");
417  parameter = new G4UIparameter("x", 'd', omitable = true);
418  parameter -> SetDefaultValue (0.);
419  fpCommandUpVector -> SetParameter (parameter);
420  parameter = new G4UIparameter("y", 'd', omitable = true);
421  parameter -> SetDefaultValue (1.);
422  fpCommandUpVector -> SetParameter (parameter);
423  parameter = new G4UIparameter ("z", 'd', omitable = true);
424  parameter -> SetDefaultValue (0.);
425  fpCommandUpVector -> SetParameter (parameter);
426 
427  fpCommandViewpointThetaPhi = new G4UIcommand
428  ("/vis/viewer/set/viewpointThetaPhi", this);
429  fpCommandViewpointThetaPhi -> SetGuidance
430  ("Set direction from target to camera.");
431  fpCommandViewpointThetaPhi -> SetGuidance
432  ("Also changes lightpoint direction if lights are set to move with camera.");
433  parameter = new G4UIparameter("theta", 'd', omitable = true);
434  parameter -> SetDefaultValue (60.);
435  fpCommandViewpointThetaPhi -> SetParameter (parameter);
436  parameter = new G4UIparameter("phi", 'd', omitable = true);
437  parameter -> SetDefaultValue (45.);
438  fpCommandViewpointThetaPhi -> SetParameter (parameter);
439  parameter = new G4UIparameter ("unit", 's', omitable = true);
440  parameter -> SetDefaultValue ("deg");
441  fpCommandViewpointThetaPhi -> SetParameter (parameter);
442 
443  fpCommandViewpointVector = new G4UIcommand
444  ("/vis/viewer/set/viewpointVector", this);
445  fpCommandViewpointVector -> SetGuidance
446  ("Set direction from target to camera.");
447  fpCommandViewpointVector -> SetGuidance
448  ("Also changes lightpoint direction if lights are set to move with camera.");
449  parameter = new G4UIparameter("x", 'd', omitable = true);
450  parameter -> SetDefaultValue (1.);
451  fpCommandViewpointVector -> SetParameter (parameter);
452  parameter = new G4UIparameter("y", 'd', omitable = true);
453  parameter -> SetDefaultValue (1.);
454  fpCommandViewpointVector -> SetParameter (parameter);
455  parameter = new G4UIparameter ("z", 'd', omitable = true);
456  parameter -> SetDefaultValue (1.);
457  fpCommandViewpointVector -> SetParameter (parameter);
458 }
459 
461  delete fpCommandAll;
462  delete fpCommandAuxEdge;
463  delete fpCommandAutoRefresh;
464  delete fpCommandBackground;
465  delete fpCommandCulling;
466  delete fpCommandCutawayMode;
467  delete fpCommandDefaultColour;
468  delete fpCommandDefaultTextColour;
469  delete fpCommandEdge;
470  delete fpCommandExplodeFactor;
471  delete fpCommandGlobalLineWidthScale;
472  delete fpCommandGlobalMarkerScale;
473  delete fpCommandHiddenEdge;
474  delete fpCommandHiddenMarker;
475  delete fpCommandLineSegments;
476  delete fpCommandLightsMove;
477  delete fpCommandLightsThetaPhi;
478  delete fpCommandLightsVector;
479  delete fpCommandPicking;
480  delete fpCommandProjection;
481  delete fpCommandRotationStyle;
482  delete fpCommandSectionPlane;
483  delete fpCommandStyle;
484  delete fpCommandTargetPoint;
485  delete fpCommandUpThetaPhi;
486  delete fpCommandUpVector;
487  delete fpCommandViewpointThetaPhi;
488  delete fpCommandViewpointVector;
489 }
490 
492  return "";
493 }
494 
496 (G4UIcommand* command,G4String newValue) {
497 
498  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
499 
500  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
501  if (!currentViewer) {
502  if (verbosity >= G4VisManager::errors) {
503  G4cerr <<
504  "ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer."
505  << G4endl;
506  }
507  return;
508  }
509 
510  G4ViewParameters vp = currentViewer->GetViewParameters();
511 
512  if (command == fpCommandAll) {
513  G4VViewer* fromViewer = fpVisManager->GetViewer(newValue);
514  if (!fromViewer) {
515  if (verbosity >= G4VisManager::errors) {
516  G4cerr <<
517  "ERROR: G4VisCommandsViewerSet::SetNewValue: all:"
518  "\n unrecognised from-viewer."
519  << G4endl;
520  }
521  return;
522  }
523  if (fromViewer == currentViewer) {
524  if (verbosity >= G4VisManager::warnings) {
525  G4cout <<
526  "WARNING: G4VisCommandsViewerSet::SetNewValue: all:"
527  "\n from-viewer and current viewer are identical."
528  << G4endl;
529  }
530  return;
531  }
532  // Copy view parameters except for autoRefresh...
533  G4bool currentAutoRefresh =
534  currentViewer->GetViewParameters().IsAutoRefresh();
535  vp = fromViewer->GetViewParameters();
536  vp.SetAutoRefresh(currentAutoRefresh);
537  // Concatenate any private vis attributes modifiers...
538  const std::vector<G4ModelingParameters::VisAttributesModifier>*
539  privateVAMs = fromViewer->GetPrivateVisAttributesModifiers();
540  if (privateVAMs) {
541  std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
542  for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
544  }
545  }
546  if (verbosity >= G4VisManager::confirmations) {
547  G4cout << "View parameters of viewer \"" << currentViewer->GetName()
548  << "\"\n set to those of viewer \"" << fromViewer->GetName()
549  << "\"."
550  << G4endl;
551  }
552  }
553 
554  else if (command == fpCommandAutoRefresh) {
555  G4bool autoRefresh = G4UIcommand::ConvertToBool(newValue);
556  const G4ViewParameters& defaultVP =
557  currentViewer->GetDefaultViewParameters();
558  if (autoRefresh && !defaultVP.IsAutoRefresh()) {
559  if (verbosity >= G4VisManager::warnings) {
560  G4cout
561  << "WARNING: "
562  << currentViewer->GetName() << " is NOT auto-refesh by default"
563  << "\n so cannot be set to auto-refresh."
564  << G4endl;
565  }
566  return;
567  }
568  vp.SetAutoRefresh(autoRefresh);
569  if (verbosity >= G4VisManager::confirmations) {
570  G4cout << "Views will ";
571  if (!vp.IsAutoRefresh()) G4cout << "not ";
572  G4cout << "be automatically refreshed after a change of view parameters."
573  << G4endl;
574  }
575  if (!vp.IsAutoRefresh()) {
576  currentViewer->SetViewParameters(vp);
577  return; // Avoid a refresh if auto-refresh has been set to off...
578  } // ...otherwise take normal action.
579  }
580 
581  else if (command == fpCommandAuxEdge) {
583  if (verbosity >= G4VisManager::confirmations) {
584  G4cout << "Auxiliary edges will ";
585  if (!vp.IsAuxEdgeVisible()) G4cout << "not ";
586  G4cout << "be visible." << G4endl;
587  }
588  }
589 
590  else if (command == fpCommandBackground) {
591  G4String redOrString;
592  G4double green, blue, opacity;
593  std::istringstream iss(newValue);
594  iss >> redOrString >> green >> blue >> opacity;
595  G4Colour colour(0.,0.,0.); // Default black and opaque.
596  const size_t iPos0 = 0;
597  if (std::isalpha(redOrString[iPos0])) {
598  if (!G4Colour::GetColour(redOrString, colour)) {
599  if (verbosity >= G4VisManager::warnings) {
600  G4cout << "WARNING: Text colour \"" << redOrString
601  << "\" not found. Defaulting to black and opaque."
602  << G4endl;
603  }
604  }
605  } else {
606  colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
607  }
608  // Add opacity
609  colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
610  vp.SetBackgroundColour(colour);
611  if (verbosity >= G4VisManager::confirmations) {
612  G4cout << "Background colour "
613  << vp.GetBackgroundColour()
614  << " requested."
615  << G4endl;
616  }
617  }
618 
619  else if (command == fpCommandCulling) {
620  G4String cullingOption, stringFlag, unit;
621  G4double density;
622  std::istringstream is (newValue);
623  is >> cullingOption >> stringFlag >> density >> unit;
624  G4bool boolFlag = G4UIcommand::ConvertToBool(stringFlag);
625  if (cullingOption == "global") {
626  vp.SetCulling(boolFlag);
627  if (verbosity >= G4VisManager::confirmations) {
628  G4cout <<
629  "G4VisCommandsViewerSet::SetNewValue: culling: global culling flag"
630  " set to " << G4UIcommand::ConvertToString(boolFlag) <<
631  ".\n Does not change specific culling flags."
632  << G4endl;
633  }
634  }
635  else if (cullingOption == "coveredDaughters") {
636  vp.SetCullingCovered(boolFlag);
637  if (verbosity >= G4VisManager::confirmations) {
638  G4cout <<
639  "G4VisCommandsViewerSet::SetNewValue: culling: culling covered"
640  "\n daughters flag set to "
641  << G4UIcommand::ConvertToString(boolFlag) <<
642  ". Daughters covered by opaque mothers"
643  "\n will be culled, i.e., not drawn, if this flag is true."
644  "\n Note: this is only effective in surface drawing style,"
645  "\n and then only if the volumes are visible and opaque, and then"
646  "\n only if no sections or cutaways are in operation."
647  << G4endl;
648  }
649  }
650  else if (cullingOption == "invisible") {
651  vp.SetCullingInvisible(boolFlag);
652  if (verbosity >= G4VisManager::confirmations) {
653  G4cout <<
654  "G4VisCommandsViewerSet::SetNewValue: culling: culling invisible"
655  "\n flag set to "
656  << boolFlag << G4UIcommand::ConvertToString(boolFlag) <<
657  ". Volumes marked invisible will be culled,"
658  "\n i.e., not drawn, if this flag is true."
659  << G4endl;
660  }
661  }
662  else if (cullingOption == "density") {
663  vp.SetDensityCulling(boolFlag);
664  if (boolFlag) {
665  density *= G4UnitDefinition::GetValueOf(unit);
666  vp.SetVisibleDensity(density);
667  }
668  else {
669  density = vp.GetVisibleDensity();
670  }
671  if (verbosity >= G4VisManager::confirmations) {
672  G4cout <<
673  "G4VisCommandsViewerSet::SetNewValue: culling: culling by density"
674  "\n flag set to " << G4UIcommand::ConvertToString(boolFlag) <<
675  ". Volumes with density less than " <<
676  G4BestUnit(density,"Volumic Mass") <<
677  "\n will be culled, i.e., not drawn, if this flag is true."
678  << G4endl;
679  }
680  }
681  else {
682  if (verbosity >= G4VisManager::errors) {
683  G4cerr <<
684  "ERROR: G4VisCommandsViewerSet::SetNewValue: culling:"
685  "\n option not recognised."
686  << G4endl;
687  }
688  }
689  }
690 
691  else if (command == fpCommandCutawayMode) {
692  if (newValue == "add" || newValue == "union")
694  if (newValue == "multiply" || newValue == "intersection")
696 
697  if (verbosity >= G4VisManager::confirmations) {
698  G4cout << "Cutaway mode set to ";
700  G4cout << "cutawayUnion";
702  G4cout << "cutawayIntersection";
703  G4cout << G4endl;
704  }
705  }
706 
707  else if (command == fpCommandDefaultColour) {
708  G4String redOrString;
709  G4double green, blue, opacity;
710  std::istringstream iss(newValue);
711  iss >> redOrString >> green >> blue >> opacity;
712  G4Colour colour(1.,1.,1.); // Default white and opaque.
713  const size_t iPos0 = 0;
714  if (std::isalpha(redOrString[iPos0])) {
715  if (!G4Colour::GetColour(redOrString, colour)) {
716  if (verbosity >= G4VisManager::warnings) {
717  G4cout << "WARNING: Text colour \"" << redOrString
718  << "\" not found. Defaulting to white and opaque."
719  << G4endl;
720  }
721  }
722  } else {
723  colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
724  }
725  // Add opacity
726  colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
728  va.SetColour(colour);
730  if (verbosity >= G4VisManager::confirmations) {
731  G4cout << "Default colour "
733  << " requested."
734  << G4endl;
735  }
736  }
737 
738  else if (command == fpCommandDefaultTextColour) {
739  G4String redOrString;
740  G4double green, blue, opacity;
741  std::istringstream iss(newValue);
742  iss >> redOrString >> green >> blue >> opacity;
743  G4Colour colour(1.,1.,1.); // Default white and opaque.
744  const size_t iPos0 = 0;
745  if (std::isalpha(redOrString[iPos0])) {
746  if (!G4Colour::GetColour(redOrString, colour)) {
747  if (verbosity >= G4VisManager::warnings) {
748  G4cout << "WARNING: Text colour \"" << redOrString
749  << "\" not found. Defaulting to white and opaque."
750  << G4endl;
751  }
752  }
753  } else {
754  colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
755  }
756  // Add opacity
757  colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
759  va.SetColour(colour);
761  if (verbosity >= G4VisManager::confirmations) {
762  G4cout << "Default colour "
764  << " requested."
765  << G4endl;
766  }
767  }
768 
769  else if (command == fpCommandEdge) {
770  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
771  if (G4UIcommand::ConvertToBool(newValue)) {
772  switch (existingStyle) {
774  break;
776  break;
779  break;
781  break;
782  }
783  }
784  else {
785  switch (existingStyle) {
787  break;
789  break;
791  break;
794  break;
795  }
796  }
797  if (verbosity >= G4VisManager::confirmations) {
798  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
799  << "\" set to " << vp.GetDrawingStyle()
800  << G4endl;
801  }
802  }
803 
804  else if (command == fpCommandExplodeFactor) {
805  G4double explodeFactor, x, y, z;
806  G4String unitString;
807  std::istringstream is (newValue);
808  is >> explodeFactor >> x >> y >> z >> unitString;
809  G4double unit = G4UIcommand::ValueOf(unitString);
810  vp.SetExplodeFactor(explodeFactor);
811  vp.SetExplodeCentre(G4Point3D(x * unit, y * unit, z * unit));
812  if (verbosity >= G4VisManager::confirmations) {
813  G4cout << "Explode factor changed to " << vp.GetExplodeFactor()
814  << " from centre " << vp.GetExplodeCentre()
815  << G4endl;
816  }
817  }
818 
819  else if (command == fpCommandGlobalLineWidthScale) {
820  G4double globalLineWidthScale
821  = fpCommandGlobalLineWidthScale->GetNewDoubleValue(newValue);
822  vp.SetGlobalLineWidthScale(globalLineWidthScale);
823  if (verbosity >= G4VisManager::confirmations) {
824  G4cout << "Global Line Width Scale changed to "
825  << vp.GetGlobalLineWidthScale() << G4endl;
826  }
827  }
828 
829  else if (command == fpCommandGlobalMarkerScale) {
830  G4double globalMarkerScale
831  = fpCommandGlobalMarkerScale->GetNewDoubleValue(newValue);
832  vp.SetGlobalMarkerScale(globalMarkerScale);
833  if (verbosity >= G4VisManager::confirmations) {
834  G4cout << "Global Marker Scale changed to "
835  << vp.GetGlobalMarkerScale() << G4endl;
836  }
837  }
838 
839  else if (command == fpCommandHiddenEdge) {
840  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
841  if (G4UIcommand::ConvertToBool(newValue)) {
842  switch (existingStyle) {
845  break;
847  break;
850  break;
852  break;
853  }
854  }
855  else {
856  switch (existingStyle) {
858  break;
861  break;
863  break;
866  break;
867  }
868  }
869  if (verbosity >= G4VisManager::confirmations) {
870  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
871  << "\" set to " << vp.GetDrawingStyle()
872  << G4endl;
873  }
874  }
875 
876  else if (command == fpCommandHiddenMarker) {
877  G4bool hidden = G4UIcommand::ConvertToBool(newValue);
878  if (hidden) vp.SetMarkerHidden();
879  else vp.SetMarkerNotHidden();
880  if (verbosity >= G4VisManager::confirmations) {
881  G4cout << "Markers will ";
882  if (vp.IsMarkerNotHidden()) G4cout << "not ";
883  G4cout << "be hidden under solid objects." << G4endl;
884  }
885  }
886 
887  else if (command == fpCommandLightsMove) {
888  if (newValue.find("cam") != G4String::npos)
889  vp.SetLightsMoveWithCamera(true);
890  else if(newValue.find("obj") != G4String::npos)
891  vp.SetLightsMoveWithCamera(false);
892  else {
893  if (verbosity >= G4VisManager::errors) {
894  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
895  " Looking for \"cam\" or \"obj\" in string." << G4endl;
896  }
897  }
898  if (verbosity >= G4VisManager::confirmations) {
899  G4cout << "Lights move with ";
900  if (vp.GetLightsMoveWithCamera())
901  G4cout << "camera (object appears to rotate).";
902  else G4cout << "object (the viewer appears to be moving).";
903  G4cout << G4endl;
904  }
905  }
906 
907  else if (command == fpCommandLightsThetaPhi) {
908  G4double theta, phi;
909  ConvertToDoublePair(newValue, theta, phi);
910  G4double x = std::sin (theta) * std::cos (phi);
911  G4double y = std::sin (theta) * std::sin (phi);
912  G4double z = std::cos (theta);
913  fLightsVector = G4ThreeVector (x, y, z);
914  vp.SetLightpointDirection(fLightsVector);
915  if (verbosity >= G4VisManager::confirmations) {
916  G4cout << "Lights direction set to "
917  << vp.GetLightpointDirection() << G4endl;
918  }
919  }
920 
921  else if (command == fpCommandLightsVector) {
922  fLightsVector = G4UIcommand::ConvertTo3Vector(newValue);
923  vp.SetLightpointDirection(fLightsVector);
924  if (verbosity >= G4VisManager::confirmations) {
925  G4cout << "Lights direction set to "
926  << vp.GetLightpointDirection() << G4endl;
927  }
928  }
929 
930  else if (command == fpCommandLineSegments) {
931  G4int nSides = G4UIcommand::ConvertToInt(newValue);
932  nSides = vp.SetNoOfSides(nSides);
933  if (verbosity >= G4VisManager::confirmations) {
934  G4cout <<
935  "Number of line segements per circle in polygon approximation is "
936  << nSides << G4endl;
937  }
938  }
939 
940  else if (command == fpCommandPicking) {
942  if (verbosity >= G4VisManager::confirmations) {
943  G4cout << "Picking ";
944  if (vp.IsPicking()) G4cout << "requested.";
945  else G4cout << "inhibited.";
946  G4cout << G4endl;
947  }
948  if (verbosity >= G4VisManager::warnings) {
949  G4cout << "You may need to issue \"/vis/viewer/update\"."
950  << G4endl;
951  }
952  }
953 
954  else if (command == fpCommandProjection) {
955  G4double fieldHalfAngle;
956  const size_t iPos0 = 0;
957  if (newValue[iPos0] == 'o') { // "orthogonal"
958  fieldHalfAngle = 0.;
959  }
960  else if (newValue[iPos0] == 'p') { // "perspective"
961  G4String dummy;
962  G4String unit;
963  std::istringstream is (newValue);
964  is >> dummy >> fieldHalfAngle >> unit;
965  fieldHalfAngle *= G4UIcommand::ValueOf(unit);
966  if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
967  if (verbosity >= G4VisManager::errors) {
968  G4cerr <<
969  "ERROR: Field half angle should be 0 < angle <= 89.5 degrees.";
970  G4cout << G4endl;
971  }
972  return;
973  }
974  }
975  else {
976  if (verbosity >= G4VisManager::errors) {
977  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
978  " Looking for 'o' or 'p' first character." << G4endl;
979  }
980  return;
981  }
982  vp.SetFieldHalfAngle(fieldHalfAngle);
983  if (verbosity >= G4VisManager::confirmations) {
984  G4cout << "Projection style of viewer \"" << currentViewer->GetName()
985  << "\" set to ";
986  if (fieldHalfAngle == 0.) {
987  G4cout << "orthogonal.";
988  }
989  else {
990  G4cout << "perspective\n with half angle " << fieldHalfAngle / deg
991  << " degrees.";
992  }
993  G4cout << G4endl;
994  }
995  }
996 
997  else if (command == fpCommandSectionPlane) {
998  G4String choice, unit;
999  G4double x, y, z, nx, ny, nz;
1000  std::istringstream is (newValue);
1001  is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
1002 
1003  G4int iSelector = -1;
1004  if (choice.compareTo("off",G4String::ignoreCase) == 0 ||
1005  !G4UIcommand::ConvertToBool(choice)) iSelector = 0;
1006  if (choice.compareTo("on",G4String::ignoreCase) == 0 ||
1007  G4UIcommand::ConvertToBool(choice)) iSelector = 1;
1008  if (iSelector < 0) {
1009  if (verbosity >= G4VisManager::errors) {
1010  G4cout << "Choice not recognised (on/true or off/false)." << G4endl;
1011  G4cout << "Section drawing is currently: ";
1012  if (vp.IsSection ()) G4cout << "on";
1013  else G4cout << "off";
1014  G4cout << ".\nSection plane is currently: "
1015  << vp.GetSectionPlane ();
1016  G4cout << G4endl;
1017  }
1018  return;
1019  }
1020 
1021  G4double F = 1.;
1022  // iSelector can only be 0 or 1
1023  switch (iSelector) {
1024  case 0:
1025  vp.UnsetSectionPlane();
1026  break;
1027  case 1:
1028  F = G4UIcommand::ValueOf(unit);
1029  x *= F; y *= F; z *= F;
1030  vp.SetSectionPlane(G4Plane3D(G4Normal3D(nx,ny,nz), G4Point3D(x,y,z)));
1031  vp.SetViewpointDirection(G4Normal3D(nx,ny,nz));
1032  break;
1033  }
1034 
1035  if (verbosity >= G4VisManager::confirmations) {
1036  G4cout << "Section drawing is now: ";
1037  if (vp.IsSection ()) G4cout << "on";
1038  else G4cout << "off";
1039  G4cout << ".\nSection plane is now: "
1040  << vp.GetSectionPlane ();
1041  G4cout << G4endl;
1042  }
1043  }
1044 
1045  else if (command == fpCommandRotationStyle) {
1047  if (newValue == "constrainUpDirection")
1049  else if (newValue == "freeRotation")
1051  else {
1052  if (verbosity >= G4VisManager::errors) {
1053  G4cerr << "ERROR: \"" << newValue << "\" not recognised." << G4endl;
1054  }
1055  return;
1056  }
1057  vp.SetRotationStyle(style);
1058  if (verbosity >= G4VisManager::confirmations) {
1059  G4cout << "Rotation style of viewer \"" << currentViewer->GetName()
1060  << "\" set to " << vp.GetRotationStyle()
1061  << G4endl;
1062  }
1063  }
1064 
1065  else if (command == fpCommandStyle) {
1066  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
1067  const size_t iPos0 = 0;
1068  if (newValue[iPos0] == 'w') { // "wireframe"
1069  switch (existingStyle) {
1071  break;
1072  case G4ViewParameters::hlr:
1073  break;
1074  case G4ViewParameters::hsr:
1076  break;
1079  break;
1080  }
1081  }
1082  else if (newValue[iPos0] == 's') { // "surface"
1083  switch (existingStyle) {
1086  break;
1087  case G4ViewParameters::hlr:
1089  break;
1090  case G4ViewParameters::hsr:
1091  break;
1093  break;
1094  }
1095  }
1096  else {
1097  if (verbosity >= G4VisManager::errors) {
1098  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1099  " Looking for 'w' or 's' first character." << G4endl;
1100  }
1101  return;
1102  }
1103  if (verbosity >= G4VisManager::confirmations) {
1104  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
1105  << "\" set to " << vp.GetDrawingStyle()
1106  << G4endl;
1107  }
1108  }
1109 
1110  else if (command == fpCommandTargetPoint) {
1111  G4ThreeVector targetPoint =
1112  fpCommandTargetPoint->GetNew3VectorValue(newValue);
1113  const G4Point3D& standardTargetPoint =
1114  currentViewer->GetSceneHandler()->GetScene()->GetStandardTargetPoint();
1115  vp.SetCurrentTargetPoint(targetPoint - standardTargetPoint);
1116  if (verbosity >= G4VisManager::confirmations) {
1117  G4cout << "Target point set to "
1118  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1119  (targetPoint)
1120  << "\n\"Current Target Point\" set to "
1121  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1122  (vp.GetCurrentTargetPoint())
1123  << "\n\"Standard Target Point\" is "
1124  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1125  (standardTargetPoint)
1126  << G4endl;
1127  }
1128  }
1129 
1130  else if (command == fpCommandUpThetaPhi) {
1131  G4double theta, phi;
1132  ConvertToDoublePair(newValue, theta, phi);
1133  G4double x = std::sin (theta) * std::cos (phi);
1134  G4double y = std::sin (theta) * std::sin (phi);
1135  G4double z = std::cos (theta);
1136  fUpVector = G4ThreeVector (x, y, z);
1137  vp.SetUpVector(fUpVector);
1138  if (verbosity >= G4VisManager::confirmations) {
1139  G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1140  }
1141  }
1142 
1143  else if (command == fpCommandUpVector) {
1144  fUpVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
1145  vp.SetUpVector(fUpVector);
1146  if (verbosity >= G4VisManager::confirmations) {
1147  G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1148  }
1149  }
1150 
1151  else if (command == fpCommandViewpointThetaPhi) {
1152  G4double theta, phi;
1153  ConvertToDoublePair(newValue, theta, phi);
1154  G4double x = std::sin (theta) * std::cos (phi);
1155  G4double y = std::sin (theta) * std::sin (phi);
1156  G4double z = std::cos (theta);
1157  fViewpointVector = G4ThreeVector (x, y, z);
1158  vp.SetViewAndLights(fViewpointVector);
1159  if (verbosity >= G4VisManager::confirmations) {
1160  G4cout << "Viewpoint direction set to "
1161  << vp.GetViewpointDirection() << G4endl;
1162  if (vp.GetLightsMoveWithCamera ()) {
1163  G4cout << "Lightpoint direction set to "
1165  }
1166  }
1167  }
1168 
1169  else if (command == fpCommandViewpointVector) {
1170  G4ThreeVector viewpointVector = G4UIcommand::ConvertTo3Vector(newValue);
1171  if (viewpointVector.mag2() <= 0.) {
1172  if (verbosity >= G4VisManager::errors) {
1173  G4cerr << "ERROR: Null viewpoint vector. No action taken." << G4endl;
1174  }
1175  } else {
1176  fViewpointVector = viewpointVector.unit();
1177  vp.SetViewAndLights(fViewpointVector);
1178  if (verbosity >= G4VisManager::confirmations) {
1179  G4cout << "Viewpoint direction set to "
1180  << vp.GetViewpointDirection() << G4endl;
1181  if (vp.GetLightsMoveWithCamera ()) {
1182  G4cout << "Lightpoint direction set to "
1184  }
1185  }
1186  }
1187  }
1188 
1189  else {
1190  if (verbosity >= G4VisManager::errors) {
1191  G4cerr <<
1192  "ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command."
1193  << G4endl;
1194  }
1195  return;
1196  }
1197 
1198  SetViewParameters(currentViewer,vp);
1199 }
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
const G4String & GetName() const
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetMarkerNotHidden()
void SetColour(const G4Colour &)
const G4Colour & GetBackgroundColour() const
G4Vector3D & GetActualLightpointDirection()
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
G4double GetVisibleDensity() const
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
CLHEP::Hep3Vector G4ThreeVector
void SetAuxEdgeVisible(G4bool)
G4int SetNoOfSides(G4int nSides)
void SetRotationStyle(RotationStyle)
const G4Point3D & GetExplodeCentre() const
void SetParameterRange(const char *theRange)
void SetPicking(G4bool)
void SetParameterCandidates(const char *theString)
G4double GetExplodeFactor() const
void SetUnitCategory(const char *unitCategory)
void SetUpVector(const G4Vector3D &upVector)
const G4ViewParameters & GetViewParameters() const
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition: G4Colour.cc:126
const G4Colour & GetColour() const
void SetDefaultValue(const char *theDefaultValue)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:372
void SetViewParameters(const G4ViewParameters &vp)
Definition: G4VViewer.cc:120
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
tuple x
Definition: test.py:50
G4double GetBlue() const
Definition: G4Colour.hh:141
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetDensityCulling(G4bool)
void SetVisibleDensity(G4double visibleDensity)
Definition: test07.cc:36
int G4int
Definition: G4Types.hh:78
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
static G4ThreeVector ConvertTo3Vector(const char *st)
Definition: G4UIcommand.cc:475
void SetDefaultTextVisAttributes(const G4VisAttributes &)
void SetBackgroundColour(const G4Colour &)
void SetCutawayMode(CutawayMode)
void SetLightsMoveWithCamera(G4bool moves)
void SetDefaultValue(G4bool defVal)
void SetViewAndLights(const G4Vector3D &viewpointDirection)
const G4Point3D & GetCurrentTargetPoint() const
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
const G4Vector3D & GetLightpointDirection() const
static G4double GetValueOf(const G4String &)
const G4Vector3D & GetViewpointDirection() const
void SetExplodeFactor(G4double explodeFactor)
G4GLOB_DLL std::ostream G4cout
G4bool IsAuxEdgeVisible() const
G4double GetRed() const
Definition: G4Colour.hh:139
const G4ViewParameters & GetDefaultViewParameters() const
void SetGlobalMarkerScale(G4double globalMarkerScale)
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:437
const G4Point3D & GetStandardTargetPoint() const
bool G4bool
Definition: G4Types.hh:79
G4double GetGreen() const
Definition: G4Colour.hh:140
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetCurrentTargetPoint(const G4Point3D &currentTargetPoint)
RotationStyle GetRotationStyle() const
void SetDefaultVisAttributes(const G4VisAttributes &)
void SetFieldHalfAngle(G4double fieldHalfAngle)
CutawayMode GetCutawayMode() const
void SetExplodeCentre(const G4Point3D &explodeCentre)
G4double GetGlobalLineWidthScale() const
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
void SetNewValue(G4UIcommand *command, G4String newValue)
const G4VisAttributes * GetDefaultTextVisAttributes() const
void SetMarkerHidden()
void SetCullingInvisible(G4bool)
G4bool IsSection() const
void SetAutoRefresh(G4bool)
G4Scene * GetScene() const
G4bool IsMarkerNotHidden() const
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
void SetDefaultValue(const char *defVal)
G4VSceneHandler * GetSceneHandler() const
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
Hep3Vector unit() const
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:309
G4String GetCurrentValue(G4UIcommand *command)
void UnsetSectionPlane()
void SetDefaultValue(G4double defVal)
double mag2() const
tuple z
Definition: test.py:28
DrawingStyle GetDrawingStyle() const
G4int compareTo(const char *, caseCompare mode=exact) const
void SetGlobalLineWidthScale(G4double globalLineWidthScale)
G4bool IsPicking() const
HepGeom::Plane3D< G4double > G4Plane3D
Definition: G4Plane3D.hh:37
void SetCandidates(const char *candidateList)
G4bool GetLightsMoveWithCamera() const
#define G4endl
Definition: G4ios.hh:61
const G4Plane3D & GetSectionPlane() const
void SetDefaultValue(G4int defVal)
const G4VisAttributes * GetDefaultVisAttributes() const
double G4double
Definition: G4Types.hh:76
static constexpr double deg
Definition: G4SIunits.hh:152
void SetGuidance(const char *theGuidance)
void SetSectionPlane(const G4Plane3D &sectionPlane)
const G4Vector3D & GetUpVector() const
void SetCulling(G4bool)
G4bool IsAutoRefresh() const
void SetCullingCovered(G4bool)
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
G4GLOB_DLL std::ostream G4cerr
G4double GetGlobalMarkerScale() const
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:35