Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
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 // $Id: G4VisCommandsViewerSet.cc 109510 2018-04-26 07:15:57Z 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 <iomanip>
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);
57  ("Copies view parameters.");
59  ("Copies ALL view parameters (except the autoRefresh status) from"
60  "\nfrom-viewer to current viewer. You may need \"/vis/viewer/rebuild\".");
62  ("Note: to copy only the camera-specific parameters use"
63  "\n\"/vis/viewer/copyfrom\".");
64  fpCommandAll->SetParameterName ("from-viewer-name",omitable = false);
65 
67  ("/vis/viewer/set/autoRefresh",this);
68  fpCommandAutoRefresh->SetGuidance("Sets auto-refresh.");
70  ("If true, view is automatically refreshed after a change of"
71  "\nview parameters.");
72  fpCommandAutoRefresh->SetParameterName("auto-refresh",omitable = true);
74 
76  ("/vis/viewer/set/auxiliaryEdge",this);
77  fpCommandAuxEdge->SetGuidance("Sets visibility of auxiliary edges");
79  ("Auxiliary edges, i.e., those that are part of a curved surface,"
80  "\nsometimes called soft edges, become visible/invisible.");
81  fpCommandAuxEdge->SetParameterName("edge",omitable = true);
83 
85  ("/vis/viewer/set/background",this);
87  ("Set background colour and transparency (default black and opaque).");
89  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
90  parameter -> SetDefaultValue ("0.");
91  fpCommandBackground -> SetParameter (parameter);
92  parameter = new G4UIparameter("green", 'd', omitable = true);
93  parameter -> SetDefaultValue (0.);
94  fpCommandBackground -> SetParameter (parameter);
95  parameter = new G4UIparameter ("blue", 'd', omitable = true);
96  parameter -> SetDefaultValue (0.);
97  fpCommandBackground -> SetParameter (parameter);
98  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
99  parameter -> SetDefaultValue (1.);
100  fpCommandBackground -> SetParameter (parameter);
101 
102  fpCommandCulling = new G4UIcommand("/vis/viewer/set/culling",this);
103  fpCommandCulling->SetGuidance ("Set culling options.");
105  ("\"global\": enables/disables all other culling options.");
107  ("\"coveredDaughters\": culls, i.e., eliminates, volumes that would not"
108  "\nbe seen because covered by ancester volumes in surface drawing mode,"
109  "\nand then only if the ancesters are visible and opaque, and then only"
110  "\nif no sections or cutaways are in operation. Intended solely to"
111  "\nimprove the speed of rendering visible volumes.");
113  ("\"invisible\": culls objects with the invisible attribute set.");
115  ("\"density\": culls volumes with density lower than threshold. Useful"
116  "\nfor eliminating \"container volumes\" with no physical correspondence,"
117  "\nwhose material is usually air. If this is selected, provide threshold"
118  "\ndensity and unit (e.g., g/cm3, mg/cm3 or kg/m3)."
119  );
120  parameter = new G4UIparameter("culling-option",'s',omitable = false);
121  parameter->SetParameterCandidates
122  ("global coveredDaughters invisible density");
123  fpCommandCulling->SetParameter(parameter);
124  parameter = new G4UIparameter("action",'b',omitable = true);
125  parameter->SetDefaultValue(1);
126  fpCommandCulling->SetParameter(parameter);
127  parameter = new G4UIparameter("density-threshold",'d',omitable = true);
128  parameter->SetDefaultValue("0.01");
129  fpCommandCulling->SetParameter(parameter);
130  parameter = new G4UIparameter("unit",'s',omitable = true);
131  // parameter->SetParameterCandidates ("g/cm3 mg/cm3 kg/m3");
132  // Instead of the above, SetNewValue accepts *any* density unit.
133  parameter->SetDefaultValue("g/cm3");
134  fpCommandCulling->SetParameter(parameter);
135 
137  new G4UIcmdWithAString ("/vis/viewer/set/cutawayMode", this);
139  ("Sets cutaway mode - add (union) or multiply (intersection).");
140  fpCommandCutawayMode->SetParameterName ("cutaway-mode",omitable = false);
141  fpCommandCutawayMode->SetCandidates ("add union multiply intersection");
143 
145  ("/vis/viewer/set/defaultColour",this);
147  ("Set defaultColour colour and transparency (default white and opaque).");
149  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
150  parameter -> SetDefaultValue ("1.");
151  fpCommandDefaultColour -> SetParameter (parameter);
152  parameter = new G4UIparameter("green", 'd', omitable = true);
153  parameter -> SetDefaultValue (1.);
154  fpCommandDefaultColour -> SetParameter (parameter);
155  parameter = new G4UIparameter ("blue", 'd', omitable = true);
156  parameter -> SetDefaultValue (1.);
157  fpCommandDefaultColour -> SetParameter (parameter);
158  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
159  parameter -> SetDefaultValue (1.);
160  fpCommandDefaultColour -> SetParameter (parameter);
161 
163  ("/vis/viewer/set/defaultTextColour",this);
165  ("Set defaultTextColour colour and transparency (default blue and opaque).");
167  parameter = new G4UIparameter("red_or_string", 's', omitable = true);
168  parameter -> SetDefaultValue ("0.");
169  fpCommandDefaultTextColour -> SetParameter (parameter);
170  parameter = new G4UIparameter("green", 'd', omitable = true);
171  parameter -> SetDefaultValue (0.);
172  fpCommandDefaultTextColour -> SetParameter (parameter);
173  parameter = new G4UIparameter ("blue", 'd', omitable = true);
174  parameter -> SetDefaultValue (1.);
175  fpCommandDefaultTextColour -> SetParameter (parameter);
176  parameter = new G4UIparameter ("opacity", 'd', omitable = true);
177  parameter -> SetDefaultValue (1.);
178  fpCommandDefaultTextColour -> SetParameter (parameter);
179 
180  fpCommandEdge = new G4UIcmdWithABool("/vis/viewer/set/edge",this);
182  ("Edges become visible/invisible in surface mode.");
183  fpCommandEdge->SetParameterName("edge",omitable = true);
185 
187  ("/vis/viewer/set/explodeFactor", this);
189  ("Moves top-level drawn volumes by this factor from this centre.");
190  parameter = new G4UIparameter("explodeFactor", 'd', omitable=true);
191  parameter->SetParameterRange("explodeFactor>=1.");
192  parameter->SetDefaultValue(1.);
194  parameter = new G4UIparameter("x",'d',omitable = true);
195  parameter->SetDefaultValue (0);
196  parameter->SetGuidance ("Coordinate of explode centre.");
198  parameter = new G4UIparameter("y",'d',omitable = true);
199  parameter->SetDefaultValue (0);
200  parameter->SetGuidance ("Coordinate of explode centre.");
202  parameter = new G4UIparameter("z",'d',omitable = true);
203  parameter->SetDefaultValue (0);
204  parameter->SetGuidance ("Coordinate of explode centre.");
206  parameter = new G4UIparameter("unit",'s',omitable = true);
207  parameter->SetDefaultValue ("m");
208  parameter->SetGuidance ("Unit of explode centre.");
210 
212  ("/vis/viewer/set/globalLineWidthScale", this);
214  ("Multiplies line widths by this factor.");
216  SetParameterName("scale-factor", omitable=true);
218 
220  ("/vis/viewer/set/globalMarkerScale", this);
222  ("Multiplies marker sizes by this factor.");
224  SetParameterName("scale-factor", omitable=true);
226 
228  new G4UIcmdWithABool("/vis/viewer/set/hiddenEdge",this);
230  ("Edges become hidden/seen in wireframe or surface mode.");
231  fpCommandHiddenEdge->SetParameterName("hidden-edge",omitable = true);
233 
235  new G4UIcmdWithABool("/vis/viewer/set/hiddenMarker",this);
237  ("If true, closer objects hide markers. Otherwise, markers always show.");
238  fpCommandHiddenMarker->SetParameterName("hidden-marker",omitable = true);
240 
242  ("/vis/viewer/set/lightsMove",this);
244  ("Lights move with camera or with object");
245  fpCommandLightsMove->SetParameterName("lightsMove",omitable = false);
247  ("cam camera with-camera obj object with-object");
248 
250  ("/vis/viewer/set/lightsThetaPhi", this);
252  ("Set direction from target to lights.");
253  parameter = new G4UIparameter("theta", 'd', omitable = true);
254  parameter -> SetDefaultValue(60.);
255  fpCommandLightsThetaPhi -> SetParameter (parameter);
256  parameter = new G4UIparameter("phi", 'd', omitable = true);
257  parameter -> SetDefaultValue(45.);
258  fpCommandLightsThetaPhi -> SetParameter (parameter);
259  parameter = new G4UIparameter ("unit", 's', omitable = true);
260  parameter -> SetDefaultValue ("deg");
261  fpCommandLightsThetaPhi -> SetParameter (parameter);
262 
264  ("/vis/viewer/set/lightsVector", this);
266  ("Set direction from target to lights.");
267  parameter = new G4UIparameter("x", 'd', omitable = true);
268  parameter -> SetDefaultValue (1);
269  fpCommandLightsVector -> SetParameter (parameter);
270  parameter = new G4UIparameter("y", 'd', omitable = true);
271  parameter -> SetDefaultValue (1);
272  fpCommandLightsVector -> SetParameter (parameter);
273  parameter = new G4UIparameter ("z", 'd', omitable = true);
274  parameter -> SetDefaultValue (1);
275  fpCommandLightsVector -> SetParameter (parameter);
276 
278  ("/vis/viewer/set/lineSegmentsPerCircle",this);
280  ("Set number of sides per circle for polygon/polyhedron drawing.");
282  ("Refers to graphical representation of objects with curved lines/surfaces.");
283  fpCommandLineSegments->SetParameterName("line-segments",omitable = true);
285 
287  ("/vis/viewer/set/picking",this);
288  fpCommandPicking->SetGuidance("Sets picking, if available.");
290  ("If true, view is set up for picking, if available.");
292  ("You may need to issue \"/vis/viewer/update\".");
294  ("For required actions, watch for instructions for viewer.");
295  fpCommandPicking->SetParameterName("picking",omitable = true);
297 
298  fpCommandProjection = new G4UIcommand("/vis/viewer/set/projection",this);
300  ("Set projection style - o[rthogonal] or p[erspective]."
301  "\nIf p[erspective], also set field half angle.");
302  parameter = new G4UIparameter("projection",'s',omitable = true);
303  parameter->SetParameterCandidates("o orthogonal p perspective");
304  parameter->SetDefaultValue("orthogonal");
305  fpCommandProjection->SetParameter(parameter);
306  parameter = new G4UIparameter("field-half-angle",'d',omitable = true);
307  parameter->SetDefaultValue(30.);
308  //parameter->SetCurrentAsDefault(true);
309  fpCommandProjection->SetParameter(parameter);
310  parameter = new G4UIparameter("unit",'s',omitable = true);
311  parameter->SetDefaultValue("deg");
312  //parameter->SetCurrentAsDefault(true);
313  fpCommandProjection->SetParameter(parameter);
314 
316  ("/vis/viewer/set/rotationStyle",this);
318  ("Set style of rotation - constrainUpDirection or freeRotation.");
320  ("constrainUpDirection: conventional HEP view.");
322  ("freeRotation: Google-like rotation, using mouse-grab.");
323  fpCommandRotationStyle->SetParameterName ("style",omitable = false);
324  fpCommandRotationStyle->SetCandidates("constrainUpDirection freeRotation");
325 
326  fpCommandSectionPlane = new G4UIcommand("/vis/viewer/set/sectionPlane",this);
327  fpCommandSectionPlane -> SetGuidance
328  ("Set plane for drawing section (DCUT).");
329  fpCommandSectionPlane -> SetGuidance
330  ("E.g., for a y-z plane at x = 1 cm:"
331  "\n\"/vis/viewer/set/sectionPlane on 1 0 0 cm 1 0 0\"."
332  "\nTo turn off: /vis/viewer/set/sectionPlane off");
333  parameter = new G4UIparameter("Selector",'c',true);
334  parameter -> SetDefaultValue ("on");
336  parameter = new G4UIparameter("x",'d',omitable = true);
337  parameter -> SetDefaultValue (0);
338  parameter -> SetGuidance ("Coordinate of point on the plane.");
340  parameter = new G4UIparameter("y",'d',omitable = true);
341  parameter -> SetDefaultValue (0);
342  parameter -> SetGuidance ("Coordinate of point on the plane.");
344  parameter = new G4UIparameter("z",'d',omitable = true);
345  parameter -> SetDefaultValue (0);
346  parameter -> SetGuidance ("Coordinate of point on the plane.");
348  parameter = new G4UIparameter("unit",'s',omitable = true);
349  parameter -> SetDefaultValue ("m");
350  parameter -> SetGuidance ("Unit of point on the plane.");
352  parameter = new G4UIparameter("nx",'d',omitable = true);
353  parameter -> SetDefaultValue (1);
354  parameter -> SetGuidance ("Component of plane normal.");
356  parameter = new G4UIparameter("ny",'d',omitable = true);
357  parameter -> SetDefaultValue (0);
358  parameter -> SetGuidance ("Component of plane normal.");
360  parameter = new G4UIparameter("nz",'d',omitable = true);
361  parameter -> SetDefaultValue (0);
362  parameter -> SetGuidance ("Component of plane normal.");
364 
365  fpCommandStyle = new G4UIcmdWithAString ("/vis/viewer/set/style",this);
367  ("Set style of drawing - w[ireframe] or s[urface].");
369  ("(Hidden line drawing is controlled by \"/vis/viewer/set/hiddenEdge\".)");
370  fpCommandStyle->SetParameterName ("style",omitable = false);
371  fpCommandStyle->SetCandidates("w wireframe s surface");
372 
374  ("/vis/viewer/set/targetPoint", this);
376  ("Set target point.");
378  ("This sets the \"Current Target Point\" relative to the \"Standard");
380  ("Target Point\" so that the actual target point is as requested.");
382  ("(See G4ViewParameters.hh for an explanation of target points.)");
383  fpCommandTargetPoint->SetParameterName("x", "y", "z", omitable = false);
385 
387  ("/vis/viewer/set/upThetaPhi", this);
388  fpCommandUpThetaPhi -> SetGuidance ("Set up vector.");
389  fpCommandUpThetaPhi -> SetGuidance
390  ("Viewer will attempt always to show this direction upwards.");
391  parameter = new G4UIparameter("theta", 'd', omitable = true);
392  parameter -> SetDefaultValue (90.);
393  fpCommandUpThetaPhi -> SetParameter (parameter);
394  parameter = new G4UIparameter("phi", 'd', omitable = true);
395  parameter -> SetDefaultValue (90.);
396  fpCommandUpThetaPhi -> SetParameter (parameter);
397  parameter = new G4UIparameter ("unit", 's', omitable = true);
398  parameter -> SetDefaultValue ("deg");
399  fpCommandUpThetaPhi -> SetParameter (parameter);
400 
402  ("/vis/viewer/set/upVector", this);
403  fpCommandUpVector -> SetGuidance ("Set up vector.");
404  fpCommandUpVector -> SetGuidance
405  ("Viewer will attempt always to show this direction upwards.");
406  parameter = new G4UIparameter("x", 'd', omitable = true);
407  parameter -> SetDefaultValue (0.);
408  fpCommandUpVector -> SetParameter (parameter);
409  parameter = new G4UIparameter("y", 'd', omitable = true);
410  parameter -> SetDefaultValue (1.);
411  fpCommandUpVector -> SetParameter (parameter);
412  parameter = new G4UIparameter ("z", 'd', omitable = true);
413  parameter -> SetDefaultValue (0.);
414  fpCommandUpVector -> SetParameter (parameter);
415 
417  ("/vis/viewer/set/viewpointThetaPhi", this);
418  fpCommandViewpointThetaPhi -> SetGuidance
419  ("Set direction from target to camera.");
420  fpCommandViewpointThetaPhi -> SetGuidance
421  ("Also changes lightpoint direction if lights are set to move with camera.");
422  parameter = new G4UIparameter("theta", 'd', omitable = true);
423  parameter -> SetDefaultValue (60.);
424  fpCommandViewpointThetaPhi -> SetParameter (parameter);
425  parameter = new G4UIparameter("phi", 'd', omitable = true);
426  parameter -> SetDefaultValue (45.);
427  fpCommandViewpointThetaPhi -> SetParameter (parameter);
428  parameter = new G4UIparameter ("unit", 's', omitable = true);
429  parameter -> SetDefaultValue ("deg");
430  fpCommandViewpointThetaPhi -> SetParameter (parameter);
431 
433  ("/vis/viewer/set/viewpointVector", this);
434  fpCommandViewpointVector -> SetGuidance
435  ("Set direction from target to camera.");
436  fpCommandViewpointVector -> SetGuidance
437  ("Also changes lightpoint direction if lights are set to move with camera.");
438  parameter = new G4UIparameter("x", 'd', omitable = true);
439  parameter -> SetDefaultValue (1.);
440  fpCommandViewpointVector -> SetParameter (parameter);
441  parameter = new G4UIparameter("y", 'd', omitable = true);
442  parameter -> SetDefaultValue (1.);
443  fpCommandViewpointVector -> SetParameter (parameter);
444  parameter = new G4UIparameter ("z", 'd', omitable = true);
445  parameter -> SetDefaultValue (1.);
446  fpCommandViewpointVector -> SetParameter (parameter);
447 
448  fpTimeWindowDirectory = new G4UIdirectory ("/vis/viewer/set/timeWindow/");
449  fpTimeWindowDirectory -> SetGuidance ("Set time window parameters of current viewer.");
450  G4String timeWindowGuidance =
451  "For these commands use"
452  "\n /vis/scene/add/trajectories rich"
453  "\n /vis/modeling/trajectories/drawByCharge-0/default/setTimeSliceInterval 0.01 ns"
454  "\nthen typically"
455  "\n /vis/viewer/set/timeWindow/displayLightFront true 0 0 -50 cm -0.5 ns"
456  "\n /vis/viewer/set/timeWindow/displayHeadTime true"
457  "\n /vis/viewer/set/timeWindow/fadeFactor 1"
458  "\n /run/beamOn # or several until you get a good event or events"
459  "\n /vis/viewer/set/timeWindow/startTime 0 ns 1 ns"
460  "\n /vis/viewer/save"
461  "\n /vis/viewer/set/timeWindow/startTime 1 ns 1 ns"
462  "\nthen zoom, pan etc to a view of interest and"
463  "\n /vis/viewer/save"
464  "\nthen repeat with next start time, another view and a save, then try"
465  "\n /vis/viewer/interpolate";
466 
468  new G4UIcommand("/vis/viewer/set/timeWindow/displayHeadTime", this);
470  ("Display head time of range in 2D text.");
471  fpCommandTimeWindowDisplayHeadTime->SetGuidance(timeWindowGuidance);
472  parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false);
473  parameter->SetDefaultValue(false);
475  parameter = new G4UIparameter ("screenX", 'd', omitable = true);
476  parameter->SetGuidance("-1 < screenX < 1");
477  parameter->SetParameterRange("screenX >= -1. && screenX <= 1.");
478  parameter->SetDefaultValue(-0.9);
480  parameter = new G4UIparameter ("screenY", 'd', omitable = true);
481  parameter->SetGuidance("-1 < screenY < 1");
482  parameter->SetParameterRange("screenY >= -1. && screenY <= 1.");
483  parameter->SetDefaultValue(-0.9);
485  parameter = new G4UIparameter ("screenSize", 'd', omitable = true);
486  parameter->SetDefaultValue(24.);
488  parameter = new G4UIparameter ("red", 'd', omitable = true);
489  parameter->SetParameterRange("red >= 0. && red <= 1.");
490  parameter->SetDefaultValue(0.);
492  parameter = new G4UIparameter ("green", 'd', omitable = true);
493  parameter->SetParameterRange("green >= 0. && green <= 1.");
494  parameter->SetDefaultValue(1.);
496  parameter = new G4UIparameter ("blue", 'd', omitable = true);
497  parameter->SetParameterRange("blue >= 0. && blue <= 1.");
498  parameter->SetDefaultValue(1.);
500 
502  new G4UIcommand("/vis/viewer/set/timeWindow/displayLightFront", this);
504  ("Display the light front at head time.");
506  ("Tip: The trajectories can appear of jump ahead of the light front"
507  "\nbecause their time range overlaps the viewer's time range. To"
508  "\naverage out this discrete time effect, advance the light front by"
509  "\nhalf the trajectories interval. E.g., if the trajectory time slice"
510  "\ninterval is 0.01 ns:"
511  "\n /vis/viewer/set/timeWindow/displayLightFront true -90 0 0 mm -0.005 ns"
512  "\nTo prevent them beating the light front at all:"
513  "\n /vis/viewer/set/timeWindow/displayLightFront true -90 0 0 mm -0.01 ns");
515  parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false);
516  parameter->SetDefaultValue(false);
518  parameter = new G4UIparameter ("originX", 'd', omitable = true);
519  parameter->SetDefaultValue(0.);
521  parameter = new G4UIparameter ("originY", 'd', omitable = true);
522  parameter->SetDefaultValue(0.);
524  parameter = new G4UIparameter ("originZ", 'd', omitable = true);
525  parameter->SetDefaultValue(0.);
527  parameter = new G4UIparameter ("space_unit", 's', omitable = true);
528  parameter->SetDefaultValue("m");
530  parameter = new G4UIparameter ("originT", 'd', omitable = true);
531  parameter->SetDefaultValue(0.);
533  parameter = new G4UIparameter ("time_unit", 's', omitable = true);
534  parameter->SetDefaultValue("s");
536  parameter = new G4UIparameter ("red", 'd', omitable = true);
537  parameter->SetParameterRange("red >= 0. && red <= 1.");
538  parameter->SetDefaultValue(0.);
540  parameter = new G4UIparameter ("green", 'd', omitable = true);
541  parameter->SetParameterRange("green >= 0. && green <= 1.");
542  parameter->SetDefaultValue(1.);
544  parameter = new G4UIparameter ("blue", 'd', omitable = true);
545  parameter->SetParameterRange("blue >= 0. && blue <= 1.");
546  parameter->SetDefaultValue(0.);
548 
550  new G4UIcommand("/vis/viewer/set/timeWindow/endTime", this);
551  fpCommandTimeWindowEndTime->SetGuidance("Set end and range of track time.");
552  fpCommandTimeWindowEndTime->SetGuidance(timeWindowGuidance);
553  parameter = new G4UIparameter ("end-time", 'd', omitable = false);
556  parameter = new G4UIparameter ("end-time-unit", 's', omitable = false);
557  parameter->SetDefaultValue("ns");
559  parameter = new G4UIparameter ("time-range", 'd', omitable = true);
560  parameter->SetDefaultValue(-1.);
562  parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
563  parameter->SetDefaultValue("ns");
565 
567  new G4UIcmdWithADouble("/vis/viewer/set/timeWindow/fadeFactor", this);
569  ("0: no fade; 1: maximum fade with time window.");
570  fpCommandTimeWindowFadeFactor->SetGuidance(timeWindowGuidance);
571  fpCommandTimeWindowFadeFactor->SetParameterName("fade_factor", omitable = false);
572  fpCommandTimeWindowFadeFactor->SetRange("fade_factor>=0.&&fade_factor<=1.");
574 
576  new G4UIcommand("/vis/viewer/set/timeWindow/startTime", this);
577  fpCommandTimeWindowStartTime->SetGuidance("Set start and range of track time.");
578  fpCommandTimeWindowStartTime->SetGuidance(timeWindowGuidance);
579  parameter = new G4UIparameter ("start-time", 'd', omitable = false);
582  parameter = new G4UIparameter ("start-time-unit", 's', omitable = false);
583  parameter->SetDefaultValue("ns");
585  parameter = new G4UIparameter ("time-range", 'd', omitable = true);
586  parameter->SetDefaultValue(-1.);
588  parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
589  parameter->SetDefaultValue("ns");
591 }
592 
599  delete fpTimeWindowDirectory;
602  delete fpCommandUpVector;
603  delete fpCommandUpThetaPhi;
604  delete fpCommandTargetPoint;
605  delete fpCommandStyle;
606  delete fpCommandSectionPlane;
607  delete fpCommandRotationStyle;
608  delete fpCommandProjection;
609  delete fpCommandPicking;
610  delete fpCommandLineSegments;
611  delete fpCommandLightsVector;
613  delete fpCommandLightsMove;
614  delete fpCommandHiddenMarker;
615  delete fpCommandHiddenEdge;
618  delete fpCommandExplodeFactor;
619  delete fpCommandEdge;
621  delete fpCommandDefaultColour;
622  delete fpCommandCutawayMode;
623  delete fpCommandCulling;
624  delete fpCommandBackground;
625  delete fpCommandAuxEdge;
626  delete fpCommandAutoRefresh;
627  delete fpCommandAll;
628 }
629 
631  return "";
632 }
633 
635 (G4UIcommand* command,G4String newValue) {
636 
637  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
638 
639  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
640  if (!currentViewer) {
641  if (verbosity >= G4VisManager::errors) {
642  G4cerr <<
643  "ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer."
644  << G4endl;
645  }
646  return;
647  }
648 
649  G4ViewParameters vp = currentViewer->GetViewParameters();
650 
651  if (command == fpCommandAll) {
652  G4VViewer* fromViewer = fpVisManager->GetViewer(newValue);
653  if (!fromViewer) {
654  if (verbosity >= G4VisManager::errors) {
655  G4cerr <<
656  "ERROR: G4VisCommandsViewerSet::SetNewValue: all:"
657  "\n unrecognised from-viewer."
658  << G4endl;
659  }
660  return;
661  }
662  if (fromViewer == currentViewer) {
663  if (verbosity >= G4VisManager::warnings) {
664  G4cout <<
665  "WARNING: G4VisCommandsViewerSet::SetNewValue: all:"
666  "\n from-viewer and current viewer are identical."
667  << G4endl;
668  }
669  return;
670  }
671  // Copy view parameters except for autoRefresh...
672  G4bool currentAutoRefresh =
673  currentViewer->GetViewParameters().IsAutoRefresh();
674  vp = fromViewer->GetViewParameters();
675  vp.SetAutoRefresh(currentAutoRefresh);
676  // Concatenate any private vis attributes modifiers...
677  const std::vector<G4ModelingParameters::VisAttributesModifier>*
678  privateVAMs = fromViewer->GetPrivateVisAttributesModifiers();
679  if (privateVAMs) {
680  std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
681  for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
683  }
684  }
685  if (verbosity >= G4VisManager::confirmations) {
686  G4cout << "View parameters of viewer \"" << currentViewer->GetName()
687  << "\"\n set to those of viewer \"" << fromViewer->GetName()
688  << "\"."
689  << G4endl;
690  }
691  if (verbosity >= G4VisManager::warnings) {
692  G4cout << "You may need \"/vis/viewer/rebuild\"."
693  << G4endl;
694  }
695  }
696 
697  else if (command == fpCommandAutoRefresh) {
698  G4bool autoRefresh = G4UIcommand::ConvertToBool(newValue);
699  const G4ViewParameters& defaultVP =
700  currentViewer->GetDefaultViewParameters();
701  if (autoRefresh && !defaultVP.IsAutoRefresh()) {
702  if (verbosity >= G4VisManager::warnings) {
703  G4cout
704  << "WARNING: "
705  << currentViewer->GetName() << " is NOT auto-refesh by default"
706  << "\n so cannot be set to auto-refresh."
707  << G4endl;
708  }
709  return;
710  }
711  vp.SetAutoRefresh(autoRefresh);
712  if (verbosity >= G4VisManager::confirmations) {
713  G4cout << "Views will ";
714  if (!vp.IsAutoRefresh()) G4cout << "not ";
715  G4cout << "be automatically refreshed after a change of view parameters."
716  << G4endl;
717  }
718  if (!vp.IsAutoRefresh()) {
719  currentViewer->SetViewParameters(vp);
720  return; // Avoid a refresh if auto-refresh has been set to off...
721  } // ...otherwise take normal action.
722  }
723 
724  else if (command == fpCommandAuxEdge) {
726  if (verbosity >= G4VisManager::confirmations) {
727  G4cout << "Auxiliary edges will ";
728  if (!vp.IsAuxEdgeVisible()) G4cout << "not ";
729  G4cout << "be visible." << G4endl;
730  }
731  }
732 
733  else if (command == fpCommandBackground) {
734  G4String redOrString;
735  G4double green, blue, opacity;
736  std::istringstream iss(newValue);
737  iss >> redOrString >> green >> blue >> opacity;
738  G4Colour colour(0.,0.,0.); // Default black and opaque.
739  ConvertToColour(colour, redOrString, green, blue, opacity);
740  vp.SetBackgroundColour(colour);
741  if (verbosity >= G4VisManager::confirmations) {
742  G4cout << "Background colour "
743  << vp.GetBackgroundColour()
744  << " requested."
745  << G4endl;
746  }
747  }
748 
749  else if (command == fpCommandCulling) {
750  G4String cullingOption, stringFlag, unit;
751  G4double density;
752  std::istringstream is (newValue);
753  is >> cullingOption >> stringFlag >> density >> unit;
754  G4bool boolFlag = G4UIcommand::ConvertToBool(stringFlag);
755  if (cullingOption == "global") {
756  vp.SetCulling(boolFlag);
757  if (verbosity >= G4VisManager::confirmations) {
758  G4cout <<
759  "G4VisCommandsViewerSet::SetNewValue: culling: global culling flag"
760  " set to " << G4UIcommand::ConvertToString(boolFlag) <<
761  ".\n Does not change specific culling flags."
762  << G4endl;
763  }
764  }
765  else if (cullingOption == "coveredDaughters") {
766  vp.SetCullingCovered(boolFlag);
767  if (verbosity >= G4VisManager::confirmations) {
768  G4cout <<
769  "G4VisCommandsViewerSet::SetNewValue: culling: culling covered"
770  "\n daughters flag set to "
771  << G4UIcommand::ConvertToString(boolFlag) <<
772  ". Daughters covered by opaque mothers"
773  "\n will be culled, i.e., not drawn, if this flag is true."
774  "\n Note: this is only effective in surface drawing style,"
775  "\n and then only if the volumes are visible and opaque, and then"
776  "\n only if no sections or cutaways are in operation."
777  << G4endl;
778  }
779  }
780  else if (cullingOption == "invisible") {
781  vp.SetCullingInvisible(boolFlag);
782  if (verbosity >= G4VisManager::confirmations) {
783  G4cout <<
784  "G4VisCommandsViewerSet::SetNewValue: culling: culling invisible"
785  "\n flag set to "
786  << boolFlag << G4UIcommand::ConvertToString(boolFlag) <<
787  ". Volumes marked invisible will be culled,"
788  "\n i.e., not drawn, if this flag is true."
789  << G4endl;
790  }
791  }
792  else if (cullingOption == "density") {
793  const G4String where =
794  "G4VisCommandsViewerSet::SetNewValue: culling: culling by density";
795  if (boolFlag) {
796  G4double valueOfUnit;
797  // "Volumic Mass" is Michel's phrase for "Density"
798  if (ProvideValueOfUnit(where,unit,"Volumic Mass",valueOfUnit)) {
799  // Successful outcome of unit search
800  vp.SetDensityCulling(boolFlag);
801  density *= valueOfUnit;
802  vp.SetVisibleDensity(density);
803  } else {
804  // Unsuccessful outcome of unit search. Flag and density unchanged.
805  density = vp.GetVisibleDensity();
806  }
807  } else { // Reset flag but density unchanged.
808  vp.SetDensityCulling(boolFlag);
809  }
810  if (verbosity >= G4VisManager::confirmations) {
811  G4cout
812  << where
813  << "\n flag set to "
814  << std::boolalpha << vp.IsDensityCulling()
815  << ". Volumes with density less than "
816  << G4BestUnit(density,"Volumic Mass")
817  << "\n will be culled, i.e., not drawn, if this flag is true."
818  << G4endl;
819  }
820  }
821  else {
822  if (verbosity >= G4VisManager::errors) {
823  G4cerr <<
824  "ERROR: G4VisCommandsViewerSet::SetNewValue: culling:"
825  "\n option not recognised."
826  << G4endl;
827  }
828  }
829  }
830 
831  else if (command == fpCommandCutawayMode) {
832  if (newValue == "add" || newValue == "union")
834  if (newValue == "multiply" || newValue == "intersection")
836 
837  if (verbosity >= G4VisManager::confirmations) {
838  G4cout << "Cutaway mode set to ";
840  G4cout << "cutawayUnion";
842  G4cout << "cutawayIntersection";
843  G4cout << G4endl;
844  }
845  }
846 
847  else if (command == fpCommandDefaultColour) {
848  G4String redOrString;
849  G4double green, blue, opacity;
850  std::istringstream iss(newValue);
851  iss >> redOrString >> green >> blue >> opacity;
852  G4Colour colour(1.,1.,1.); // Default white and opaque.
853  ConvertToColour(colour, redOrString, green, blue, opacity);
855  va.SetColour(colour);
857  if (verbosity >= G4VisManager::confirmations) {
858  G4cout << "Default colour "
860  << " requested."
861  << G4endl;
862  }
863  }
864 
865  else if (command == fpCommandDefaultTextColour) {
866  G4String redOrString;
867  G4double green, blue, opacity;
868  std::istringstream iss(newValue);
869  iss >> redOrString >> green >> blue >> opacity;
870  G4Colour colour(1.,1.,1.); // Default white and opaque.
871  ConvertToColour(colour, redOrString, green, blue, opacity);
873  va.SetColour(colour);
875  if (verbosity >= G4VisManager::confirmations) {
876  G4cout << "Default colour "
878  << " requested."
879  << G4endl;
880  }
881  }
882 
883  else if (command == fpCommandEdge) {
884  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
885  if (G4UIcommand::ConvertToBool(newValue)) {
886  switch (existingStyle) {
888  break;
890  break;
893  break;
895  break;
896  }
897  }
898  else {
899  switch (existingStyle) {
901  break;
903  break;
905  break;
908  break;
909  }
910  }
911  if (verbosity >= G4VisManager::confirmations) {
912  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
913  << "\" set to " << vp.GetDrawingStyle()
914  << G4endl;
915  }
916  }
917 
918  else if (command == fpCommandExplodeFactor) {
919  G4double explodeFactor, x, y, z;
920  G4String unitString;
921  std::istringstream is (newValue);
922  is >> explodeFactor >> x >> y >> z >> unitString;
923  G4double unit = G4UIcommand::ValueOf(unitString);
924  vp.SetExplodeFactor(explodeFactor);
925  vp.SetExplodeCentre(G4Point3D(x * unit, y * unit, z * unit));
926  if (verbosity >= G4VisManager::confirmations) {
927  G4cout << "Explode factor changed to " << vp.GetExplodeFactor()
928  << " from centre " << vp.GetExplodeCentre()
929  << G4endl;
930  }
931  }
932 
933  else if (command == fpCommandGlobalLineWidthScale) {
934  G4double globalLineWidthScale
935  = fpCommandGlobalLineWidthScale->GetNewDoubleValue(newValue);
936  vp.SetGlobalLineWidthScale(globalLineWidthScale);
937  if (verbosity >= G4VisManager::confirmations) {
938  G4cout << "Global Line Width Scale changed to "
939  << vp.GetGlobalLineWidthScale() << G4endl;
940  }
941  }
942 
943  else if (command == fpCommandGlobalMarkerScale) {
944  G4double globalMarkerScale
945  = fpCommandGlobalMarkerScale->GetNewDoubleValue(newValue);
946  vp.SetGlobalMarkerScale(globalMarkerScale);
947  if (verbosity >= G4VisManager::confirmations) {
948  G4cout << "Global Marker Scale changed to "
949  << vp.GetGlobalMarkerScale() << G4endl;
950  }
951  }
952 
953  else if (command == fpCommandHiddenEdge) {
954  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
955  if (G4UIcommand::ConvertToBool(newValue)) {
956  switch (existingStyle) {
959  break;
961  break;
964  break;
966  break;
967  }
968  }
969  else {
970  switch (existingStyle) {
972  break;
975  break;
977  break;
980  break;
981  }
982  }
983  if (verbosity >= G4VisManager::confirmations) {
984  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
985  << "\" set to " << vp.GetDrawingStyle()
986  << G4endl;
987  }
988  }
989 
990  else if (command == fpCommandHiddenMarker) {
991  G4bool hidden = G4UIcommand::ConvertToBool(newValue);
992  if (hidden) vp.SetMarkerHidden();
993  else vp.SetMarkerNotHidden();
994  if (verbosity >= G4VisManager::confirmations) {
995  G4cout << "Markers will ";
996  if (vp.IsMarkerNotHidden()) G4cout << "not ";
997  G4cout << "be hidden under solid objects." << G4endl;
998  }
999  }
1000 
1001  else if (command == fpCommandLightsMove) {
1002  if (newValue.find("cam") != G4String::npos)
1003  vp.SetLightsMoveWithCamera(true);
1004  else if(newValue.find("obj") != G4String::npos)
1005  vp.SetLightsMoveWithCamera(false);
1006  else {
1007  if (verbosity >= G4VisManager::errors) {
1008  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1009  " Looking for \"cam\" or \"obj\" in string." << G4endl;
1010  }
1011  }
1012  if (verbosity >= G4VisManager::confirmations) {
1013  G4cout << "Lights move with ";
1014  if (vp.GetLightsMoveWithCamera())
1015  G4cout << "camera (object appears to rotate).";
1016  else G4cout << "object (the viewer appears to be moving).";
1017  G4cout << G4endl;
1018  }
1019  }
1020 
1021  else if (command == fpCommandLightsThetaPhi) {
1022  G4double theta, phi;
1023  if (ConvertToDoublePair(newValue, theta, phi)) {
1024  G4double x = std::sin (theta) * std::cos (phi);
1025  G4double y = std::sin (theta) * std::sin (phi);
1026  G4double z = std::cos (theta);
1027  fLightsVector = G4ThreeVector (x, y, z);
1028  vp.SetLightpointDirection(fLightsVector);
1029  if (verbosity >= G4VisManager::confirmations) {
1030  G4cout << "Lights direction set to "
1031  << vp.GetLightpointDirection() << G4endl;
1032  }
1033  }
1034  }
1035 
1036  else if (command == fpCommandLightsVector) {
1037  fLightsVector = G4UIcommand::ConvertTo3Vector(newValue);
1038  vp.SetLightpointDirection(fLightsVector);
1039  if (verbosity >= G4VisManager::confirmations) {
1040  G4cout << "Lights direction set to "
1041  << vp.GetLightpointDirection() << G4endl;
1042  }
1043  }
1044 
1045  else if (command == fpCommandLineSegments) {
1046  G4int nSides = G4UIcommand::ConvertToInt(newValue);
1047  nSides = vp.SetNoOfSides(nSides);
1048  if (verbosity >= G4VisManager::confirmations) {
1049  G4cout <<
1050  "Number of line segements per circle in polygon approximation is "
1051  << nSides << G4endl;
1052  }
1053  }
1054 
1055  else if (command == fpCommandPicking) {
1056  vp.SetPicking(G4UIcommand::ConvertToBool(newValue));
1057  if (verbosity >= G4VisManager::confirmations) {
1058  G4cout << "Picking ";
1059  if (vp.IsPicking()) G4cout << "requested.";
1060  else G4cout << "inhibited.";
1061  G4cout << G4endl;
1062  }
1063  if (verbosity >= G4VisManager::warnings) {
1064  G4cout << "You may need to issue \"/vis/viewer/update\"."
1065  << G4endl;
1066  }
1067  }
1068 
1069  else if (command == fpCommandProjection) {
1070  G4double fieldHalfAngle;
1071  const size_t iPos0 = 0;
1072  if (newValue[iPos0] == 'o') { // "orthogonal"
1073  fieldHalfAngle = 0.;
1074  }
1075  else if (newValue[iPos0] == 'p') { // "perspective"
1076  G4String dummy;
1077  G4String unit;
1078  std::istringstream is (newValue);
1079  is >> dummy >> fieldHalfAngle >> unit;
1080  fieldHalfAngle *= G4UIcommand::ValueOf(unit);
1081  if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
1082  if (verbosity >= G4VisManager::errors) {
1083  G4cerr <<
1084  "ERROR: Field half angle should be 0 < angle <= 89.5 degrees.";
1085  G4cout << G4endl;
1086  }
1087  return;
1088  }
1089  }
1090  else {
1091  if (verbosity >= G4VisManager::errors) {
1092  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1093  " Looking for 'o' or 'p' first character." << G4endl;
1094  }
1095  return;
1096  }
1097  vp.SetFieldHalfAngle(fieldHalfAngle);
1098  if (verbosity >= G4VisManager::confirmations) {
1099  G4cout << "Projection style of viewer \"" << currentViewer->GetName()
1100  << "\" set to ";
1101  if (fieldHalfAngle == 0.) {
1102  G4cout << "orthogonal.";
1103  }
1104  else {
1105  G4cout << "perspective\n with half angle " << fieldHalfAngle / deg
1106  << " degrees.";
1107  }
1108  G4cout << G4endl;
1109  }
1110  }
1111 
1112  else if (command == fpCommandSectionPlane) {
1113  G4String choice, unit;
1114  G4double x, y, z, nx, ny, nz;
1115  std::istringstream is (newValue);
1116  is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
1117  G4int iSelector = -1;
1118  if (choice.compareTo("off",G4String::ignoreCase) == 0 ||
1119  !G4UIcommand::ConvertToBool(choice)) iSelector = 0;
1120  if (choice.compareTo("on",G4String::ignoreCase) == 0 ||
1121  G4UIcommand::ConvertToBool(choice)) iSelector = 1;
1122  if (iSelector < 0) {
1123  if (verbosity >= G4VisManager::errors) {
1124  G4cout << "Choice not recognised (on/true or off/false)." << G4endl;
1125  G4cout << "Section drawing is currently: ";
1126  if (vp.IsSection ()) G4cout << "on";
1127  else G4cout << "off";
1128  G4cout << ".\nSection plane is currently: "
1129  << vp.GetSectionPlane ();
1130  G4cout << G4endl;
1131  }
1132  return;
1133  }
1134  G4double F = 1.;
1135  // iSelector can only be 0 or 1
1136  switch (iSelector) {
1137  case 0:
1138  vp.UnsetSectionPlane();
1139  break;
1140  case 1:
1141  F = G4UIcommand::ValueOf(unit);
1142  x *= F; y *= F; z *= F;
1143  vp.SetSectionPlane(G4Plane3D(G4Normal3D(nx,ny,nz), G4Point3D(x,y,z)));
1144  vp.SetViewpointDirection(G4Normal3D(nx,ny,nz));
1145  break;
1146  }
1147  if (verbosity >= G4VisManager::confirmations) {
1148  G4cout << "Section drawing is now: ";
1149  if (vp.IsSection ()) G4cout << "on";
1150  else G4cout << "off";
1151  G4cout << ".\nSection plane is now: "
1152  << vp.GetSectionPlane ();
1153  G4cout << G4endl;
1154  }
1155  }
1156 
1157  else if (command == fpCommandRotationStyle) {
1159  if (newValue == "constrainUpDirection")
1161  else if (newValue == "freeRotation")
1163  else {
1164  if (verbosity >= G4VisManager::errors) {
1165  G4cerr << "ERROR: \"" << newValue << "\" not recognised." << G4endl;
1166  }
1167  return;
1168  }
1169  vp.SetRotationStyle(style);
1170  if (verbosity >= G4VisManager::confirmations) {
1171  G4cout << "Rotation style of viewer \"" << currentViewer->GetName()
1172  << "\" set to " << vp.GetRotationStyle()
1173  << G4endl;
1174  }
1175  }
1176 
1177  else if (command == fpCommandStyle) {
1178  G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
1179  const size_t iPos0 = 0;
1180  if (newValue[iPos0] == 'w') { // "wireframe"
1181  switch (existingStyle) {
1183  break;
1184  case G4ViewParameters::hlr:
1185  break;
1186  case G4ViewParameters::hsr:
1188  break;
1191  break;
1192  }
1193  }
1194  else if (newValue[iPos0] == 's') { // "surface"
1195  switch (existingStyle) {
1198  break;
1199  case G4ViewParameters::hlr:
1201  break;
1202  case G4ViewParameters::hsr:
1203  break;
1205  break;
1206  }
1207  }
1208  else {
1209  if (verbosity >= G4VisManager::errors) {
1210  G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1211  " Looking for 'w' or 's' first character." << G4endl;
1212  }
1213  return;
1214  }
1215  if (verbosity >= G4VisManager::confirmations) {
1216  G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
1217  << "\" set to " << vp.GetDrawingStyle()
1218  << G4endl;
1219  }
1220  }
1221 
1222  else if (command == fpCommandTargetPoint) {
1223  G4ThreeVector targetPoint =
1224  fpCommandTargetPoint->GetNew3VectorValue(newValue);
1225  const G4Point3D& standardTargetPoint =
1226  currentViewer->GetSceneHandler()->GetScene()->GetStandardTargetPoint();
1227  vp.SetCurrentTargetPoint(targetPoint - standardTargetPoint);
1228  if (verbosity >= G4VisManager::confirmations) {
1229  G4cout << "Target point set to "
1230  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1231  (targetPoint)
1232  << "\n\"Current Target Point\" set to "
1233  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1234  (vp.GetCurrentTargetPoint())
1235  << "\n\"Standard Target Point\" is "
1236  << fpCommandTargetPoint->ConvertToStringWithBestUnit
1237  (standardTargetPoint)
1238  << G4endl;
1239  }
1240  }
1241 
1242  else if (command == fpCommandUpThetaPhi) {
1243  G4double theta, phi;
1244  if (ConvertToDoublePair(newValue, theta, phi)) {
1245  G4double x = std::sin (theta) * std::cos (phi);
1246  G4double y = std::sin (theta) * std::sin (phi);
1247  G4double z = std::cos (theta);
1248  fUpVector = G4ThreeVector (x, y, z);
1249  vp.SetUpVector(fUpVector);
1250  if (verbosity >= G4VisManager::confirmations) {
1251  G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1252  }
1253  }
1254  }
1255 
1256  else if (command == fpCommandUpVector) {
1257  fUpVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
1258  vp.SetUpVector(fUpVector);
1259  if (verbosity >= G4VisManager::confirmations) {
1260  G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1261  }
1262  }
1263 
1264  else if (command == fpCommandViewpointThetaPhi) {
1265  G4double theta, phi;
1266  if (ConvertToDoublePair(newValue, theta, phi)) {
1267  G4double x = std::sin (theta) * std::cos (phi);
1268  G4double y = std::sin (theta) * std::sin (phi);
1269  G4double z = std::cos (theta);
1270  fViewpointVector = G4ThreeVector (x, y, z);
1271  vp.SetViewAndLights(fViewpointVector);
1272  if (verbosity >= G4VisManager::confirmations) {
1273  G4cout << "Viewpoint direction set to "
1274  << vp.GetViewpointDirection() << G4endl;
1275  if (vp.GetLightsMoveWithCamera ()) {
1276  G4cout << "Lightpoint direction set to "
1278  }
1279  }
1280  }
1281  }
1282 
1283  else if (command == fpCommandViewpointVector) {
1284  G4ThreeVector viewpointVector = G4UIcommand::ConvertTo3Vector(newValue);
1285  if (viewpointVector.mag2() <= 0.) {
1286  if (verbosity >= G4VisManager::errors) {
1287  G4cerr << "ERROR: Null viewpoint vector. No action taken." << G4endl;
1288  }
1289  } else {
1290  fViewpointVector = viewpointVector.unit();
1291  vp.SetViewAndLights(fViewpointVector);
1292  if (verbosity >= G4VisManager::confirmations) {
1293  G4cout << "Viewpoint direction set to "
1294  << vp.GetViewpointDirection() << G4endl;
1295  if (vp.GetLightsMoveWithCamera ()) {
1296  G4cout << "Lightpoint direction set to "
1298  }
1299  }
1300  }
1301  }
1302 
1303  else if (command == fpCommandTimeWindowDisplayHeadTime)
1304  {
1305  G4String display;
1306  G4double screenX, screenY, screenSize, red, green, blue;
1307  std::istringstream iss(newValue);
1308  iss >> display >> screenX >> screenY
1309  >> screenSize >> red >> green >> blue;
1310  vp.SetDisplayHeadTime(command->ConvertToBool(display));
1311  vp.SetDisplayHeadTimeX(screenX);
1312  vp.SetDisplayHeadTimeY(screenY);
1313  vp.SetDisplayHeadTimeSize(screenSize);
1314  vp.SetDisplayHeadTimeRed(red);
1315  vp.SetDisplayHeadTimeGreen(green);
1316  vp.SetDisplayHeadTimeBlue(blue);
1317  if (verbosity >= G4VisManager::confirmations) {
1318  G4cout << "Display head time flag set: "
1319  << vp
1320  << G4endl;
1321  }
1322  }
1323 
1324  else if (command == fpCommandTimeWindowDisplayLightFront)
1325  {
1326  G4String display, originX, originY, originZ, unitS, originT, unitT;
1327  G4double red, green, blue;
1328  std::istringstream iss(newValue);
1329  iss >> display
1330  >> originX >> originY >> originZ >> unitS
1331  >> originT >> unitT
1332  >> red >> green >> blue;
1333  vp.SetDisplayLightFront(command->ConvertToBool(display));
1335  (command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)));
1337  (command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)));
1339  (command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)));
1341  (command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)));
1342  vp.SetDisplayLightFrontRed(red);
1343  vp.SetDisplayLightFrontGreen(green);
1344  vp.SetDisplayLightFrontBlue(blue);
1345  if (verbosity >= G4VisManager::confirmations) {
1346  G4cout << "Display light front flag set: "
1347  << vp
1348  << G4endl;
1349  }
1350  }
1351 
1352  else if (command == fpCommandTimeWindowEndTime)
1353  {
1354  G4String end_time_string, end_time_unit,
1355  time_range_string, time_range_unit;
1356  std::istringstream iss(newValue);
1357  iss >> end_time_string >> end_time_unit
1358  >> time_range_string >> time_range_unit;
1359  vp.SetEndTime
1360  (command->ConvertToDimensionedDouble
1361  (G4String(end_time_string + ' ' + end_time_unit)));
1362  G4double timeRange = command->ConvertToDimensionedDouble
1363  (G4String(time_range_string + ' ' + time_range_unit));
1364  if (timeRange > 0.) {
1365  vp.SetStartTime
1366  (vp.GetEndTime() - timeRange);
1367  }
1368  if (verbosity >= G4VisManager::confirmations) {
1369  G4cout
1370  << "Time window start time: " << vp.GetStartTime()/ns << " ns"
1371  << ", time window end time: " << vp.GetEndTime()/ns << " ns";
1372  if (timeRange > 0.) {
1373  G4cout << "\n (time range: " << timeRange/ns << " ns)";
1374  }
1375  G4cout << G4endl;
1376  }
1377  }
1378 
1379  else if (command == fpCommandTimeWindowFadeFactor) {
1380  vp.SetFadeFactor(command->ConvertToDouble(newValue));
1381  if (verbosity >= G4VisManager::confirmations) {
1382  G4cout << "Time window fade factor changed to " << vp.GetFadeFactor()
1383  << G4endl;
1384  }
1385  }
1386 
1387  else if (command == fpCommandTimeWindowStartTime)
1388  {
1389  G4String start_time_string, start_time_unit,
1390  time_range_string, time_range_unit;
1391  std::istringstream iss(newValue);
1392  iss >> start_time_string >> start_time_unit
1393  >> time_range_string >> time_range_unit;
1394  vp.SetStartTime
1395  (command->ConvertToDimensionedDouble
1396  (G4String(start_time_string + ' ' + start_time_unit)));
1397  G4double timeRange = command->ConvertToDimensionedDouble
1398  (G4String(time_range_string + ' ' + time_range_unit));
1399  if (timeRange > 0.) {
1400  vp.SetEndTime
1401  (vp.GetStartTime() + timeRange);
1402  }
1403  if (verbosity >= G4VisManager::confirmations) {
1404  G4cout
1405  << "Time window start time: " << vp.GetStartTime()/ns << " ns"
1406  << ", time window end time: " << vp.GetEndTime()/ns << " ns";
1407  if (timeRange > 0.) {
1408  G4cout << "\n (time range: " << timeRange/ns << " ns)";
1409  }
1410  G4cout << G4endl;
1411  }
1412  }
1413 
1414  else {
1415  if (verbosity >= G4VisManager::errors) {
1416  G4cerr <<
1417  "ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command."
1418  << G4endl;
1419  }
1420  return;
1421  }
1422 
1423  SetViewParameters(currentViewer,vp);
1424 }
G4UIcmdWithAnInteger * fpCommandLineSegments
Float_t x
Definition: compare.C:6
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:311
void SetVisibleDensity(G4double visibleDensity)
G4bool IsMarkerNotHidden() const
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
G4double GetExplodeFactor() const
void SetDisplayHeadTime(G4bool)
G4UIcmdWithADouble * fpCommandGlobalLineWidthScale
G4UIcommand * fpCommandDefaultTextColour
void SetSectionPlane(const G4Plane3D &sectionPlane)
CLHEP::Hep3Vector G4ThreeVector
void SetCullingCovered(G4bool)
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:457
G4UIcmdWithADouble * fpCommandGlobalMarkerScale
G4UIcmdWithAString * fpCommandAll
G4Vector3D & GetActualLightpointDirection()
void SetPicking(G4bool)
void SetDisplayLightFront(G4bool)
const G4ViewParameters & GetDefaultViewParameters() const
Definition: test07.cc:36
void SetFieldHalfAngle(G4double fieldHalfAngle)
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
static constexpr G4double fVeryLongTime
G4bool IsDensityCulling() const
G4double GetEndTime() const
const G4Point3D & GetCurrentTargetPoint() const
void SetDisplayHeadTimeRed(G4double)
const G4Plane3D & GetSectionPlane() const
void SetDefaultValue(G4bool defVal)
G4int compareTo(const char *, caseCompare mode=exact) const
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
Float_t y
Definition: compare.C:6
G4UIcommand * fpCommandTimeWindowDisplayLightFront
Double_t z
G4UIcmdWithABool * fpCommandHiddenEdge
void SetLightsMoveWithCamera(G4bool moves)
G4double GetStartTime() const
void SetGlobalMarkerScale(G4double globalMarkerScale)
const G4Vector3D & GetUpVector() const
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:439
G4double GetFadeFactor() const
G4bool IsAuxEdgeVisible() const
void SetViewParameters(const G4ViewParameters &vp)
Definition: G4VViewer.cc:120
G4UIcmdWithAString * fpCommandStyle
RotationStyle GetRotationStyle() const
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
G4UIdirectory * fpTimeWindowDirectory
void UnsetSectionPlane()
const G4ViewParameters & GetViewParameters() const
void SetDefaultValue(const char *defVal)
G4UIcmdWith3VectorAndUnit * fpCommandTargetPoint
const G4Point3D & GetExplodeCentre() const
void SetEndTime(G4double)
Definition: test07.cc:36
void SetGuidance(const char *theGuidance)
void SetCullingInvisible(G4bool)
void SetDisplayHeadTimeBlue(G4double)
G4UIcmdWithABool * fpCommandEdge
void SetUnitCategory(const char *unitCategory)
G4String GetCurrentValue(G4UIcommand *command)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetParameterRange(const char *theRange)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:449
G4bool IsPicking() const
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetStartTime(G4double)
void SetDisplayLightFrontRed(G4double)
const G4Vector3D & GetLightpointDirection() const
const G4Vector3D & GetViewpointDirection() const
void SetDefaultValue(const char *theDefaultValue)
G4UIcmdWithABool * fpCommandHiddenMarker
G4bool GetLightsMoveWithCamera() const
G4VSceneHandler * GetSceneHandler() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
void SetBackgroundColour(const G4Colour &)
G4UIcommand * fpCommandTimeWindowEndTime
void SetCulling(G4bool)
CutawayMode GetCutawayMode() const
void SetUpVector(const G4Vector3D &upVector)
void SetAuxEdgeVisible(G4bool)
void SetDefaultVisAttributes(const G4VisAttributes &)
static constexpr double deg
Definition: G4SIunits.hh:152
void SetDisplayLightFrontBlue(G4double)
void SetDisplayHeadTimeSize(G4double)
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:35
G4UIcmdWithABool * fpCommandAuxEdge
void SetRotationStyle(RotationStyle)
G4int SetNoOfSides(G4int nSides)
void SetMarkerHidden()
void SetExplodeFactor(G4double explodeFactor)
const G4VisAttributes * GetDefaultVisAttributes() const
double mag2() const
HepGeom::Plane3D< G4double > G4Plane3D
Definition: G4Plane3D.hh:37
const G4String & GetName() const
void SetCandidates(const char *candidateList)
void SetDisplayLightFrontX(G4double)
G4UIcommand * fpCommandTimeWindowStartTime
const G4String & ConvertToColourGuidance()
G4double GetGlobalLineWidthScale() const
static G4ThreeVector ConvertTo3Vector(const char *st)
Definition: G4UIcommand.cc:477
G4GLOB_DLL std::ostream G4cerr
void SetDisplayHeadTimeY(G4double)
void SetNewValue(G4UIcommand *command, G4String newValue)
Hep3Vector unit() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4bool IsAutoRefresh() const
void SetCurrentTargetPoint(const G4Point3D &currentTargetPoint)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
void SetFadeFactor(G4double)
DrawingStyle GetDrawingStyle() const
void SetDisplayLightFrontY(G4double)
int G4int
Definition: G4Types.hh:78
G4UIcmdWithADouble * fpCommandTimeWindowFadeFactor
G4UIcmdWithABool * fpCommandAutoRefresh
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDisplayHeadTimeGreen(G4double)
G4UIcmdWithABool * fpCommandPicking
G4UIcmdWithAString * fpCommandLightsMove
void SetDefaultValue(G4double defVal)
void SetMarkerNotHidden()
const G4Colour & GetBackgroundColour() const
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultTextVisAttributes(const G4VisAttributes &)
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4GLOB_DLL std::ostream G4cout
void SetDensityCulling(G4bool)
const G4VisAttributes * GetDefaultTextVisAttributes() const
void SetColour(const G4Colour &)
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
G4double GetGlobalMarkerScale() const
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetCutawayMode(CutawayMode)
G4UIcmdWithAString * fpCommandCutawayMode
G4UIcommand * fpCommandViewpointThetaPhi
const G4Point3D & GetStandardTargetPoint() const
static G4double ConvertToDimensionedDouble(const char *st)
Definition: G4UIcommand.cc:465
void SetViewAndLights(const G4Vector3D &viewpointDirection)
G4UIcmdWithAString * fpCommandRotationStyle
void SetDisplayHeadTimeX(G4double)
G4double GetVisibleDensity() const
void SetDisplayLightFrontGreen(G4double)
G4UIcommand * fpCommandTimeWindowDisplayHeadTime
void SetParameterCandidates(const char *theString)
void SetDisplayLightFrontZ(G4double)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
void SetExplodeCentre(const G4Point3D &explodeCentre)
void SetAutoRefresh(G4bool)
#define ns
Definition: xmlparse.cc:614
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
void SetDisplayLightFrontT(G4double)
G4Scene * GetScene() const
void SetGlobalLineWidthScale(G4double globalLineWidthScale)
const G4Colour & GetColour() const
G4bool IsSection() const