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