Geant4-11
G4VisCommandsViewerSet.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27
28// /vis/viewer/set commands - John Allison 16th May 2000
29
31
32#include "G4UIcommand.hh"
33#include "G4UIcmdWithAString.hh"
34#include "G4UIcmdWithABool.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
47fLightsVector (G4ThreeVector(1.,1.,1.)),
48fUpVector (G4ThreeVector(0.,1.,0.)),
49fViewpointVector (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");
312 parameter = new G4UIparameter("field-half-angle",'d',omitable = true);
313 parameter->SetDefaultValue(30.);
314 //parameter->SetCurrentAsDefault(true);
316 parameter = new G4UIparameter("unit",'s',omitable = true);
317 parameter->SetDefaultValue("deg");
318 //parameter->SetCurrentAsDefault(true);
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
372 ("/vis/viewer/set/specialMeshRendering",this);
373 fpCommandSpecialMeshRendering -> SetGuidance
374 ("Request special rendering of volumes (meshes) that use G4VNestedParameterisation.");
375 fpCommandSpecialMeshRendering->SetParameterName("render",omitable = true);
377
379 ("/vis/viewer/set/specialMeshVolumes",this);
380 fpCommandSpecialMeshVolumes -> SetGuidance
381 ("Specify the volumes for special rendering. No arguments resets the list"
382 "\nand is interpreted to mean \"all found meshes\".");
384 ("Please provide a list of space-separated physical volume names and copy"
385 "\nnumber pairs. Negative copy number means \"all volumes of that name\".");
386 parameter = new G4UIparameter("volumes",'s',omitable = true);
387 parameter->SetGuidance
388 ("List of physical volume names and copy number pairs");
390
391 fpCommandStyle = new G4UIcmdWithAString ("/vis/viewer/set/style",this);
393 ("Set style of drawing - w[ireframe] or s[urface] or c[loud].");
395 ("(Hidden line drawing is controlled by \"/vis/viewer/set/hiddenEdge\".)");
396 fpCommandStyle->SetParameterName ("style",omitable = false);
397 fpCommandStyle->SetCandidates("w wireframe s surface c cloud");
398
400 ("/vis/viewer/set/targetPoint", this);
402 ("Set target point.");
404 ("This sets the \"Current Target Point\" relative to the \"Standard");
406 ("Target Point\" so that the actual target point is as requested.");
408 ("(See G4ViewParameters.hh for an explanation of target points.)");
409 fpCommandTargetPoint->SetParameterName("x", "y", "z", omitable = false);
411
413 ("/vis/viewer/set/upThetaPhi", this);
414 fpCommandUpThetaPhi -> SetGuidance ("Set up vector.");
415 fpCommandUpThetaPhi -> SetGuidance
416 ("Viewer will attempt always to show this direction upwards.");
417 parameter = new G4UIparameter("theta", 'd', omitable = true);
418 parameter -> SetDefaultValue (90.);
419 fpCommandUpThetaPhi -> SetParameter (parameter);
420 parameter = new G4UIparameter("phi", 'd', omitable = true);
421 parameter -> SetDefaultValue (90.);
422 fpCommandUpThetaPhi -> SetParameter (parameter);
423 parameter = new G4UIparameter ("unit", 's', omitable = true);
424 parameter -> SetDefaultValue ("deg");
425 fpCommandUpThetaPhi -> SetParameter (parameter);
426
428 ("/vis/viewer/set/upVector", this);
429 fpCommandUpVector -> SetGuidance ("Set up vector.");
430 fpCommandUpVector -> SetGuidance
431 ("Viewer will attempt always to show this direction upwards.");
432 parameter = new G4UIparameter("x", 'd', omitable = true);
433 parameter -> SetDefaultValue (0.);
434 fpCommandUpVector -> SetParameter (parameter);
435 parameter = new G4UIparameter("y", 'd', omitable = true);
436 parameter -> SetDefaultValue (1.);
437 fpCommandUpVector -> SetParameter (parameter);
438 parameter = new G4UIparameter ("z", 'd', omitable = true);
439 parameter -> SetDefaultValue (0.);
440 fpCommandUpVector -> SetParameter (parameter);
441
443 ("/vis/viewer/set/viewpointThetaPhi", this);
444 fpCommandViewpointThetaPhi -> SetGuidance
445 ("Set direction from target to camera.");
446 fpCommandViewpointThetaPhi -> SetGuidance
447 ("Also changes lightpoint direction if lights are set to move with camera.");
448 parameter = new G4UIparameter("theta", 'd', omitable = true);
449 parameter -> SetDefaultValue (60.);
450 fpCommandViewpointThetaPhi -> SetParameter (parameter);
451 parameter = new G4UIparameter("phi", 'd', omitable = true);
452 parameter -> SetDefaultValue (45.);
453 fpCommandViewpointThetaPhi -> SetParameter (parameter);
454 parameter = new G4UIparameter ("unit", 's', omitable = true);
455 parameter -> SetDefaultValue ("deg");
456 fpCommandViewpointThetaPhi -> SetParameter (parameter);
457
459 ("/vis/viewer/set/viewpointVector", this);
460 fpCommandViewpointVector -> SetGuidance
461 ("Set direction from target to camera.");
462 fpCommandViewpointVector -> SetGuidance
463 ("Also changes lightpoint direction if lights are set to move with camera.");
464 parameter = new G4UIparameter("x", 'd', omitable = true);
465 parameter -> SetDefaultValue (1.);
466 fpCommandViewpointVector -> SetParameter (parameter);
467 parameter = new G4UIparameter("y", 'd', omitable = true);
468 parameter -> SetDefaultValue (1.);
469 fpCommandViewpointVector -> SetParameter (parameter);
470 parameter = new G4UIparameter ("z", 'd', omitable = true);
471 parameter -> SetDefaultValue (1.);
472 fpCommandViewpointVector -> SetParameter (parameter);
473
474 fpTimeWindowDirectory = new G4UIdirectory ("/vis/viewer/set/timeWindow/");
475 fpTimeWindowDirectory -> SetGuidance ("Set time window parameters of current viewer.");
476 G4String timeWindowGuidance =
477 "For these commands use"
478 "\n /vis/scene/add/trajectories rich"
479 "\n /vis/modeling/trajectories/drawByCharge-0/default/setTimeSliceInterval 0.01 ns"
480 "\nthen typically"
481 "\n /vis/viewer/set/timeWindow/displayLightFront true 0 0 -50 cm -0.5 ns"
482 "\n /vis/viewer/set/timeWindow/displayHeadTime true"
483 "\n /vis/viewer/set/timeWindow/fadeFactor 1"
484 "\n /run/beamOn # or several until you get a good event or events"
485 "\n /vis/viewer/set/timeWindow/startTime 0 ns 1 ns"
486 "\n /vis/viewer/save"
487 "\n /vis/viewer/set/timeWindow/startTime 1 ns 1 ns"
488 "\nthen zoom, pan etc to a view of interest and"
489 "\n /vis/viewer/save"
490 "\nthen repeat with next start time, another view and a save, then try"
491 "\n /vis/viewer/interpolate";
492
494 new G4UIcommand("/vis/viewer/set/timeWindow/displayHeadTime", this);
496 ("Display head time of range in 2D text.");
498 parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false);
499 parameter->SetDefaultValue(false);
501 parameter = new G4UIparameter ("screenX", 'd', omitable = true);
502 parameter->SetGuidance("-1 < screenX < 1");
503 parameter->SetParameterRange("screenX >= -1. && screenX <= 1.");
504 parameter->SetDefaultValue(-0.9);
506 parameter = new G4UIparameter ("screenY", 'd', omitable = true);
507 parameter->SetGuidance("-1 < screenY < 1");
508 parameter->SetParameterRange("screenY >= -1. && screenY <= 1.");
509 parameter->SetDefaultValue(-0.9);
511 parameter = new G4UIparameter ("screenSize", 'd', omitable = true);
512 parameter->SetDefaultValue(24.);
514 parameter = new G4UIparameter ("red", 'd', omitable = true);
515 parameter->SetParameterRange("red >= 0. && red <= 1.");
516 parameter->SetDefaultValue(0.);
518 parameter = new G4UIparameter ("green", 'd', omitable = true);
519 parameter->SetParameterRange("green >= 0. && green <= 1.");
520 parameter->SetDefaultValue(1.);
522 parameter = new G4UIparameter ("blue", 'd', omitable = true);
523 parameter->SetParameterRange("blue >= 0. && blue <= 1.");
524 parameter->SetDefaultValue(1.);
526
528 new G4UIcommand("/vis/viewer/set/timeWindow/displayLightFront", this);
530 ("Display the light front at head time.");
532 ("Tip: The trajectories can appear of jump ahead of the light front"
533 "\nbecause their time range overlaps the viewer's time range. To"
534 "\naverage out this discrete time effect, advance the light front by"
535 "\nhalf the trajectories interval. E.g., if the trajectory time slice"
536 "\ninterval is 0.01 ns:"
537 "\n /vis/viewer/set/timeWindow/displayLightFront true -90 0 0 mm -0.005 ns"
538 "\nTo prevent them beating the light front at all:"
539 "\n /vis/viewer/set/timeWindow/displayLightFront true -90 0 0 mm -0.01 ns");
541 parameter = new G4UIparameter ("displayLightFront", 'b', omitable = true);
542 parameter->SetDefaultValue(true);
544 parameter = new G4UIparameter ("originX", 'd', omitable = true);
545 parameter->SetDefaultValue(0.);
547 parameter = new G4UIparameter ("originY", 'd', omitable = true);
548 parameter->SetDefaultValue(0.);
550 parameter = new G4UIparameter ("originZ", 'd', omitable = true);
551 parameter->SetDefaultValue(0.);
553 parameter = new G4UIparameter ("space_unit", 's', omitable = true);
554 parameter->SetDefaultValue("m");
556 parameter = new G4UIparameter ("originT", 'd', omitable = true);
557 parameter->SetDefaultValue(0.);
559 parameter = new G4UIparameter ("time_unit", 's', omitable = true);
560 parameter->SetDefaultValue("s");
562 parameter = new G4UIparameter ("red", 'd', omitable = true);
563 parameter->SetParameterRange("red >= 0. && red <= 1.");
564 parameter->SetDefaultValue(0.);
566 parameter = new G4UIparameter ("green", 'd', omitable = true);
567 parameter->SetParameterRange("green >= 0. && green <= 1.");
568 parameter->SetDefaultValue(1.);
570 parameter = new G4UIparameter ("blue", 'd', omitable = true);
571 parameter->SetParameterRange("blue >= 0. && blue <= 1.");
572 parameter->SetDefaultValue(0.);
574
576 new G4UIcommand("/vis/viewer/set/timeWindow/endTime", this);
577 fpCommandTimeWindowEndTime->SetGuidance("Set end and range of track time.");
578 fpCommandTimeWindowEndTime->SetGuidance(timeWindowGuidance);
579 parameter = new G4UIparameter ("end-time", 'd', omitable = false);
582 parameter = new G4UIparameter ("end-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
593 new G4UIcmdWithADouble("/vis/viewer/set/timeWindow/fadeFactor", this);
595 ("0: no fade; 1: maximum fade with time window.");
596 fpCommandTimeWindowFadeFactor->SetGuidance(timeWindowGuidance);
597 fpCommandTimeWindowFadeFactor->SetParameterName("fade_factor", omitable = false);
598 fpCommandTimeWindowFadeFactor->SetRange("fade_factor>=0.&&fade_factor<=1.");
600
602 new G4UIcommand("/vis/viewer/set/timeWindow/startTime", this);
603 fpCommandTimeWindowStartTime->SetGuidance("Set start and range of track time.");
604 fpCommandTimeWindowStartTime->SetGuidance(timeWindowGuidance);
605 parameter = new G4UIparameter ("start-time", 'd', omitable = false);
608 parameter = new G4UIparameter ("start-time-unit", 's', omitable = false);
609 parameter->SetDefaultValue("ns");
611 parameter = new G4UIparameter ("time-range", 'd', omitable = true);
612 parameter->SetDefaultValue(-1.);
614 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
615 parameter->SetDefaultValue("ns");
617}
618
628 delete fpCommandUpVector;
629 delete fpCommandUpThetaPhi;
631 delete fpCommandStyle;
636 delete fpCommandProjection;
637 delete fpCommandPicking;
642 delete fpCommandLightsMove;
644 delete fpCommandHiddenEdge;
648 delete fpCommandEdge;
652 delete fpCommandCulling;
653 delete fpCommandBackground;
654 delete fpCommandAuxEdge;
656 delete fpCommandAll;
657}
658
660 return "";
661}
662
664(G4UIcommand* command,G4String newValue) {
665
667
668 G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
669 if (!currentViewer) {
670 if (verbosity >= G4VisManager::errors) {
671 G4cerr <<
672 "ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer."
673 << G4endl;
674 }
675 return;
676 }
677
678 G4ViewParameters vp = currentViewer->GetViewParameters();
679
680 if (command == fpCommandAll) {
681 G4VViewer* fromViewer = fpVisManager->GetViewer(newValue);
682 if (!fromViewer) {
683 if (verbosity >= G4VisManager::errors) {
684 G4cerr <<
685 "ERROR: G4VisCommandsViewerSet::SetNewValue: all:"
686 "\n unrecognised from-viewer."
687 << G4endl;
688 }
689 return;
690 }
691 if (fromViewer == currentViewer) {
692 if (verbosity >= G4VisManager::warnings) {
693 G4cout <<
694 "WARNING: G4VisCommandsViewerSet::SetNewValue: all:"
695 "\n from-viewer and current viewer are identical."
696 << G4endl;
697 }
698 return;
699 }
700 // Copy view parameters except for autoRefresh and background...
701 CopyMostViewParameters(vp, fromViewer->GetViewParameters());
702 // Concatenate any private vis attributes modifiers...
703 const std::vector<G4ModelingParameters::VisAttributesModifier>*
704 privateVAMs = fromViewer->GetPrivateVisAttributesModifiers();
705 if (privateVAMs) {
706 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
707 for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
709 }
710 }
711 if (verbosity >= G4VisManager::confirmations) {
712 G4cout << "View parameters of viewer \"" << currentViewer->GetName()
713 << "\"\n set to those of viewer \"" << fromViewer->GetName()
714 << "\"."
715 << G4endl;
716 }
717 if (verbosity >= G4VisManager::warnings) {
718 G4cout << "You may need \"/vis/viewer/rebuild\"."
719 << G4endl;
720 }
721 }
722
723 else if (command == fpCommandAutoRefresh) {
724 G4bool autoRefresh = G4UIcommand::ConvertToBool(newValue);
725 const G4ViewParameters& defaultVP =
726 currentViewer->GetDefaultViewParameters();
727 if (autoRefresh && !defaultVP.IsAutoRefresh()) {
728 if (verbosity >= G4VisManager::warnings) {
729 G4cout
730 << "WARNING: "
731 << currentViewer->GetName() << " is NOT auto-refesh by default"
732 << "\n so cannot be set to auto-refresh."
733 << G4endl;
734 }
735 return;
736 }
737 vp.SetAutoRefresh(autoRefresh);
738 if (verbosity >= G4VisManager::confirmations) {
739 G4cout << "Views will ";
740 if (!vp.IsAutoRefresh()) G4cout << "not ";
741 G4cout << "be automatically refreshed after a change of view parameters."
742 << G4endl;
743 }
744 if (!vp.IsAutoRefresh()) {
745 currentViewer->SetViewParameters(vp);
746 return; // Avoid a refresh if auto-refresh has been set to off...
747 } // ...otherwise take normal action.
748 }
749
750 else if (command == fpCommandAuxEdge) {
752 if (verbosity >= G4VisManager::confirmations) {
753 G4cout << "Auxiliary edges will ";
754 if (!vp.IsAuxEdgeVisible()) G4cout << "not ";
755 G4cout << "be visible." << G4endl;
756 }
757 }
758
759 else if (command == fpCommandBackground) {
760 G4String redOrString;
761 G4double green, blue, opacity;
762 std::istringstream iss(newValue);
763 iss >> redOrString >> green >> blue >> opacity;
764 G4Colour colour(0.,0.,0.); // Default black and opaque.
765 ConvertToColour(colour, redOrString, green, blue, opacity);
766 vp.SetBackgroundColour(colour);
767 if (verbosity >= G4VisManager::confirmations) {
768 G4cout << "Background colour "
769 << vp.GetBackgroundColour()
770 << " requested."
771 << G4endl;
772 }
773 }
774
775 else if (command == fpCommandCulling) {
776 G4String cullingOption, stringFlag, unit;
777 G4double density;
778 std::istringstream is (newValue);
779 is >> cullingOption >> stringFlag >> density >> unit;
780 G4bool boolFlag = G4UIcommand::ConvertToBool(stringFlag);
781 if (cullingOption == "global") {
782 vp.SetCulling(boolFlag);
783 if (verbosity >= G4VisManager::confirmations) {
784 G4cout <<
785 "G4VisCommandsViewerSet::SetNewValue: culling: global culling flag"
786 " set to " << G4UIcommand::ConvertToString(boolFlag) <<
787 ".\n Does not change specific culling flags."
788 << G4endl;
789 }
790 }
791 else if (cullingOption == "coveredDaughters") {
792 vp.SetCullingCovered(boolFlag);
793 if (verbosity >= G4VisManager::confirmations) {
794 G4cout <<
795 "G4VisCommandsViewerSet::SetNewValue: culling: culling covered"
796 "\n daughters flag set to "
797 << G4UIcommand::ConvertToString(boolFlag) <<
798 ". Daughters covered by opaque mothers"
799 "\n will be culled, i.e., not drawn, if this flag is true."
800 "\n Note: this is only effective in surface drawing style,"
801 "\n and then only if the volumes are visible and opaque, and then"
802 "\n only if no sections or cutaways are in operation."
803 << G4endl;
804 }
805 }
806 else if (cullingOption == "invisible") {
807 vp.SetCullingInvisible(boolFlag);
808 if (verbosity >= G4VisManager::confirmations) {
809 G4cout <<
810 "G4VisCommandsViewerSet::SetNewValue: culling: culling invisible"
811 "\n flag set to "
812 << boolFlag << G4UIcommand::ConvertToString(boolFlag) <<
813 ". Volumes marked invisible will be culled,"
814 "\n i.e., not drawn, if this flag is true."
815 << G4endl;
816 }
817 }
818 else if (cullingOption == "density") {
819 const G4String where =
820 "G4VisCommandsViewerSet::SetNewValue: culling: culling by density";
821 if (boolFlag) {
822 G4double valueOfUnit;
823 // "Volumic Mass" is Michel's phrase for "Density"
824 if (ProvideValueOfUnit(where,unit,"Volumic Mass",valueOfUnit)) {
825 // Successful outcome of unit search
826 vp.SetDensityCulling(boolFlag);
827 density *= valueOfUnit;
828 vp.SetVisibleDensity(density);
829 } else {
830 // Unsuccessful outcome of unit search. Flag and density unchanged.
831 density = vp.GetVisibleDensity();
832 }
833 } else { // Reset flag but density unchanged.
834 vp.SetDensityCulling(boolFlag);
835 }
836 if (verbosity >= G4VisManager::confirmations) {
837 G4cout
838 << where
839 << "\n flag set to "
840 << std::boolalpha << vp.IsDensityCulling()
841 << ". Volumes with density less than "
842 << G4BestUnit(density,"Volumic Mass")
843 << "\n will be culled, i.e., not drawn, if this flag is true."
844 << G4endl;
845 }
846 }
847 else {
848 if (verbosity >= G4VisManager::errors) {
849 G4cerr <<
850 "ERROR: G4VisCommandsViewerSet::SetNewValue: culling:"
851 "\n option not recognised."
852 << G4endl;
853 }
854 }
855 }
856
857 else if (command == fpCommandCutawayMode) {
858 if (newValue == "add" || newValue == "union")
860 if (newValue == "multiply" || newValue == "intersection")
862
863 if (verbosity >= G4VisManager::confirmations) {
864 G4cout << "Cutaway mode set to ";
866 G4cout << "cutawayUnion";
868 G4cout << "cutawayIntersection";
869 G4cout << G4endl;
870 }
871 }
872
873 else if (command == fpCommandDefaultColour) {
874 G4String redOrString;
875 G4double green, blue, opacity;
876 std::istringstream iss(newValue);
877 iss >> redOrString >> green >> blue >> opacity;
878 G4Colour colour(1.,1.,1.); // Default white and opaque.
879 ConvertToColour(colour, redOrString, green, blue, opacity);
881 va.SetColour(colour);
883 if (verbosity >= G4VisManager::confirmations) {
884 G4cout << "Default colour "
886 << " requested."
887 << G4endl;
888 }
889 }
890
891 else if (command == fpCommandDefaultTextColour) {
892 G4String redOrString;
893 G4double green, blue, opacity;
894 std::istringstream iss(newValue);
895 iss >> redOrString >> green >> blue >> opacity;
896 G4Colour colour(1.,1.,1.); // Default white and opaque.
897 ConvertToColour(colour, redOrString, green, blue, opacity);
899 va.SetColour(colour);
901 if (verbosity >= G4VisManager::confirmations) {
902 G4cout << "Default colour "
904 << " requested."
905 << G4endl;
906 }
907 }
908
909 else if (command == fpCommandEdge) {
911 if (G4UIcommand::ConvertToBool(newValue)) { // true
912 switch (existingStyle) {
914 break;
916 break;
919 break;
921 break;
923 break;
924 }
925 }
926 else { // false
927 switch (existingStyle) {
929 break;
931 break;
933 break;
936 break;
938 break;
939 }
940 }
941 if (verbosity >= G4VisManager::confirmations) {
942 G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
943 << "\" set to " << vp.GetDrawingStyle()
944 << G4endl;
945 }
946 }
947
948 else if (command == fpCommandExplodeFactor) {
949 G4double explodeFactor, x, y, z;
950 G4String unitString;
951 std::istringstream is (newValue);
952 is >> explodeFactor >> x >> y >> z >> unitString;
953 G4double unit = G4UIcommand::ValueOf(unitString);
954 vp.SetExplodeFactor(explodeFactor);
955 vp.SetExplodeCentre(G4Point3D(x * unit, y * unit, z * unit));
956 if (verbosity >= G4VisManager::confirmations) {
957 G4cout << "Explode factor changed to " << vp.GetExplodeFactor()
958 << " from centre " << vp.GetExplodeCentre()
959 << G4endl;
960 }
961 }
962
963 else if (command == fpCommandGlobalLineWidthScale) {
964 G4double globalLineWidthScale
966 vp.SetGlobalLineWidthScale(globalLineWidthScale);
967 if (verbosity >= G4VisManager::confirmations) {
968 G4cout << "Global Line Width Scale changed to "
970 }
971 }
972
973 else if (command == fpCommandGlobalMarkerScale) {
974 G4double globalMarkerScale
976 vp.SetGlobalMarkerScale(globalMarkerScale);
977 if (verbosity >= G4VisManager::confirmations) {
978 G4cout << "Global Marker Scale changed to "
979 << vp.GetGlobalMarkerScale() << G4endl;
980 }
981 }
982
983 else if (command == fpCommandHiddenEdge) {
985 if (G4UIcommand::ConvertToBool(newValue)) {
986 switch (existingStyle) {
989 break;
991 break;
994 break;
996 break;
998 break;
999 }
1000 }
1001 else {
1002 switch (existingStyle) {
1004 break;
1007 break;
1009 break;
1012 break;
1014 break;
1015 }
1016 }
1017 if (verbosity >= G4VisManager::confirmations) {
1018 G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
1019 << "\" set to " << vp.GetDrawingStyle()
1020 << G4endl;
1021 }
1022 }
1023
1024 else if (command == fpCommandHiddenMarker) {
1025 G4bool hidden = G4UIcommand::ConvertToBool(newValue);
1026 if (hidden) vp.SetMarkerHidden();
1027 else vp.SetMarkerNotHidden();
1028 if (verbosity >= G4VisManager::confirmations) {
1029 G4cout << "Markers will ";
1030 if (vp.IsMarkerNotHidden()) G4cout << "not ";
1031 G4cout << "be hidden under solid objects." << G4endl;
1032 }
1033 }
1034
1035 else if (command == fpCommandLightsMove) {
1036 if (newValue.find("cam") != G4String::npos)
1037 vp.SetLightsMoveWithCamera(true);
1038 else if(newValue.find("obj") != G4String::npos)
1039 vp.SetLightsMoveWithCamera(false);
1040 else {
1041 if (verbosity >= G4VisManager::errors) {
1042 G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1043 " Looking for \"cam\" or \"obj\" in string." << G4endl;
1044 }
1045 }
1046 if (verbosity >= G4VisManager::confirmations) {
1047 G4cout << "Lights move with ";
1048 if (vp.GetLightsMoveWithCamera())
1049 G4cout << "camera (object appears to rotate).";
1050 else G4cout << "object (the viewer appears to be moving).";
1051 G4cout << G4endl;
1052 }
1053 }
1054
1055 else if (command == fpCommandLightsThetaPhi) {
1056 G4double theta, phi;
1057 if (ConvertToDoublePair(newValue, theta, phi)) {
1058 G4double x = std::sin (theta) * std::cos (phi);
1059 G4double y = std::sin (theta) * std::sin (phi);
1060 G4double z = std::cos (theta);
1061 fLightsVector = G4ThreeVector (x, y, z);
1063 if (verbosity >= G4VisManager::confirmations) {
1064 G4cout << "Lights direction set to "
1065 << vp.GetLightpointDirection() << G4endl;
1066 }
1067 }
1068 }
1069
1070 else if (command == fpCommandLightsVector) {
1073 if (verbosity >= G4VisManager::confirmations) {
1074 G4cout << "Lights direction set to "
1075 << vp.GetLightpointDirection() << G4endl;
1076 }
1077 }
1078
1079 else if (command == fpCommandLineSegments) {
1080 G4int nSides = G4UIcommand::ConvertToInt(newValue);
1081 nSides = vp.SetNoOfSides(nSides);
1082 if (verbosity >= G4VisManager::confirmations) {
1083 G4cout <<
1084 "Number of line segments per circle in polygon approximation is "
1085 << nSides << G4endl;
1086 }
1087 }
1088
1089 else if (command == fpCommandNumberOfCloudPoints) {
1090 G4int nPoints = G4UIcommand::ConvertToInt(newValue);
1091 nPoints = vp.SetNumberOfCloudPoints(nPoints);
1092 if (verbosity >= G4VisManager::confirmations) {
1093 G4cout <<
1094 "Number of points to be used in cloud representation of volumes is "
1095 << nPoints << G4endl;
1096 }
1097 }
1098
1099 else if (command == fpCommandPicking) {
1101 if (verbosity >= G4VisManager::confirmations) {
1102 G4cout << "Picking ";
1103 if (vp.IsPicking()) G4cout << "requested.";
1104 else G4cout << "inhibited.";
1105 G4cout << G4endl;
1106 }
1107 if (verbosity >= G4VisManager::warnings) {
1108 G4cout << "You may need to issue \"/vis/viewer/update\"."
1109 << G4endl;
1110 }
1111 }
1112
1113 else if (command == fpCommandProjection) {
1114 G4double fieldHalfAngle;
1115 const size_t iPos0 = 0;
1116 if (newValue[iPos0] == 'o') { // "orthogonal"
1117 fieldHalfAngle = 0.;
1118 }
1119 else if (newValue[iPos0] == 'p') { // "perspective"
1120 G4String dummy;
1121 G4String unit;
1122 std::istringstream is (newValue);
1123 is >> dummy >> fieldHalfAngle >> unit;
1124 fieldHalfAngle *= G4UIcommand::ValueOf(unit);
1125 if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
1126 if (verbosity >= G4VisManager::errors) {
1127 G4cerr <<
1128 "ERROR: Field half angle should be 0 < angle <= 89.5 degrees.";
1129 G4cout << G4endl;
1130 }
1131 return;
1132 }
1133 }
1134 else {
1135 if (verbosity >= G4VisManager::errors) {
1136 G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1137 " Looking for 'o' or 'p' first character." << G4endl;
1138 }
1139 return;
1140 }
1141 vp.SetFieldHalfAngle(fieldHalfAngle);
1142 if (verbosity >= G4VisManager::confirmations) {
1143 G4cout << "Projection style of viewer \"" << currentViewer->GetName()
1144 << "\" set to ";
1145 if (fieldHalfAngle == 0.) {
1146 G4cout << "orthogonal.";
1147 }
1148 else {
1149 G4cout << "perspective\n with half angle " << fieldHalfAngle / deg
1150 << " degrees.";
1151 }
1152 G4cout << G4endl;
1153 }
1154 }
1155
1156 else if (command == fpCommandRotationStyle) {
1158 if (newValue == "constrainUpDirection")
1160 else if (newValue == "freeRotation")
1162 else {
1163 if (verbosity >= G4VisManager::errors) {
1164 G4cerr << "ERROR: \"" << newValue << "\" not recognised." << G4endl;
1165 }
1166 return;
1167 }
1168 vp.SetRotationStyle(style);
1169 if (verbosity >= G4VisManager::confirmations) {
1170 G4cout << "Rotation style of viewer \"" << currentViewer->GetName()
1171 << "\" set to " << vp.GetRotationStyle()
1172 << G4endl;
1173 }
1174 }
1175
1176 else if (command == fpCommandSectionPlane) {
1177 G4String choice, unit;
1178 G4double x, y, z, nx, ny, nz, F = 1.;
1179 std::istringstream is (newValue);
1180 is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
1181 G4int iSelector = -1;
1182 if (G4StrUtil::icompare(choice, "off") == 0 ||
1183 !G4UIcommand::ConvertToBool(choice)) iSelector = 0;
1184 if (G4StrUtil::icompare(choice, "on") == 0 ||
1185 G4UIcommand::ConvertToBool(choice)) iSelector = 1;
1186 if (iSelector < 0) {
1187 if (verbosity >= G4VisManager::errors) {
1188 G4cout << "Choice not recognised (on/true or off/false)." << G4endl;
1189 }
1190 goto write_result;
1191 }
1192 // iSelector can only be 0 or 1
1193 switch (iSelector) {
1194 case 0:
1195 vp.UnsetSectionPlane();
1196 break;
1197 case 1:
1198 F = G4UIcommand::ValueOf(unit);
1199 x *= F; y *= F; z *= F;
1200 if (nx == 0. && ny == 0. && nz == 0.) {
1201 if (verbosity >= G4VisManager::errors) {
1202 G4cout << "Null normal." << G4endl;
1203 }
1204 break;;
1205 }
1206 const G4Normal3D& normal = G4Normal3D(nx,ny,nz).unit();
1209 break;
1210 }
1211 write_result:
1212 if (verbosity >= G4VisManager::confirmations) {
1213 G4cout << "Section drawing is: ";
1214 if (vp.IsSection ()) G4cout << "on";
1215 else G4cout << "off";
1216 G4cout << ".\nSection plane is now: "
1217 << vp.GetSectionPlane ();
1218 G4cout << G4endl;
1219 }
1220 }
1221
1222 else if (command == fpCommandSpecialMeshRendering) {
1224 if (verbosity >= G4VisManager::confirmations) {
1225 G4cout << "Special mesh rendering ";
1226 if (vp.IsSpecialMeshRendering()) G4cout << "requested.";
1227 else G4cout << "inhibited.";
1228 G4cout << G4endl;
1229 }
1230 }
1231
1232 else if (command == fpCommandSpecialMeshVolumes) {
1233 std::vector<G4ModelingParameters::PVNameCopyNo> requestedMeshes;
1234 if (newValue.empty()) {
1235 vp.SetSpecialMeshVolumes(requestedMeshes); // Empty list
1236 } else {
1237 // Algorithm from Josuttis p.476.
1238 G4String::size_type iBegin, iEnd;
1239 iBegin = newValue.find_first_not_of(' ');
1240 while (iBegin != G4String::npos) {
1241 iEnd = newValue.find_first_of(' ',iBegin);
1242 if (iEnd == G4String::npos) {
1243 iEnd = newValue.length();
1244 }
1245 G4String name(newValue.substr(iBegin,iEnd-iBegin));
1246 iBegin = newValue.find_first_not_of(' ',iEnd);
1247 if (iBegin == G4String::npos) {
1248 if (verbosity >= G4VisManager::warnings) {
1249 G4cout <<
1250 "WARNING: G4VisCommandsViewerSet::SetNewValue: /vis/viewer/set/specialMeshVolumes"
1251 "\n A pair not found. (There should be an even number of parameters.)"
1252 "\n Command ignored."
1253 << G4endl;
1254 return;
1255 }
1256 }
1257 iEnd = newValue.find_first_of(' ',iBegin);
1258 if (iEnd == G4String::npos) {
1259 iEnd = newValue.length();
1260 }
1261 G4int copyNo;
1262 std::istringstream iss(newValue.substr(iBegin,iEnd-iBegin));
1263 if (!(iss >> copyNo)) {
1264 if (verbosity >= G4VisManager::warnings) {
1265 G4cout <<
1266 "WARNING: G4VisCommandsViewerSet::SetNewValue: /vis/viewer/set/specialMeshVolumes"
1267 "\n Error reading copy number - it was not numeric?"
1268 "\n Command ignored."
1269 << G4endl;
1270 return;
1271 }
1272 }
1273 requestedMeshes.push_back(G4ModelingParameters::PVNameCopyNo(name,copyNo));
1274 iBegin = newValue.find_first_not_of(' ',iEnd);
1275 }
1276 vp.SetSpecialMeshVolumes(requestedMeshes);
1277 }
1278 if (verbosity >= G4VisManager::confirmations) {
1279 if (vp.GetSpecialMeshVolumes().empty()) {
1280 G4cout <<
1281 "Special mesh list empty, which means \"all meshes\"."
1282 << G4endl;
1283 } else {
1284 G4cout << "Selected special mesh volumes are:";
1285 for (const auto& pvNameCopyNo: vp.GetSpecialMeshVolumes()) {
1286 G4cout << "\n " << pvNameCopyNo.GetName();
1287 if (pvNameCopyNo.GetCopyNo() >= 0) G4cout << ':' << pvNameCopyNo.GetCopyNo();
1288 }
1289 G4cout << G4endl;
1290 }
1291 }
1292 }
1293
1294 else if (command == fpCommandStyle) {
1296 const size_t iPos0 = 0;
1297 if (newValue[iPos0] == 'w') { // "wireframe"
1298 switch (existingStyle) {
1300 break;
1302 break;
1305 break;
1308 break;
1311 break;
1312 }
1313 }
1314 else if (newValue[iPos0] == 's') { // "surface"
1315 switch (existingStyle) {
1318 break;
1321 break;
1323 break;
1325 break;
1328 break;
1329 }
1330 }
1331 else if (newValue[iPos0] == 'c') { // "cloud"
1332 switch (existingStyle) {
1335 break;
1338 break;
1341 break;
1344 break;
1346 break;
1347 }
1348 }
1349 else {
1350 if (verbosity >= G4VisManager::errors) {
1351 G4cerr << "ERROR: \"" << newValue << "\" not recognised."
1352 " Looking for 'w' or 's' or 'c' first character." << G4endl;
1353 }
1354 return;
1355 }
1356 if (verbosity >= G4VisManager::confirmations) {
1357 G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
1358 << "\" set to " << vp.GetDrawingStyle()
1359 << G4endl;
1360 }
1361 }
1362
1363 else if (command == fpCommandTargetPoint) {
1364 G4ThreeVector targetPoint =
1366 const G4Point3D& standardTargetPoint =
1367 currentViewer->GetSceneHandler()->GetScene()->GetStandardTargetPoint();
1368 vp.SetCurrentTargetPoint(targetPoint - standardTargetPoint);
1369 if (verbosity >= G4VisManager::confirmations) {
1370 G4cout << "Target point set to "
1372 (targetPoint)
1373 << "\n\"Current Target Point\" set to "
1376 << "\n\"Standard Target Point\" is "
1378 (standardTargetPoint)
1379 << G4endl;
1380 }
1381 }
1382
1383 else if (command == fpCommandUpThetaPhi) {
1384 G4double theta, phi;
1385 if (ConvertToDoublePair(newValue, theta, phi)) {
1386 G4double x = std::sin (theta) * std::cos (phi);
1387 G4double y = std::sin (theta) * std::sin (phi);
1388 G4double z = std::cos (theta);
1389 fUpVector = G4ThreeVector (x, y, z);
1391 if (verbosity >= G4VisManager::confirmations) {
1392 G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1393 }
1394 }
1395 }
1396
1397 else if (command == fpCommandUpVector) {
1400 if (verbosity >= G4VisManager::confirmations) {
1401 G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
1402 }
1403 }
1404
1405 else if (command == fpCommandViewpointThetaPhi) {
1406 G4double theta, phi;
1407 if (ConvertToDoublePair(newValue, theta, phi)) {
1408 G4double x = std::sin (theta) * std::cos (phi);
1409 G4double y = std::sin (theta) * std::sin (phi);
1410 G4double z = std::cos (theta);
1411 fViewpointVector = G4ThreeVector (x, y, z);
1413 if (verbosity >= G4VisManager::confirmations) {
1414 G4cout << "Viewpoint direction set to "
1415 << vp.GetViewpointDirection() << G4endl;
1416 if (vp.GetLightsMoveWithCamera ()) {
1417 G4cout << "Lightpoint direction set to "
1419 }
1420 }
1421 }
1422 }
1423
1424 else if (command == fpCommandViewpointVector) {
1425 G4ThreeVector viewpointVector = G4UIcommand::ConvertTo3Vector(newValue);
1426 if (viewpointVector.mag2() <= 0.) {
1427 if (verbosity >= G4VisManager::errors) {
1428 G4cerr << "ERROR: Null viewpoint vector. No action taken." << G4endl;
1429 }
1430 } else {
1431 fViewpointVector = viewpointVector.unit();
1433 if (verbosity >= G4VisManager::confirmations) {
1434 G4cout << "Viewpoint direction set to "
1435 << vp.GetViewpointDirection() << G4endl;
1436 if (vp.GetLightsMoveWithCamera ()) {
1437 G4cout << "Lightpoint direction set to "
1439 }
1440 }
1441 }
1442 }
1443
1444 else if (command == fpCommandTimeWindowDisplayHeadTime)
1445 {
1446 G4String display;
1447 G4double screenX, screenY, screenSize, red, green, blue;
1448 std::istringstream iss(newValue);
1449 iss >> display >> screenX >> screenY
1450 >> screenSize >> red >> green >> blue;
1451 vp.SetDisplayHeadTime(command->ConvertToBool(display));
1452 vp.SetDisplayHeadTimeX(screenX);
1453 vp.SetDisplayHeadTimeY(screenY);
1454 vp.SetDisplayHeadTimeSize(screenSize);
1455 vp.SetDisplayHeadTimeRed(red);
1456 vp.SetDisplayHeadTimeGreen(green);
1457 vp.SetDisplayHeadTimeBlue(blue);
1458 if (verbosity >= G4VisManager::confirmations) {
1459 G4cout << "Display head time flag set: "
1460 << vp
1461 << G4endl;
1462 }
1463 }
1464
1465 else if (command == fpCommandTimeWindowDisplayLightFront)
1466 {
1467 G4String display, originX, originY, originZ, unitS, originT, unitT;
1468 G4double red, green, blue;
1469 std::istringstream iss(newValue);
1470 iss >> display
1471 >> originX >> originY >> originZ >> unitS
1472 >> originT >> unitT
1473 >> red >> green >> blue;
1474 vp.SetDisplayLightFront(command->ConvertToBool(display));
1476 (command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)));
1478 (command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)));
1480 (command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)));
1482 (command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)));
1484 vp.SetDisplayLightFrontGreen(green);
1485 vp.SetDisplayLightFrontBlue(blue);
1486 if (verbosity >= G4VisManager::confirmations) {
1487 G4cout << "Display light front flag set: "
1488 << vp
1489 << G4endl;
1490 }
1491 }
1492
1493 else if (command == fpCommandTimeWindowEndTime)
1494 {
1495 G4String end_time_string, end_time_unit,
1496 time_range_string, time_range_unit;
1497 std::istringstream iss(newValue);
1498 iss >> end_time_string >> end_time_unit
1499 >> time_range_string >> time_range_unit;
1500 vp.SetEndTime
1502 (G4String(end_time_string + ' ' + end_time_unit)));
1503 G4double timeRange = command->ConvertToDimensionedDouble
1504 (G4String(time_range_string + ' ' + time_range_unit));
1505 if (timeRange > 0.) {
1506 vp.SetStartTime
1507 (vp.GetEndTime() - timeRange);
1508 }
1509 if (verbosity >= G4VisManager::confirmations) {
1510 G4cout
1511 << "Time window start time: " << vp.GetStartTime()/ns << " ns"
1512 << ", time window end time: " << vp.GetEndTime()/ns << " ns";
1513 if (timeRange > 0.) {
1514 G4cout << "\n (time range: " << timeRange/ns << " ns)";
1515 }
1516 G4cout << G4endl;
1517 }
1518 }
1519
1520 else if (command == fpCommandTimeWindowFadeFactor) {
1521 vp.SetFadeFactor(command->ConvertToDouble(newValue));
1522 if (verbosity >= G4VisManager::confirmations) {
1523 G4cout << "Time window fade factor changed to " << vp.GetFadeFactor()
1524 << G4endl;
1525 }
1526 }
1527
1528 else if (command == fpCommandTimeWindowStartTime)
1529 {
1530 G4String start_time_string, start_time_unit,
1531 time_range_string, time_range_unit;
1532 std::istringstream iss(newValue);
1533 iss >> start_time_string >> start_time_unit
1534 >> time_range_string >> time_range_unit;
1535 vp.SetStartTime
1537 (G4String(start_time_string + ' ' + start_time_unit)));
1538 G4double timeRange = command->ConvertToDimensionedDouble
1539 (G4String(time_range_string + ' ' + time_range_unit));
1540 if (timeRange > 0.) {
1541 vp.SetEndTime
1542 (vp.GetStartTime() + timeRange);
1543 }
1544 if (verbosity >= G4VisManager::confirmations) {
1545 G4cout
1546 << "Time window start time: " << vp.GetStartTime()/ns << " ns"
1547 << ", time window end time: " << vp.GetEndTime()/ns << " ns";
1548 if (timeRange > 0.) {
1549 G4cout << "\n (time range: " << timeRange/ns << " ns)";
1550 }
1551 G4cout << G4endl;
1552 }
1553 }
1554
1555 else {
1556 if (verbosity >= G4VisManager::errors) {
1557 G4cerr <<
1558 "ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command."
1559 << G4endl;
1560 }
1561 return;
1562 }
1563
1564 SetViewParameters(currentViewer,vp);
1565}
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:34
HepGeom::Plane3D< G4double > G4Plane3D
Definition: G4Plane3D.hh:36
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:34
static constexpr double deg
Definition: G4SIunits.hh:132
#define G4BestUnit(a, b)
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
Hep3Vector unit() const
double mag2() const
const G4Point3D & GetStandardTargetPoint() const
G4String ConvertToStringWithBestUnit(G4ThreeVector vec)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetUnitCategory(const char *unitCategory)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4double GetNewDoubleValue(const char *paramString)
void SetDefaultValue(G4double defVal)
void SetCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
static G4ThreeVector ConvertTo3Vector(const char *st)
Definition: G4UIcommand.cc:597
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:363
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:557
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:545
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:575
static G4double ConvertToDimensionedDouble(const char *st)
Definition: G4UIcommand.cc:584
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)
G4Scene * GetScene() const
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
const G4ViewParameters & GetDefaultViewParameters() const
void SetViewParameters(const G4ViewParameters &vp)
Definition: G4VViewer.cc:120
G4VSceneHandler * GetSceneHandler() const
void ConvertToColour(G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
static G4VisManager * fpVisManager
static G4bool ConvertToDoublePair(const G4String &paramString, G4double &xval, G4double &yval)
void SetViewParameters(G4VViewer *viewer, const G4ViewParameters &viewParams)
const G4String & ConvertToColourGuidance()
G4bool ProvideValueOfUnit(const G4String &where, const G4String &unit, const G4String &category, G4double &value)
void CopyMostViewParameters(G4ViewParameters &target, const G4ViewParameters &from)
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
G4int SetNumberOfCloudPoints(G4int)
G4int SetNoOfSides(G4int nSides)
void SetViewAndLights(const G4Vector3D &viewpointDirection)
void SetAutoRefresh(G4bool)
void SetBackgroundColour(const G4Colour &)
void SetGlobalMarkerScale(G4double globalMarkerScale)
void SetExplodeCentre(const G4Point3D &explodeCentre)
void SetDisplayLightFrontY(G4double)
G4bool IsSpecialMeshRendering() const
CutawayMode GetCutawayMode() const
G4double GetExplodeFactor() const
G4bool IsMarkerNotHidden() const
void SetDisplayHeadTimeBlue(G4double)
void SetVisibleDensity(G4double visibleDensity)
G4double GetGlobalLineWidthScale() const
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4Vector3D & GetActualLightpointDirection()
void SetCulling(G4bool)
void SetCurrentTargetPoint(const G4Point3D &currentTargetPoint)
void SetDisplayLightFrontT(G4double)
void UnsetSectionPlane()
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
const G4Colour & GetBackgroundColour() const
const G4Vector3D & GetLightpointDirection() const
void SetDisplayHeadTimeX(G4double)
void SetDefaultVisAttributes(const G4VisAttributes &)
void SetFieldHalfAngle(G4double fieldHalfAngle)
void SetCullingCovered(G4bool)
const G4Vector3D & GetViewpointDirection() const
G4bool IsSection() const
void SetExplodeFactor(G4double explodeFactor)
void SetGlobalLineWidthScale(G4double globalLineWidthScale)
const G4Point3D & GetCurrentTargetPoint() const
G4bool IsPicking() const
void SetStartTime(G4double)
void SetSpecialMeshVolumes(const std::vector< G4ModelingParameters::PVNameCopyNo > &)
void SetPicking(G4bool)
void SetDisplayLightFrontBlue(G4double)
void SetMarkerHidden()
void SetDisplayHeadTime(G4bool)
const G4VisAttributes * GetDefaultTextVisAttributes() const
void SetDisplayHeadTimeY(G4double)
void SetDensityCulling(G4bool)
void SetDisplayLightFrontZ(G4double)
G4double GetStartTime() const
void SetDisplayLightFront(G4bool)
void SetDisplayLightFrontRed(G4double)
const G4Vector3D & GetUpVector() const
void SetDisplayHeadTimeSize(G4double)
void SetMarkerNotHidden()
void SetDisplayHeadTimeRed(G4double)
G4double GetEndTime() const
const std::vector< G4ModelingParameters::PVNameCopyNo > & GetSpecialMeshVolumes() const
G4double GetFadeFactor() const
G4double GetGlobalMarkerScale() const
const G4VisAttributes * GetDefaultVisAttributes() const
void SetCullingInvisible(G4bool)
void SetUpVector(const G4Vector3D &upVector)
void SetEndTime(G4double)
void SetFadeFactor(G4double)
RotationStyle GetRotationStyle() const
void SetCutawayMode(CutawayMode)
void SetSpecialMeshRendering(G4bool)
G4bool IsDensityCulling() const
void SetDefaultTextVisAttributes(const G4VisAttributes &)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetDisplayLightFrontX(G4double)
void SetLightsMoveWithCamera(G4bool moves)
void SetDisplayHeadTimeGreen(G4double)
void SetRotationStyle(RotationStyle)
G4bool IsAutoRefresh() const
G4double GetVisibleDensity() const
G4bool GetLightsMoveWithCamera() const
void SetSectionPlane(const G4Plane3D &sectionPlane)
void SetAuxEdgeVisible(G4bool)
void SetDisplayLightFrontGreen(G4double)
const G4Point3D & GetExplodeCentre() const
const G4Plane3D & GetSectionPlane() const
DrawingStyle GetDrawingStyle() const
G4bool IsAuxEdgeVisible() const
void SetColour(const G4Colour &)
const G4Colour & GetColour() const
static constexpr G4double fVeryLongTime
G4UIcmdWith3VectorAndUnit * fpCommandTargetPoint
G4UIcmdWithABool * fpCommandHiddenEdge
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithABool * fpCommandPicking
G4UIcmdWithABool * fpCommandAutoRefresh
G4UIcmdWithADouble * fpCommandGlobalLineWidthScale
G4UIcmdWithABool * fpCommandAuxEdge
G4UIcommand * fpCommandViewpointThetaPhi
G4UIcmdWithAnInteger * fpCommandLineSegments
G4UIcommand * fpCommandTimeWindowDisplayHeadTime
G4UIcmdWithABool * fpCommandHiddenMarker
G4UIdirectory * fpTimeWindowDirectory
G4UIcmdWithAString * fpCommandCutawayMode
G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithADouble * fpCommandTimeWindowFadeFactor
G4UIcmdWithAString * fpCommandStyle
G4UIcmdWithADouble * fpCommandGlobalMarkerScale
G4UIcommand * fpCommandDefaultTextColour
G4UIcommand * fpCommandSpecialMeshVolumes
G4UIcmdWithABool * fpCommandEdge
G4UIcmdWithAnInteger * fpCommandNumberOfCloudPoints
G4UIcmdWithAString * fpCommandRotationStyle
G4UIcmdWithABool * fpCommandSpecialMeshRendering
G4UIcommand * fpCommandTimeWindowStartTime
G4UIcmdWithAString * fpCommandLightsMove
G4UIcommand * fpCommandTimeWindowDisplayLightFront
G4UIcommand * fpCommandTimeWindowEndTime
G4UIcmdWithAString * fpCommandAll
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()
G4VViewer * GetViewer(const G4String &viewerName) const
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:79
const char * name(G4int ptype)
G4int icompare(std::string_view lhs, std::string_view rhs)
Case insensitive comparison of two strings.
#define ns
Definition: xmlparse.cc:614