ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisCommandsViewerSet.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VisCommandsViewerSet.cc
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 
28 // /vis/viewer/set commands - John Allison 16th May 2000
29 
31 
32 #include "G4UIcommand.hh"
33 #include "G4UIcmdWithAString.hh"
34 #include "G4UIcmdWithABool.hh"
35 #include "G4UIcmdWithAnInteger.hh"
36 #include "G4UIcmdWithADouble.hh"
38 #include "G4UnitsTable.hh"
39 #include "G4VisManager.hh"
40 #include "G4Polyhedron.hh"
41 #include "G4SystemOfUnits.hh"
42 
43 #include <sstream>
44 #include <iomanip>
45 
47 fLightsVector (G4ThreeVector(1.,1.,1.)),
48 fUpVector (G4ThreeVector(0.,1.,0.)),
49 fViewpointVector (G4ThreeVector(0.,0.,1.))
50 {
51  G4bool omitable;
52  G4UIparameter* parameter;
53 
54  fpCommandAll = new G4UIcmdWithAString ("/vis/viewer/set/all",this);
56  ("Copies view parameters.");
58  ("Copies ALL view parameters (except the autoRefresh status) from"
59  "\nfrom-viewer to current viewer. You may need \"/vis/viewer/rebuild\".");
61  ("Note: to copy only the camera-specific parameters use"
62  "\n\"/vis/viewer/copyfrom\".");
63  fpCommandAll->SetParameterName ("from-viewer-name",omitable = false);
64 
66  ("/vis/viewer/set/autoRefresh",this);
67  fpCommandAutoRefresh->SetGuidance("Sets auto-refresh.");
69  ("If true, view is automatically refreshed after a change of"
70  "\nview parameters.");
71  fpCommandAutoRefresh->SetParameterName("auto-refresh",omitable = true);
73 
75  ("/vis/viewer/set/auxiliaryEdge",this);
76  fpCommandAuxEdge->SetGuidance("Sets visibility of auxiliary edges");
78  ("Auxiliary edges, i.e., those that are part of a curved surface,"
79  "\nsometimes called soft edges, become visible/invisible.");
80  fpCommandAuxEdge->SetParameterName("edge",omitable = true);
82 
84  ("/vis/viewer/set/background",this);
86  ("Set background colour and transparency (default black and opaque).");
88  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
89  parameter -> SetDefaultValue ("0.");
90  fpCommandBackground -> SetParameter (parameter);
91  parameter = new G4UIparameter("green", 'd', omitable = true);
92  parameter -> SetDefaultValue (0.);
93  fpCommandBackground -> SetParameter (parameter);
94  parameter = new G4UIparameter ("blue", 'd', omitable = true);
95  parameter -> SetDefaultValue (0.);
96  fpCommandBackground -> SetParameter (parameter);
97  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
98  parameter -> SetDefaultValue (1.);
99  fpCommandBackground -> SetParameter (parameter);
100 
101  fpCommandCulling = new G4UIcommand("/vis/viewer/set/culling",this);
102  fpCommandCulling->SetGuidance ("Set culling options.");
104  ("\"global\": enables/disables all other culling options.");
106  ("\"coveredDaughters\": culls, i.e., eliminates, volumes that would not"
107  "\nbe seen because covered by ancestor volumes in surface drawing mode,"
108  "\nand then only if the ancestors are visible and opaque, and then only"
109  "\nif no sections or cutaways are in operation. Intended solely to"
110  "\nimprove the speed of rendering visible volumes.");
112  ("\"invisible\": culls objects with the invisible attribute set.");
114  ("\"density\": culls volumes with density lower than threshold. Useful"
115  "\nfor eliminating \"container volumes\" with no physical correspondence,"
116  "\nwhose material is usually air. If this is selected, provide threshold"
117  "\ndensity and unit (e.g., g/cm3, mg/cm3 or kg/m3)."
118  );
119  parameter = new G4UIparameter("culling-option",'s',omitable = false);
120  parameter->SetParameterCandidates
121  ("global coveredDaughters invisible density");
122  fpCommandCulling->SetParameter(parameter);
123  parameter = new G4UIparameter("action",'b',omitable = true);
124  parameter->SetDefaultValue(1);
125  fpCommandCulling->SetParameter(parameter);
126  parameter = new G4UIparameter("density-threshold",'d',omitable = true);
127  parameter->SetDefaultValue("0.01");
128  fpCommandCulling->SetParameter(parameter);
129  parameter = new G4UIparameter("unit",'s',omitable = true);
130  // parameter->SetParameterCandidates ("g/cm3 mg/cm3 kg/m3");
131  // Instead of the above, SetNewValue accepts *any* density unit.
132  parameter->SetDefaultValue("g/cm3");
133  fpCommandCulling->SetParameter(parameter);
134 
136  new G4UIcmdWithAString ("/vis/viewer/set/cutawayMode", this);
138  ("Sets cutaway mode - add (union) or multiply (intersection).");
139  fpCommandCutawayMode->SetParameterName ("cutaway-mode",omitable = false);
140  fpCommandCutawayMode->SetCandidates ("add union multiply intersection");
142 
144  ("/vis/viewer/set/defaultColour",this);
146  ("Set defaultColour colour and transparency (default white and opaque).");
148  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
149  parameter -> SetDefaultValue ("1.");
150  fpCommandDefaultColour -> SetParameter (parameter);
151  parameter = new G4UIparameter("green", 'd', omitable = true);
152  parameter -> SetDefaultValue (1.);
153  fpCommandDefaultColour -> SetParameter (parameter);
154  parameter = new G4UIparameter ("blue", 'd', omitable = true);
155  parameter -> SetDefaultValue (1.);
156  fpCommandDefaultColour -> SetParameter (parameter);
157  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
158  parameter -> SetDefaultValue (1.);
159  fpCommandDefaultColour -> SetParameter (parameter);
160 
162  ("/vis/viewer/set/defaultTextColour",this);
164  ("Set defaultTextColour colour and transparency (default blue and opaque).");
166  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
167  parameter -> SetDefaultValue ("0.");
168  fpCommandDefaultTextColour -> SetParameter (parameter);
169  parameter = new G4UIparameter("green", 'd', omitable = true);
170  parameter -> SetDefaultValue (0.);
171  fpCommandDefaultTextColour -> SetParameter (parameter);
172  parameter = new G4UIparameter ("blue", 'd', omitable = true);
173  parameter -> SetDefaultValue (1.);
174  fpCommandDefaultTextColour -> SetParameter (parameter);
175  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
176  parameter -> SetDefaultValue (1.);
177  fpCommandDefaultTextColour -> SetParameter (parameter);
178 
179  fpCommandEdge = new G4UIcmdWithABool("/vis/viewer/set/edge",this);
181  ("Edges become visible/invisible in surface mode.");
182  fpCommandEdge->SetParameterName("edge",omitable = true);
184 
186  ("/vis/viewer/set/explodeFactor", this);
188  ("Moves top-level drawn volumes by this factor from this centre.");
189  parameter = new G4UIparameter("explodeFactor", 'd', omitable=true);
190  parameter->SetParameterRange("explodeFactor>=1.");
191  parameter->SetDefaultValue(1.);
193  parameter = new G4UIparameter("x",'d',omitable = true);
194  parameter->SetDefaultValue (0);
195  parameter->SetGuidance ("Coordinate of explode centre.");
197  parameter = new G4UIparameter("y",'d',omitable = true);
198  parameter->SetDefaultValue (0);
199  parameter->SetGuidance ("Coordinate of explode centre.");
201  parameter = new G4UIparameter("z",'d',omitable = true);
202  parameter->SetDefaultValue (0);
203  parameter->SetGuidance ("Coordinate of explode centre.");
205  parameter = new G4UIparameter("unit",'s',omitable = true);
206  parameter->SetDefaultValue ("m");
207  parameter->SetGuidance ("Unit of explode centre.");
209 
211  ("/vis/viewer/set/globalLineWidthScale", this);
213  ("Multiplies line widths by this factor.");
215  SetParameterName("scale-factor", omitable=true);
217 
219  ("/vis/viewer/set/globalMarkerScale", this);
221  ("Multiplies marker sizes by this factor.");
223  SetParameterName("scale-factor", omitable=true);
225 
227  new G4UIcmdWithABool("/vis/viewer/set/hiddenEdge",this);
229  ("Edges become hidden/seen in wireframe or surface mode.");
230  fpCommandHiddenEdge->SetParameterName("hidden-edge",omitable = true);
232 
234  new G4UIcmdWithABool("/vis/viewer/set/hiddenMarker",this);
236  ("If true, closer objects hide markers. Otherwise, markers always show.");
237  fpCommandHiddenMarker->SetParameterName("hidden-marker",omitable = true);
239 
241  ("/vis/viewer/set/lightsMove",this);
243  ("Lights move with camera or with object");
244  fpCommandLightsMove->SetParameterName("lightsMove",omitable = false);
246  ("cam camera with-camera obj object with-object");
247 
249  ("/vis/viewer/set/lightsThetaPhi", this);
251  ("Set direction from target to lights.");
252  parameter = new G4UIparameter("theta", 'd', omitable = true);
253  parameter -> SetDefaultValue(60.);
254  fpCommandLightsThetaPhi -> SetParameter (parameter);
255  parameter = new G4UIparameter("phi", 'd', omitable = true);
256  parameter -> SetDefaultValue(45.);
257  fpCommandLightsThetaPhi -> SetParameter (parameter);
258  parameter = new G4UIparameter ("unit", 's', omitable = true);
259  parameter -> SetDefaultValue ("deg");
260  fpCommandLightsThetaPhi -> SetParameter (parameter);
261 
263  ("/vis/viewer/set/lightsVector", this);
265  ("Set direction from target to lights.");
266  parameter = new G4UIparameter("x", 'd', omitable = true);
267  parameter -> SetDefaultValue (1);
268  fpCommandLightsVector -> SetParameter (parameter);
269  parameter = new G4UIparameter("y", 'd', omitable = true);
270  parameter -> SetDefaultValue (1);
271  fpCommandLightsVector -> SetParameter (parameter);
272  parameter = new G4UIparameter ("z", 'd', omitable = true);
273  parameter -> SetDefaultValue (1);
274  fpCommandLightsVector -> SetParameter (parameter);
275 
277  ("/vis/viewer/set/lineSegmentsPerCircle",this);
279  ("Set number of sides per circle for polygon/polyhedron drawing.");
281  ("Refers to graphical representation of objects with curved lines/surfaces.");
282  fpCommandLineSegments->SetParameterName("line-segments",omitable = true);
284 
286  ("/vis/viewer/set/numberOfCloudPoints",this);
288  ("Set number of points to be used for cloud representation of volumes.");
289  fpCommandNumberOfCloudPoints->SetParameterName("points",omitable = true);
291 
293  ("/vis/viewer/set/picking",this);
294  fpCommandPicking->SetGuidance("Sets picking, if available.");
296  ("If true, view is set up for picking, if available.");
298  ("You may need to issue \"/vis/viewer/update\".");
300  ("For required actions, watch for instructions for viewer.");
301  fpCommandPicking->SetParameterName("picking",omitable = true);
303 
304  fpCommandProjection = new G4UIcommand("/vis/viewer/set/projection",this);
306  ("Set projection style - o[rthogonal] or p[erspective]."
307  "\nIf p[erspective], also set field half angle.");
308  parameter = new G4UIparameter("projection",'s',omitable = true);
309  parameter->SetParameterCandidates("o orthogonal p perspective");
310  parameter->SetDefaultValue("orthogonal");
311  fpCommandProjection->SetParameter(parameter);
312  parameter = new G4UIparameter("field-half-angle",'d',omitable = true);
313  parameter->SetDefaultValue(30.);
314  //parameter->SetCurrentAsDefault(true);
315  fpCommandProjection->SetParameter(parameter);
316  parameter = new G4UIparameter("unit",'s',omitable = true);
317  parameter->SetDefaultValue("deg");
318  //parameter->SetCurrentAsDefault(true);
319  fpCommandProjection->SetParameter(parameter);
320 
322  ("/vis/viewer/set/rotationStyle",this);
324  ("Set style of rotation - constrainUpDirection or freeRotation.");
326  ("constrainUpDirection: conventional HEP view.");
328  ("freeRotation: Google-like rotation, using mouse-grab.");
329  fpCommandRotationStyle->SetParameterName ("style",omitable = false);
330  fpCommandRotationStyle->SetCandidates("constrainUpDirection freeRotation");
331 
332  fpCommandSectionPlane = new G4UIcommand("/vis/viewer/set/sectionPlane",this);
333  fpCommandSectionPlane -> SetGuidance
334  ("Set plane for drawing section (DCUT).");
335  fpCommandSectionPlane -> SetGuidance
336  ("E.g., for a y-z plane at x = 1 cm:"
337  "\n\"/vis/viewer/set/sectionPlane on 1 0 0 cm 1 0 0\"."
338  "\nTo turn off: /vis/viewer/set/sectionPlane off");
339  parameter = new G4UIparameter("Selector",'c',true);
340  parameter -> SetDefaultValue ("on");
342  parameter = new G4UIparameter("x",'d',omitable = true);
343  parameter -> SetDefaultValue (0);
344  parameter -> SetGuidance ("Coordinate of point on the plane.");
346  parameter = new G4UIparameter("y",'d',omitable = true);
347  parameter -> SetDefaultValue (0);
348  parameter -> SetGuidance ("Coordinate of point on the plane.");
350  parameter = new G4UIparameter("z",'d',omitable = true);
351  parameter -> SetDefaultValue (0);
352  parameter -> SetGuidance ("Coordinate of point on the plane.");
354  parameter = new G4UIparameter("unit",'s',omitable = true);
355  parameter -> SetDefaultValue ("m");
356  parameter -> SetGuidance ("Unit of point on the plane.");
358  parameter = new G4UIparameter("nx",'d',omitable = true);
359  parameter -> SetDefaultValue (1);
360  parameter -> SetGuidance ("Component of plane normal.");
362  parameter = new G4UIparameter("ny",'d',omitable = true);
363  parameter -> SetDefaultValue (0);
364  parameter -> SetGuidance ("Component of plane normal.");
366  parameter = new G4UIparameter("nz",'d',omitable = true);
367  parameter -> SetDefaultValue (0);
368  parameter -> SetGuidance ("Component of plane normal.");
370 
371  fpCommandStyle = new G4UIcmdWithAString ("/vis/viewer/set/style",this);
373  ("Set style of drawing - w[ireframe] or s[urface] or c[loud].");
375  ("(Hidden line drawing is controlled by \"/vis/viewer/set/hiddenEdge\".)");
376  fpCommandStyle->SetParameterName ("style",omitable = false);
377  fpCommandStyle->SetCandidates("w wireframe s surface c cloud");
378 
380  ("/vis/viewer/set/targetPoint", this);
382  ("Set target point.");
384  ("This sets the \"Current Target Point\" relative to the \"Standard");
386  ("Target Point\" so that the actual target point is as requested.");
388  ("(See G4ViewParameters.hh for an explanation of target points.)");
389  fpCommandTargetPoint->SetParameterName("x", "y", "z", omitable = false);
391 
393  ("/vis/viewer/set/upThetaPhi", this);
394  fpCommandUpThetaPhi -> SetGuidance ("Set up vector.");
395  fpCommandUpThetaPhi -> SetGuidance
396  ("Viewer will attempt always to show this direction upwards.");
397  parameter = new G4UIparameter("theta", 'd', omitable = true);
398  parameter -> SetDefaultValue (90.);
399  fpCommandUpThetaPhi -> SetParameter (parameter);
400  parameter = new G4UIparameter("phi", 'd', omitable = true);
401  parameter -> SetDefaultValue (90.);
402  fpCommandUpThetaPhi -> SetParameter (parameter);
403  parameter = new G4UIparameter ("unit", 's', omitable = true);
404  parameter -> SetDefaultValue ("deg");
405  fpCommandUpThetaPhi -> SetParameter (parameter);
406 
408  ("/vis/viewer/set/upVector", this);
409  fpCommandUpVector -> SetGuidance ("Set up vector.");
410  fpCommandUpVector -> SetGuidance
411  ("Viewer will attempt always to show this direction upwards.");
412  parameter = new G4UIparameter("x", 'd', omitable = true);
413  parameter -> SetDefaultValue (0.);
414  fpCommandUpVector -> SetParameter (parameter);
415  parameter = new G4UIparameter("y", 'd', omitable = true);
416  parameter -> SetDefaultValue (1.);
417  fpCommandUpVector -> SetParameter (parameter);
418  parameter = new G4UIparameter ("z", 'd', omitable = true);
419  parameter -> SetDefaultValue (0.);
420  fpCommandUpVector -> SetParameter (parameter);
421 
423  ("/vis/viewer/set/viewpointThetaPhi", this);
424  fpCommandViewpointThetaPhi -> SetGuidance
425  ("Set direction from target to camera.");
426  fpCommandViewpointThetaPhi -> SetGuidance
427  ("Also changes lightpoint direction if lights are set to move with camera.");
428  parameter = new G4UIparameter("theta", 'd', omitable = true);
429  parameter -> SetDefaultValue (60.);
430  fpCommandViewpointThetaPhi -> SetParameter (parameter);
431  parameter = new G4UIparameter("phi", 'd', omitable = true);
432  parameter -> SetDefaultValue (45.);
433  fpCommandViewpointThetaPhi -> SetParameter (parameter);
434  parameter = new G4UIparameter ("unit", 's', omitable = true);
435  parameter -> SetDefaultValue ("deg");
436  fpCommandViewpointThetaPhi -> SetParameter (parameter);
437 
439  ("/vis/viewer/set/viewpointVector", this);
440  fpCommandViewpointVector -> SetGuidance
441  ("Set direction from target to camera.");
442  fpCommandViewpointVector -> SetGuidance
443  ("Also changes lightpoint direction if lights are set to move with camera.");
444  parameter = new G4UIparameter("x", 'd', omitable = true);
445  parameter -> SetDefaultValue (1.);
446  fpCommandViewpointVector -> SetParameter (parameter);
447  parameter = new G4UIparameter("y", 'd', omitable = true);
448  parameter -> SetDefaultValue (1.);
449  fpCommandViewpointVector -> SetParameter (parameter);
450  parameter = new G4UIparameter ("z", 'd', omitable = true);
451  parameter -> SetDefaultValue (1.);
452  fpCommandViewpointVector -> SetParameter (parameter);
453 
454  fpTimeWindowDirectory = new G4UIdirectory ("/vis/viewer/set/timeWindow/");
455  fpTimeWindowDirectory -> SetGuidance ("Set time window parameters of current viewer.");
456  G4String timeWindowGuidance =
457  "For these commands use"
458  "\n /vis/scene/add/trajectories rich"
459  "\n /vis/modeling/trajectories/drawByCharge-0/default/setTimeSliceInterval 0.01 ns"
460  "\nthen typically"
461  "\n /vis/viewer/set/timeWindow/displayLightFront true 0 0 -50 cm -0.5 ns"
462  "\n /vis/viewer/set/timeWindow/displayHeadTime true"
463  "\n /vis/viewer/set/timeWindow/fadeFactor 1"
464  "\n /run/beamOn # or several until you get a good event or events"
465  "\n /vis/viewer/set/timeWindow/startTime 0 ns 1 ns"
466  "\n /vis/viewer/save"
467  "\n /vis/viewer/set/timeWindow/startTime 1 ns 1 ns"
468  "\nthen zoom, pan etc to a view of interest and"
469  "\n /vis/viewer/save"
470  "\nthen repeat with next start time, another view and a save, then try"
471  "\n /vis/viewer/interpolate";
472 
474  new G4UIcommand("/vis/viewer/set/timeWindow/displayHeadTime", this);
476  ("Display head time of range in 2D text.");
477  fpCommandTimeWindowDisplayHeadTime->SetGuidance(timeWindowGuidance);
478  parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false);
479  parameter->SetDefaultValue(false);
481  parameter = new G4UIparameter ("screenX", 'd', omitable = true);
482  parameter->SetGuidance("-1 < screenX < 1");
483  parameter->SetParameterRange("screenX >= -1. && screenX <= 1.");
484  parameter->SetDefaultValue(-0.9);
486  parameter = new G4UIparameter ("screenY", 'd', omitable = true);
487  parameter->SetGuidance("-1 < screenY < 1");
488  parameter->SetParameterRange("screenY >= -1. && screenY <= 1.");
489  parameter->SetDefaultValue(-0.9);
491  parameter = new G4UIparameter ("screenSize", 'd', omitable = true);
492  parameter->SetDefaultValue(24.);
494  parameter = new G4UIparameter ("red", 'd', omitable = true);
495  parameter->SetParameterRange("red >= 0. && red <= 1.");
496  parameter->SetDefaultValue(0.);
498  parameter = new G4UIparameter ("green", 'd', omitable = true);
499  parameter->SetParameterRange("green >= 0. && green <= 1.");
500  parameter->SetDefaultValue(1.);
502  parameter = new G4UIparameter ("blue", 'd', omitable = true);
503  parameter->SetParameterRange("blue >= 0. && blue <= 1.");
504  parameter->SetDefaultValue(1.);
506 
508  new G4UIcommand("/vis/viewer/set/timeWindow/displayLightFront", this);
510  ("Display the light front at head time.");
512  ("Tip: The trajectories can appear of jump ahead of the light front"
513  "\nbecause their time range overlaps the viewer's time range. To"
514  "\naverage out this discrete time effect, advance the light front by"
515  "\nhalf the trajectories interval. E.g., if the trajectory time slice"
516  "\ninterval is 0.01 ns:"
517  "\n /vis/viewer/set/timeWindow/displayLightFront true -90 0 0 mm -0.005 ns"
518  "\nTo prevent them beating the light front at all:"
519  "\n /vis/viewer/set/timeWindow/displayLightFront true -90 0 0 mm -0.01 ns");
521  parameter = new G4UIparameter ("displayLightFront", 'b', omitable = true);
522  parameter->SetDefaultValue(true);
524  parameter = new G4UIparameter ("originX", 'd', omitable = true);
525  parameter->SetDefaultValue(0.);
527  parameter = new G4UIparameter ("originY", 'd', omitable = true);
528  parameter->SetDefaultValue(0.);
530  parameter = new G4UIparameter ("originZ", 'd', omitable = true);
531  parameter->SetDefaultValue(0.);
533  parameter = new G4UIparameter ("space_unit", 's', omitable = true);
534  parameter->SetDefaultValue("m");
536  parameter = new G4UIparameter ("originT", 'd', omitable = true);
537  parameter->SetDefaultValue(0.);
539  parameter = new G4UIparameter ("time_unit", 's', omitable = true);
540  parameter->SetDefaultValue("s");
542  parameter = new G4UIparameter ("red", 'd', omitable = true);
543  parameter->SetParameterRange("red >= 0. && red <= 1.");
544  parameter->SetDefaultValue(0.);
546  parameter = new G4UIparameter ("green", 'd', omitable = true);
547  parameter->SetParameterRange("green >= 0. && green <= 1.");
548  parameter->SetDefaultValue(1.);
550  parameter = new G4UIparameter ("blue", 'd', omitable = true);
551  parameter->SetParameterRange("blue >= 0. && blue <= 1.");
552  parameter->SetDefaultValue(0.);
554 
556  new G4UIcommand("/vis/viewer/set/timeWindow/endTime", this);
557  fpCommandTimeWindowEndTime->SetGuidance("Set end and range of track time.");
558  fpCommandTimeWindowEndTime->SetGuidance(timeWindowGuidance);
559  parameter = new G4UIparameter ("end-time", 'd', omitable = false);
562  parameter = new G4UIparameter ("end-time-unit", 's', omitable = false);
563  parameter->SetDefaultValue("ns");
565  parameter = new G4UIparameter ("time-range", 'd', omitable = true);
566  parameter->SetDefaultValue(-1.);
568  parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
569  parameter->SetDefaultValue("ns");
571 
573  new G4UIcmdWithADouble("/vis/viewer/set/timeWindow/fadeFactor", this);
575  ("0: no fade; 1: maximum fade with time window.");
576  fpCommandTimeWindowFadeFactor->SetGuidance(timeWindowGuidance);
577  fpCommandTimeWindowFadeFactor->SetParameterName("fade_factor", omitable = false);
578  fpCommandTimeWindowFadeFactor->SetRange("fade_factor>=0.&&fade_factor<=1.");
580 
582  new G4UIcommand("/vis/viewer/set/timeWindow/startTime", this);
583  fpCommandTimeWindowStartTime->SetGuidance("Set start and range of track time.");
584  fpCommandTimeWindowStartTime->SetGuidance(timeWindowGuidance);
585  parameter = new G4UIparameter ("start-time", 'd', omitable = false);
588  parameter = new G4UIparameter ("start-time-unit", 's', omitable = false);
589  parameter->SetDefaultValue("ns");
591  parameter = new G4UIparameter ("time-range", 'd', omitable = true);
592  parameter->SetDefaultValue(-1.);
594  parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
595  parameter->SetDefaultValue("ns");
597 }
598 
605  delete fpTimeWindowDirectory;
608  delete fpCommandUpVector;
609  delete fpCommandUpThetaPhi;
610  delete fpCommandTargetPoint;
611  delete fpCommandStyle;
612  delete fpCommandSectionPlane;
613  delete fpCommandRotationStyle;
614  delete fpCommandProjection;
615  delete fpCommandPicking;
617  delete fpCommandLineSegments;
618  delete fpCommandLightsVector;
620  delete fpCommandLightsMove;
621  delete fpCommandHiddenMarker;
622  delete fpCommandHiddenEdge;
625  delete fpCommandExplodeFactor;
626  delete fpCommandEdge;
628  delete fpCommandDefaultColour;
629  delete fpCommandCutawayMode;
630  delete fpCommandCulling;
631  delete fpCommandBackground;
632  delete fpCommandAuxEdge;
633  delete fpCommandAutoRefresh;
634  delete fpCommandAll;
635 }
636 
638  return "";
639 }
640 
642 (G4UIcommand* command,G4String newValue) {
643 
644  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
645 
646  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
647  if (!currentViewer) {
648  if (verbosity >= G4VisManager::errors) {
649  G4cerr <<
650  "ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer."
651  << G4endl;
652  }
653  return;
654  }
655 
656  G4ViewParameters vp = currentViewer->GetViewParameters();
657 
658  if (command == fpCommandAll) {
659  G4VViewer* fromViewer = fpVisManager->GetViewer(newValue);
660  if (!fromViewer) {
661  if (verbosity >= G4VisManager::errors) {
662  G4cerr <<
663  "ERROR: G4VisCommandsViewerSet::SetNewValue: all:"
664  "\n unrecognised from-viewer."
665  << G4endl;
666  }
667  return;
668  }
669  if (fromViewer == currentViewer) {
670  if (verbosity >= G4VisManager::warnings) {
671  G4cout <<
672  "WARNING: G4VisCommandsViewerSet::SetNewValue: all:"
673  "\n from-viewer and current viewer are identical."
674  << G4endl;
675  }
676  return;
677  }
678  // Copy view parameters except for autoRefresh...
679  G4bool currentAutoRefresh =
680  currentViewer->GetViewParameters().IsAutoRefresh();
681  vp = fromViewer->GetViewParameters();
682  vp.SetAutoRefresh(currentAutoRefresh);
683  // Concatenate any private vis attributes modifiers...
684  const std::vector<G4ModelingParameters::VisAttributesModifier>*
685  privateVAMs = fromViewer->GetPrivateVisAttributesModifiers();
686  if (privateVAMs) {
687  std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
688  for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
690  }
691  }
692  if (verbosity >= G4VisManager::confirmations) {
693  G4cout << "View parameters of viewer \"" << currentViewer->GetName()
694  << "\"\n set to those of viewer \"" << fromViewer->GetName()
695  << "\"."
696  << G4endl;
697  }
698  if (verbosity >= G4VisManager::warnings) {
699  G4cout << "You may need \"/vis/viewer/rebuild\"."
700  << G4endl;
701  }
702  }
703 
704  else if (command == fpCommandAutoRefresh) {
705  G4bool autoRefresh = G4UIcommand::ConvertToBool(newValue);
706  const G4ViewParameters& defaultVP =
707  currentViewer->GetDefaultViewParameters();
708  if (autoRefresh && !defaultVP.IsAutoRefresh()) {
709  if (verbosity >= G4VisManager::warnings) {
710  G4cout
711  << "WARNING: "
712  << currentViewer->GetName() << " is NOT auto-refesh by default"
713  << "\n so cannot be set to auto-refresh."
714  << G4endl;
715  }
716  return;
717  }
718  vp.SetAutoRefresh(autoRefresh);
719  if (verbosity >= G4VisManager::confirmations) {
720  G4cout << "Views will ";
721  if (!vp.IsAutoRefresh()) G4cout << "not ";
722  G4cout << "be automatically refreshed after a change of view parameters."
723  << G4endl;
724  }
725  if (!vp.IsAutoRefresh()) {
726  currentViewer->SetViewParameters(vp);
727  return; // Avoid a refresh if auto-refresh has been set to off...
728  } // ...otherwise take normal action.
729  }
730 
731  else if (command == fpCommandAuxEdge) {
733  if (verbosity >= G4VisManager::confirmations) {
734  G4cout << "Auxiliary edges will ";
735  if (!vp.IsAuxEdgeVisible()) G4cout << "not ";
736  G4cout << "be visible." << G4endl;
737  }
738  }
739 
740  else if (command == fpCommandBackground) {
741  G4String redOrString;
742  G4double green, blue, opacity;
743  std::istringstream iss(newValue);
744  iss >> redOrString >> green >> blue >> opacity;
745  G4Colour colour(0.,0.,0.); // Default black and opaque.
746  ConvertToColour(colour, redOrString, green, blue, opacity);
747  vp.SetBackgroundColour(colour);
748  if (verbosity >= G4VisManager::confirmations) {
749  G4cout << "Background colour "
750  << vp.GetBackgroundColour()
751  << " requested."
752  << G4endl;
753  }
754  }
755 
756  else if (command == fpCommandCulling) {
757  G4String cullingOption, stringFlag, unit;
758  G4double density;
759  std::istringstream is (newValue);
760  is >> cullingOption >> stringFlag >> density >> unit;
761  G4bool boolFlag = G4UIcommand::ConvertToBool(stringFlag);
762  if (cullingOption == "global") {
763  vp.SetCulling(boolFlag);
764  if (verbosity >= G4VisManager::confirmations) {
765  G4cout <<
766  "G4VisCommandsViewerSet::SetNewValue: culling: global culling flag"
767  " set to " << G4UIcommand::ConvertToString(boolFlag) <<
768  ".\n Does not change specific culling flags."
769  << G4endl;
770  }
771  }
772  else if (cullingOption == "coveredDaughters") {
773  vp.SetCullingCovered(boolFlag);
774  if (verbosity >= G4VisManager::confirmations) {
775  G4cout <<
776  "G4VisCommandsViewerSet::SetNewValue: culling: culling covered"
777  "\n daughters flag set to "
778  << G4UIcommand::ConvertToString(boolFlag) <<
779  ". Daughters covered by opaque mothers"
780  "\n will be culled, i.e., not drawn, if this flag is true."
781  "\n Note: this is only effective in surface drawing style,"
782  "\n and then only if the volumes are visible and opaque, and then"
783  "\n only if no sections or cutaways are in operation."
784  << G4endl;
785  }
786  }
787  else if (cullingOption == "invisible") {
788  vp.SetCullingInvisible(boolFlag);
789  if (verbosity >= G4VisManager::confirmations) {
790  G4cout <<
791  "G4VisCommandsViewerSet::SetNewValue: culling: culling invisible"
792  "\n flag set to "
793  << boolFlag << G4UIcommand::ConvertToString(boolFlag) <<
794  ". Volumes marked invisible will be culled,"
795  "\n i.e., not drawn, if this flag is true."
796  << G4endl;
797  }
798  }
799  else if (cullingOption == "density") {
800  const G4String where =
801  "G4VisCommandsViewerSet::SetNewValue: culling: culling by density";
802  if (boolFlag) {
803  G4double valueOfUnit;
804  // "Volumic Mass" is Michel's phrase for "Density"
805  if (ProvideValueOfUnit(where,unit,"Volumic Mass",valueOfUnit)) {
806  // Successful outcome of unit search
807  vp.SetDensityCulling(boolFlag);
808  density *= valueOfUnit;
809  vp.SetVisibleDensity(density);
810  } else {
811  // Unsuccessful outcome of unit search. Flag and density unchanged.
812  density = vp.GetVisibleDensity();
813  }
814  } else { // Reset flag but density unchanged.
815  vp.SetDensityCulling(boolFlag);
816  }
817  if (verbosity >= G4VisManager::confirmations) {
818  G4cout
819  << where
820  << "\n flag set to "
821  << std::boolalpha << vp.IsDensityCulling()
822  << ". Volumes with density less than "
823  << G4BestUnit(density,"Volumic Mass")
824  << "\n will be culled, i.e., not drawn, if this flag is true."
825  << G4endl;
826  }
827  }
828  else {
829  if (verbosity >= G4VisManager::errors) {
830  G4cerr <<
831  "ERROR: G4VisCommandsViewerSet::SetNewValue: culling:"
832  "\n option not recognised."
833  << G4endl;
834  }
835  }
836  }
837 
838  else if (command == fpCommandCutawayMode) {
839  if (newValue == "add" || newValue == "union")
841  if (newValue == "multiply" || newValue == "intersection")
843 
844  if (verbosity >= G4VisManager::confirmations) {
845  G4cout << "Cutaway mode set to ";
847  G4cout << "cutawayUnion";
849  G4cout << "cutawayIntersection";
850  G4cout << G4endl;
851  }
852  }
853 
854  else if (command == fpCommandDefaultColour) {
855  G4String redOrString;
856  G4double green, blue, opacity;
857  std::istringstream iss(newValue);
858  iss >> redOrString >> green >> blue >> opacity;
859  G4Colour colour(1.,1.,1.); // Default white and opaque.
860  ConvertToColour(colour, redOrString, green, blue, opacity);
862  va.SetColour(colour);
864  if (verbosity >= G4VisManager::confirmations) {
865  G4cout << "Default colour "
867  << " requested."
868  << G4endl;
869  }
870  }
871 
872  else if (command == fpCommandDefaultTextColour) {
873  G4String redOrString;
874  G4double green, blue, opacity;
875  std::istringstream iss(newValue);
876  iss >> redOrString >> green >> blue >> opacity;
877  G4Colour colour(1.,1.,1.); // Default white and opaque.
878  ConvertToColour(colour, redOrString, green, blue, opacity);
880  va.SetColour(colour);
882  if (verbosity >= G4VisManager::confirmations) {
883  G4cout << "Default colour "
885  << " requested."
886  << G4endl;
887  }
888  }
889 
890  else if (command == fpCommandEdge) {
891  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
892  if (G4UIcommand::ConvertToBool(newValue)) { // true
893  switch (existingStyle) {
895  break;
897  break;
900  break;
902  break;
904  break;
905  }
906  }
907  else { // false
908  switch (existingStyle) {
910  break;
912  break;
914  break;
917  break;
919  break;
920  }
921  }
922  if (verbosity >= G4VisManager::confirmations) {
923  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
924  << "\" set to " << vp.GetDrawingStyle()
925  << G4endl;
926  }
927  }
928 
929  else if (command == fpCommandExplodeFactor) {
930  G4double explodeFactor, x, y, z;
931  G4String unitString;
932  std::istringstream is (newValue);
933  is >> explodeFactor >> x >> y >> z >> unitString;
934  G4double unit = G4UIcommand::ValueOf(unitString);
935  vp.SetExplodeFactor(explodeFactor);
936  vp.SetExplodeCentre(G4Point3D(x * unit, y * unit, z * unit));
937  if (verbosity >= G4VisManager::confirmations) {
938  G4cout << "Explode factor changed to " << vp.GetExplodeFactor()
939  << " from centre " << vp.GetExplodeCentre()
940  << G4endl;
941  }
942  }
943 
944  else if (command == fpCommandGlobalLineWidthScale) {
945  G4double globalLineWidthScale
946  = fpCommandGlobalLineWidthScale->GetNewDoubleValue(newValue);
947  vp.SetGlobalLineWidthScale(globalLineWidthScale);
948  if (verbosity >= G4VisManager::confirmations) {
949  G4cout << "Global Line Width Scale changed to "
950  << vp.GetGlobalLineWidthScale() << G4endl;
951  }
952  }
953 
954  else if (command == fpCommandGlobalMarkerScale) {
955  G4double globalMarkerScale
956  = fpCommandGlobalMarkerScale->GetNewDoubleValue(newValue);
957  vp.SetGlobalMarkerScale(globalMarkerScale);
958  if (verbosity >= G4VisManager::confirmations) {
959  G4cout << "Global Marker Scale changed to "
960  << vp.GetGlobalMarkerScale() << G4endl;
961  }
962  }
963 
964  else if (command == fpCommandHiddenEdge) {
965  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
966  if (G4UIcommand::ConvertToBool(newValue)) {
967  switch (existingStyle) {
970  break;
972  break;
975  break;
977  break;
979  break;
980  }
981  }
982  else {
983  switch (existingStyle) {
985  break;
988  break;
990  break;
993  break;
995  break;
996  }
997  }
998  if (verbosity >= G4VisManager::confirmations) {
999  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
1000  << "\" set to " << vp.GetDrawingStyle()
1001  << G4endl;
1002  }
1003  }
1004 
1005  else if (command == fpCommandHiddenMarker) {
1006  G4bool hidden = G4UIcommand::ConvertToBool(newValue);
1007  if (hidden) vp.SetMarkerHidden();
1008  else vp.SetMarkerNotHidden();
1009  if (verbosity >= G4VisManager::confirmations) {
1010  G4cout << "Markers will ";
1011  if (vp.IsMarkerNotHidden()) G4cout << "not ";
1012  G4cout << "be hidden under solid objects." << G4endl;
1013  }
1014  }
1015 
1016  else if (command == fpCommandLightsMove) {
1017  if (newValue.find("cam") != G4String::npos)
1018  vp.SetLightsMoveWithCamera(true);
1019  else if(newValue.find("obj") != G4String::npos)
1020  vp.SetLightsMoveWithCamera(false);
1021  else {
1022  if (verbosity >= G4VisManager::errors) {
1023  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1024  " Looking for \"cam\" or \"obj\" in string." << G4endl;
1025  }
1026  }
1027  if (verbosity >= G4VisManager::confirmations) {
1028  G4cout << "Lights move with ";
1029  if (vp.GetLightsMoveWithCamera())
1030  G4cout << "camera (object appears to rotate).";
1031  else G4cout << "object (the viewer appears to be moving).";
1032  G4cout << G4endl;
1033  }
1034  }
1035 
1036  else if (command == fpCommandLightsThetaPhi) {
1037  G4double theta, phi;
1038  if (ConvertToDoublePair(newValue, theta, phi)) {
1039  G4double x = std::sin (theta) * std::cos (phi);
1040  G4double y = std::sin (theta) * std::sin (phi);
1041  G4double z = std::cos (theta);
1042  fLightsVector = G4ThreeVector (x, y, z);
1043  vp.SetLightpointDirection(fLightsVector);
1044  if (verbosity >= G4VisManager::confirmations) {
1045  G4cout << "Lights direction set to "
1046  << vp.GetLightpointDirection() << G4endl;
1047  }
1048  }
1049  }
1050 
1051  else if (command == fpCommandLightsVector) {
1052  fLightsVector = G4UIcommand::ConvertTo3Vector(newValue);
1053  vp.SetLightpointDirection(fLightsVector);
1054  if (verbosity >= G4VisManager::confirmations) {
1055  G4cout << "Lights direction set to "
1056  << vp.GetLightpointDirection() << G4endl;
1057  }
1058  }
1059 
1060  else if (command == fpCommandLineSegments) {
1061  G4int nSides = G4UIcommand::ConvertToInt(newValue);
1062  nSides = vp.SetNoOfSides(nSides);
1063  if (verbosity >= G4VisManager::confirmations) {
1064  G4cout <<
1065  "Number of line segements per circle in polygon approximation is "
1066  << nSides << G4endl;
1067  }
1068  }
1069 
1070  else if (command == fpCommandNumberOfCloudPoints) {
1071  G4int nPoints = G4UIcommand::ConvertToInt(newValue);
1072  nPoints = vp.SetNumberOfCloudPoints(nPoints);
1073  if (verbosity >= G4VisManager::confirmations) {
1074  G4cout <<
1075  "Number of points to be used in cloud representation of volumes is "
1076  << nPoints << G4endl;
1077  }
1078  }
1079 
1080  else if (command == fpCommandPicking) {
1081  vp.SetPicking(G4UIcommand::ConvertToBool(newValue));
1082  if (verbosity >= G4VisManager::confirmations) {
1083  G4cout << "Picking ";
1084  if (vp.IsPicking()) G4cout << "requested.";
1085  else G4cout << "inhibited.";
1086  G4cout << G4endl;
1087  }
1088  if (verbosity >= G4VisManager::warnings) {
1089  G4cout << "You may need to issue \"/vis/viewer/update\"."
1090  << G4endl;
1091  }
1092  }
1093 
1094  else if (command == fpCommandProjection) {
1095  G4double fieldHalfAngle;
1096  const size_t iPos0 = 0;
1097  if (newValue[iPos0] == 'o') { // "orthogonal"
1098  fieldHalfAngle = 0.;
1099  }
1100  else if (newValue[iPos0] == 'p') { // "perspective"
1101  G4String dummy;
1102  G4String unit;
1103  std::istringstream is (newValue);
1104  is >> dummy >> fieldHalfAngle >> unit;
1105  fieldHalfAngle *= G4UIcommand::ValueOf(unit);
1106  if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
1107  if (verbosity >= G4VisManager::errors) {
1108  G4cerr <<
1109  "ERROR: Field half angle should be 0 < angle <= 89.5 degrees.";
1110  G4cout << G4endl;
1111  }
1112  return;
1113  }
1114  }
1115  else {
1116  if (verbosity >= G4VisManager::errors) {
1117  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1118  " Looking for 'o' or 'p' first character." << G4endl;
1119  }
1120  return;
1121  }
1122  vp.SetFieldHalfAngle(fieldHalfAngle);
1123  if (verbosity >= G4VisManager::confirmations) {
1124  G4cout << "Projection style of viewer \"" << currentViewer->GetName()
1125  << "\" set to ";
1126  if (fieldHalfAngle == 0.) {
1127  G4cout << "orthogonal.";
1128  }
1129  else {
1130  G4cout << "perspective\n with half angle " << fieldHalfAngle / deg
1131  << " degrees.";
1132  }
1133  G4cout << G4endl;
1134  }
1135  }
1136 
1137  else if (command == fpCommandSectionPlane) {
1138  G4String choice, unit;
1139  G4double x, y, z, nx, ny, nz, F = 1.;
1140  std::istringstream is (newValue);
1141  is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
1142  G4int iSelector = -1;
1143  if (choice.compareTo("off",G4String::ignoreCase) == 0 ||
1144  !G4UIcommand::ConvertToBool(choice)) iSelector = 0;
1145  if (choice.compareTo("on",G4String::ignoreCase) == 0 ||
1146  G4UIcommand::ConvertToBool(choice)) iSelector = 1;
1147  if (iSelector < 0) {
1148  if (verbosity >= G4VisManager::errors) {
1149  G4cout << "Choice not recognised (on/true or off/false)." << G4endl;
1150  }
1151  goto write_result;
1152  }
1153  // iSelector can only be 0 or 1
1154  switch (iSelector) {
1155  case 0:
1156  vp.UnsetSectionPlane();
1157  break;
1158  case 1:
1159  F = G4UIcommand::ValueOf(unit);
1160  x *= F; y *= F; z *= F;
1161  if (nx == 0. && ny == 0. && nz == 0.) {
1162  if (verbosity >= G4VisManager::errors) {
1163  G4cout << "Null normal." << G4endl;
1164  }
1165  break;;
1166  }
1167  const G4Normal3D& normal = G4Normal3D(nx,ny,nz).unit();
1168  vp.SetSectionPlane(G4Plane3D(normal, G4Point3D(x,y,z)));
1169  vp.SetViewpointDirection(normal);
1170  break;
1171  }
1172  write_result:
1173  if (verbosity >= G4VisManager::confirmations) {
1174  G4cout << "Section drawing is: ";
1175  if (vp.IsSection ()) G4cout << "on";
1176  else G4cout << "off";
1177  G4cout << ".\nSection plane is now: "
1178  << vp.GetSectionPlane ();
1179  G4cout << G4endl;
1180  }
1181  }
1182 
1183  else if (command == fpCommandRotationStyle) {
1185  if (newValue == "constrainUpDirection")
1187  else if (newValue == "freeRotation")
1189  else {
1190  if (verbosity >= G4VisManager::errors) {
1191  G4cerr << "ERROR: \"" << newValue << "\" not recognised." << G4endl;
1192  }
1193  return;
1194  }
1195  vp.SetRotationStyle(style);
1196  if (verbosity >= G4VisManager::confirmations) {
1197  G4cout << "Rotation style of viewer \"" << currentViewer->GetName()
1198  << "\" set to " << vp.GetRotationStyle()
1199  << G4endl;
1200  }
1201  }
1202 
1203  else if (command == fpCommandStyle) {
1204  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
1205  const size_t iPos0 = 0;
1206  if (newValue[iPos0] == 'w') { // "wireframe"
1207  switch (existingStyle) {
1209  break;
1210  case G4ViewParameters::hlr:
1211  break;
1212  case G4ViewParameters::hsr:
1214  break;
1217  break;
1220  break;
1221  }
1222  }
1223  else if (newValue[iPos0] == 's') { // "surface"
1224  switch (existingStyle) {
1227  break;
1228  case G4ViewParameters::hlr:
1230  break;
1231  case G4ViewParameters::hsr:
1232  break;
1234  break;
1237  break;
1238  }
1239  }
1240  else if (newValue[iPos0] == 'c') { // "cloud"
1241  switch (existingStyle) {
1244  break;
1245  case G4ViewParameters::hlr:
1247  break;
1248  case G4ViewParameters::hsr:
1250  break;
1253  break;
1255  break;
1256  }
1257  }
1258  else {
1259  if (verbosity >= G4VisManager::errors) {
1260  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1261  " Looking for 'w' or 's' or 'c' first character." << G4endl;
1262  }
1263  return;
1264  }
1265  if (verbosity >= G4VisManager::confirmations) {
1266  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
1267  << "\" set to " << vp.GetDrawingStyle()
1268  << G4endl;
1269  }
1270  }
1271 
1272  else if (command == fpCommandTargetPoint) {
1273  G4ThreeVector targetPoint =
1274  fpCommandTargetPoint->GetNew3VectorValue(newValue);
1275  const G4Point3D& standardTargetPoint =
1276  currentViewer->GetSceneHandler()->GetScene()->GetStandardTargetPoint();
1277  vp.SetCurrentTargetPoint(targetPoint - standardTargetPoint);
1278  if (verbosity >= G4VisManager::confirmations) {
1279  G4cout << "Target point set to "
1280  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1281  (targetPoint)
1282  << "\n\"Current Target Point\" set to "
1283  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1284  (vp.GetCurrentTargetPoint())
1285  << "\n\"Standard Target Point\" is "
1286  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1287  (standardTargetPoint)
1288  << G4endl;
1289  }
1290  }
1291 
1292  else if (command == fpCommandUpThetaPhi) {
1293  G4double theta, phi;
1294  if (ConvertToDoublePair(newValue, theta, phi)) {
1295  G4double x = std::sin (theta) * std::cos (phi);
1296  G4double y = std::sin (theta) * std::sin (phi);
1297  G4double z = std::cos (theta);
1298  fUpVector = G4ThreeVector (x, y, z);
1299  vp.SetUpVector(fUpVector);
1300  if (verbosity >= G4VisManager::confirmations) {
1301  G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1302  }
1303  }
1304  }
1305 
1306  else if (command == fpCommandUpVector) {
1307  fUpVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
1308  vp.SetUpVector(fUpVector);
1309  if (verbosity >= G4VisManager::confirmations) {
1310  G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1311  }
1312  }
1313 
1314  else if (command == fpCommandViewpointThetaPhi) {
1315  G4double theta, phi;
1316  if (ConvertToDoublePair(newValue, theta, phi)) {
1317  G4double x = std::sin (theta) * std::cos (phi);
1318  G4double y = std::sin (theta) * std::sin (phi);
1319  G4double z = std::cos (theta);
1320  fViewpointVector = G4ThreeVector (x, y, z);
1321  vp.SetViewAndLights(fViewpointVector);
1322  if (verbosity >= G4VisManager::confirmations) {
1323  G4cout << "Viewpoint direction set to "
1324  << vp.GetViewpointDirection() << G4endl;
1325  if (vp.GetLightsMoveWithCamera ()) {
1326  G4cout << "Lightpoint direction set to "
1328  }
1329  }
1330  }
1331  }
1332 
1333  else if (command == fpCommandViewpointVector) {
1334  G4ThreeVector viewpointVector = G4UIcommand::ConvertTo3Vector(newValue);
1335  if (viewpointVector.mag2() <= 0.) {
1336  if (verbosity >= G4VisManager::errors) {
1337  G4cerr << "ERROR: Null viewpoint vector. No action taken." << G4endl;
1338  }
1339  } else {
1340  fViewpointVector = viewpointVector.unit();
1341  vp.SetViewAndLights(fViewpointVector);
1342  if (verbosity >= G4VisManager::confirmations) {
1343  G4cout << "Viewpoint direction set to "
1344  << vp.GetViewpointDirection() << G4endl;
1345  if (vp.GetLightsMoveWithCamera ()) {
1346  G4cout << "Lightpoint direction set to "
1348  }
1349  }
1350  }
1351  }
1352 
1353  else if (command == fpCommandTimeWindowDisplayHeadTime)
1354  {
1355  G4String display;
1356  G4double screenX, screenY, screenSize, red, green, blue;
1357  std::istringstream iss(newValue);
1358  iss >> display >> screenX >> screenY
1359  >> screenSize >> red >> green >> blue;
1360  vp.SetDisplayHeadTime(command->ConvertToBool(display));
1361  vp.SetDisplayHeadTimeX(screenX);
1362  vp.SetDisplayHeadTimeY(screenY);
1363  vp.SetDisplayHeadTimeSize(screenSize);
1364  vp.SetDisplayHeadTimeRed(red);
1365  vp.SetDisplayHeadTimeGreen(green);
1366  vp.SetDisplayHeadTimeBlue(blue);
1367  if (verbosity >= G4VisManager::confirmations) {
1368  G4cout << "Display head time flag set: "
1369  << vp
1370  << G4endl;
1371  }
1372  }
1373 
1374  else if (command == fpCommandTimeWindowDisplayLightFront)
1375  {
1376  G4String display, originX, originY, originZ, unitS, originT, unitT;
1377  G4double red, green, blue;
1378  std::istringstream iss(newValue);
1379  iss >> display
1380  >> originX >> originY >> originZ >> unitS
1381  >> originT >> unitT
1382  >> red >> green >> blue;
1383  vp.SetDisplayLightFront(command->ConvertToBool(display));
1385  (command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)));
1387  (command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)));
1389  (command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)));
1391  (command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)));
1392  vp.SetDisplayLightFrontRed(red);
1393  vp.SetDisplayLightFrontGreen(green);
1394  vp.SetDisplayLightFrontBlue(blue);
1395  if (verbosity >= G4VisManager::confirmations) {
1396  G4cout << "Display light front flag set: "
1397  << vp
1398  << G4endl;
1399  }
1400  }
1401 
1402  else if (command == fpCommandTimeWindowEndTime)
1403  {
1404  G4String end_time_string, end_time_unit,
1405  time_range_string, time_range_unit;
1406  std::istringstream iss(newValue);
1407  iss >> end_time_string >> end_time_unit
1408  >> time_range_string >> time_range_unit;
1409  vp.SetEndTime
1410  (command->ConvertToDimensionedDouble
1411  (G4String(end_time_string + ' ' + end_time_unit)));
1412  G4double timeRange = command->ConvertToDimensionedDouble
1413  (G4String(time_range_string + ' ' + time_range_unit));
1414  if (timeRange > 0.) {
1415  vp.SetStartTime
1416  (vp.GetEndTime() - timeRange);
1417  }
1418  if (verbosity >= G4VisManager::confirmations) {
1419  G4cout
1420  << "Time window start time: " << vp.GetStartTime()/ns << " ns"
1421  << ", time window end time: " << vp.GetEndTime()/ns << " ns";
1422  if (timeRange > 0.) {
1423  G4cout << "\n (time range: " << timeRange/ns << " ns)";
1424  }
1425  G4cout << G4endl;
1426  }
1427  }
1428 
1429  else if (command == fpCommandTimeWindowFadeFactor) {
1430  vp.SetFadeFactor(command->ConvertToDouble(newValue));
1431  if (verbosity >= G4VisManager::confirmations) {
1432  G4cout << "Time window fade factor changed to " << vp.GetFadeFactor()
1433  << G4endl;
1434  }
1435  }
1436 
1437  else if (command == fpCommandTimeWindowStartTime)
1438  {
1439  G4String start_time_string, start_time_unit,
1440  time_range_string, time_range_unit;
1441  std::istringstream iss(newValue);
1442  iss >> start_time_string >> start_time_unit
1443  >> time_range_string >> time_range_unit;
1444  vp.SetStartTime
1445  (command->ConvertToDimensionedDouble
1446  (G4String(start_time_string + ' ' + start_time_unit)));
1447  G4double timeRange = command->ConvertToDimensionedDouble
1448  (G4String(time_range_string + ' ' + time_range_unit));
1449  if (timeRange > 0.) {
1450  vp.SetEndTime
1451  (vp.GetStartTime() + timeRange);
1452  }
1453  if (verbosity >= G4VisManager::confirmations) {
1454  G4cout
1455  << "Time window start time: " << vp.GetStartTime()/ns << " ns"
1456  << ", time window end time: " << vp.GetEndTime()/ns << " ns";
1457  if (timeRange > 0.) {
1458  G4cout << "\n (time range: " << timeRange/ns << " ns)";
1459  }
1460  G4cout << G4endl;
1461  }
1462  }
1463 
1464  else {
1465  if (verbosity >= G4VisManager::errors) {
1466  G4cerr <<
1467  "ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command."
1468  << G4endl;
1469  }
1470  return;
1471  }
1472 
1473  SetViewParameters(currentViewer,vp);
1474 }