1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // $Id: G4VisCommandsViewerSet.cc,v 1.50 2009/05/13 18:17:25 allison Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | |
---|
30 | // /vis/viewer/set commands - John Allison 16th May 2000 |
---|
31 | |
---|
32 | #include "G4VisCommandsViewerSet.hh" |
---|
33 | |
---|
34 | #include "G4UIcommand.hh" |
---|
35 | #include "G4UIcmdWithAString.hh" |
---|
36 | #include "G4UIcmdWithABool.hh" |
---|
37 | #include "G4UIcmdWithAnInteger.hh" |
---|
38 | #include "G4UIcmdWithADouble.hh" |
---|
39 | #include "G4UIcmdWith3VectorAndUnit.hh" |
---|
40 | #include "G4UnitsTable.hh" |
---|
41 | #include "G4VisManager.hh" |
---|
42 | #include "G4Polyhedron.hh" |
---|
43 | |
---|
44 | #include <sstream> |
---|
45 | #include <cctype> |
---|
46 | |
---|
47 | G4VisCommandsViewerSet::G4VisCommandsViewerSet (): |
---|
48 | fLightsVector (G4ThreeVector(1.,1.,1.)), |
---|
49 | fUpVector (G4ThreeVector(0.,1.,0.)), |
---|
50 | fViewpointVector (G4ThreeVector(0.,0.,1.)) |
---|
51 | { |
---|
52 | G4bool omitable; |
---|
53 | G4UIparameter* parameter; |
---|
54 | |
---|
55 | fpCommandAll = new G4UIcmdWithAString ("/vis/viewer/set/all",this); |
---|
56 | fpCommandAll->SetGuidance |
---|
57 | ("Copies view parameters."); |
---|
58 | fpCommandAll->SetGuidance |
---|
59 | ("Copies view parameters (except the autoRefresh status) from" |
---|
60 | "\nfrom-viewer to current viewer."); |
---|
61 | fpCommandAll->SetParameterName ("from-viewer-name",omitable = false); |
---|
62 | |
---|
63 | fpCommandAutoRefresh = new G4UIcmdWithABool |
---|
64 | ("/vis/viewer/set/autoRefresh",this); |
---|
65 | fpCommandAutoRefresh->SetGuidance("Sets auto-refresh."); |
---|
66 | fpCommandAutoRefresh->SetGuidance |
---|
67 | ("If true, view is automatically refreshed after a change of" |
---|
68 | "\nview parameters."); |
---|
69 | fpCommandAutoRefresh->SetParameterName("auto-refresh",omitable = true); |
---|
70 | fpCommandAutoRefresh->SetDefaultValue(true); |
---|
71 | |
---|
72 | fpCommandAuxEdge = new G4UIcmdWithABool |
---|
73 | ("/vis/viewer/set/auxiliaryEdge",this); |
---|
74 | fpCommandAuxEdge->SetGuidance("Sets visibility of auxiliary edges"); |
---|
75 | fpCommandAuxEdge->SetGuidance |
---|
76 | ("Auxiliary edges, i.e., those that are part of a curved surface," |
---|
77 | "\nsometimes called soft edges, become visible/invisible."); |
---|
78 | fpCommandAuxEdge->SetParameterName("edge",omitable = true); |
---|
79 | fpCommandAuxEdge->SetDefaultValue(true); |
---|
80 | |
---|
81 | fpCommandBackground = new G4UIcommand |
---|
82 | ("/vis/viewer/set/background",this); |
---|
83 | fpCommandBackground->SetGuidance |
---|
84 | ("Set background colour and transparency (default black and opaque)."); |
---|
85 | fpCommandBackground->SetGuidance |
---|
86 | ("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or" |
---|
87 | "\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..." |
---|
88 | "\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\"" |
---|
89 | "\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters)," |
---|
90 | "\n e.g. \"! ! ! 0.\" for a transparent background."); |
---|
91 | parameter = new G4UIparameter("red_or_string", 's', omitable = true); |
---|
92 | parameter -> SetDefaultValue ("0."); |
---|
93 | fpCommandBackground -> SetParameter (parameter); |
---|
94 | parameter = new G4UIparameter("green", 'd', omitable = true); |
---|
95 | parameter -> SetDefaultValue (0.); |
---|
96 | fpCommandBackground -> SetParameter (parameter); |
---|
97 | parameter = new G4UIparameter ("blue", 'd', omitable = true); |
---|
98 | parameter -> SetDefaultValue (0.); |
---|
99 | fpCommandBackground -> SetParameter (parameter); |
---|
100 | parameter = new G4UIparameter ("opacity", 'd', omitable = true); |
---|
101 | parameter -> SetDefaultValue (1.); |
---|
102 | fpCommandBackground -> SetParameter (parameter); |
---|
103 | |
---|
104 | fpCommandCulling = new G4UIcommand("/vis/viewer/set/culling",this); |
---|
105 | fpCommandCulling->SetGuidance ("Set culling options."); |
---|
106 | fpCommandCulling->SetGuidance |
---|
107 | ("\"global\": enables/disables all other culling options."); |
---|
108 | fpCommandCulling->SetGuidance |
---|
109 | ("\"coveredDaughters\": culls, i.e., eliminates, volumes that would not" |
---|
110 | "\nbe seen because covered by ancester volumes in surface drawing mode," |
---|
111 | "\nand then only if the ancesters are visible and opaque, and then only" |
---|
112 | "\nif no sections or cutaways are in operation. Intended solely to" |
---|
113 | "\nimprove the speed of rendering visible volumes."); |
---|
114 | fpCommandCulling->SetGuidance |
---|
115 | ("\"invisible\": culls objects with the invisible attribute set."); |
---|
116 | fpCommandCulling->SetGuidance |
---|
117 | ("\"density\": culls volumes with density lower than threshold. Useful" |
---|
118 | "\nfor eliminating \"container volumes\" with no physical correspondence," |
---|
119 | "\nwhose material is usually air. If this is selected, provide threshold" |
---|
120 | "\ndensity and unit (g/cm3 mg/cm3 or kg/m3)." |
---|
121 | ); |
---|
122 | parameter = new G4UIparameter("culling-option",'s',omitable = false); |
---|
123 | parameter->SetParameterCandidates |
---|
124 | ("global coveredDaughters invisible density"); |
---|
125 | fpCommandCulling->SetParameter(parameter); |
---|
126 | parameter = new G4UIparameter("action",'b',omitable = true); |
---|
127 | parameter->SetDefaultValue(1); |
---|
128 | fpCommandCulling->SetParameter(parameter); |
---|
129 | parameter = new G4UIparameter("density-threshold",'d',omitable = true); |
---|
130 | parameter->SetDefaultValue("0.01"); |
---|
131 | fpCommandCulling->SetParameter(parameter); |
---|
132 | parameter = new G4UIparameter("unit",'s',omitable = true); |
---|
133 | parameter->SetParameterCandidates ("g/cm3, mg/cm3 kg/m3"); |
---|
134 | parameter->SetDefaultValue("g/cm3"); |
---|
135 | fpCommandCulling->SetParameter(parameter); |
---|
136 | |
---|
137 | fpCommandCutawayMode = |
---|
138 | new G4UIcmdWithAString ("/vis/viewer/set/cutawayMode", this); |
---|
139 | fpCommandCutawayMode->SetGuidance |
---|
140 | ("Sets cutaway mode - add (union) or multiply (intersection)."); |
---|
141 | fpCommandCutawayMode->SetParameterName ("cutaway-mode",omitable = false); |
---|
142 | fpCommandCutawayMode->SetCandidates ("add union multiply intersection"); |
---|
143 | fpCommandCutawayMode->SetDefaultValue("union"); |
---|
144 | |
---|
145 | fpCommandEdge = new G4UIcmdWithABool("/vis/viewer/set/edge",this); |
---|
146 | fpCommandEdge->SetGuidance |
---|
147 | ("Edges become visible/invisible in surface mode."); |
---|
148 | fpCommandEdge->SetParameterName("edge",omitable = true); |
---|
149 | fpCommandEdge->SetDefaultValue(true); |
---|
150 | |
---|
151 | fpCommandExplodeFactor = new G4UIcommand |
---|
152 | ("/vis/viewer/set/explodeFactor", this); |
---|
153 | fpCommandExplodeFactor->SetGuidance |
---|
154 | ("Moves top-level drawn volumes by this factor from this centre."); |
---|
155 | parameter = new G4UIparameter("explodeFactor", 'd', omitable=true); |
---|
156 | parameter->SetParameterRange("explodeFactor>=1."); |
---|
157 | parameter->SetDefaultValue(1.); |
---|
158 | fpCommandExplodeFactor->SetParameter(parameter); |
---|
159 | parameter = new G4UIparameter("x",'d',omitable = true); |
---|
160 | parameter->SetDefaultValue (0); |
---|
161 | parameter->SetGuidance ("Coordinate of explode centre."); |
---|
162 | fpCommandExplodeFactor->SetParameter(parameter); |
---|
163 | parameter = new G4UIparameter("y",'d',omitable = true); |
---|
164 | parameter->SetDefaultValue (0); |
---|
165 | parameter->SetGuidance ("Coordinate of explode centre."); |
---|
166 | fpCommandExplodeFactor->SetParameter(parameter); |
---|
167 | parameter = new G4UIparameter("z",'d',omitable = true); |
---|
168 | parameter->SetDefaultValue (0); |
---|
169 | parameter->SetGuidance ("Coordinate of explode centre."); |
---|
170 | fpCommandExplodeFactor->SetParameter(parameter); |
---|
171 | parameter = new G4UIparameter("unit",'s',omitable = true); |
---|
172 | parameter->SetDefaultValue ("m"); |
---|
173 | parameter->SetGuidance ("Unit of explode centre."); |
---|
174 | fpCommandExplodeFactor->SetParameter(parameter); |
---|
175 | |
---|
176 | fpCommandGlobalLineWidthScale = new G4UIcmdWithADouble |
---|
177 | ("/vis/viewer/set/globalLineWidthScale", this); |
---|
178 | fpCommandGlobalLineWidthScale->SetGuidance |
---|
179 | ("Multiplies line widths by this factor."); |
---|
180 | fpCommandGlobalLineWidthScale-> |
---|
181 | SetParameterName("scale-factor", omitable=true); |
---|
182 | fpCommandGlobalLineWidthScale->SetDefaultValue(1.); |
---|
183 | |
---|
184 | fpCommandGlobalMarkerScale = new G4UIcmdWithADouble |
---|
185 | ("/vis/viewer/set/globalMarkerScale", this); |
---|
186 | fpCommandGlobalMarkerScale->SetGuidance |
---|
187 | ("Multiplies marker sizes by this factor."); |
---|
188 | fpCommandGlobalMarkerScale-> |
---|
189 | SetParameterName("scale-factor", omitable=true); |
---|
190 | fpCommandGlobalMarkerScale->SetDefaultValue(1.); |
---|
191 | |
---|
192 | fpCommandHiddenEdge = |
---|
193 | new G4UIcmdWithABool("/vis/viewer/set/hiddenEdge",this); |
---|
194 | fpCommandHiddenEdge->SetGuidance |
---|
195 | ("Edges become hidden/seen in wireframe or surface mode."); |
---|
196 | fpCommandHiddenEdge->SetParameterName("hidden-edge",omitable = true); |
---|
197 | fpCommandHiddenEdge->SetDefaultValue(true); |
---|
198 | |
---|
199 | fpCommandHiddenMarker = |
---|
200 | new G4UIcmdWithABool("/vis/viewer/set/hiddenMarker",this); |
---|
201 | fpCommandHiddenMarker->SetGuidance |
---|
202 | ("If true, closer objects hide markers. Otherwise, markers always show."); |
---|
203 | fpCommandHiddenMarker->SetParameterName("hidden-marker",omitable = true); |
---|
204 | fpCommandHiddenMarker->SetDefaultValue(true); |
---|
205 | |
---|
206 | fpCommandLightsMove = new G4UIcmdWithAString |
---|
207 | ("/vis/viewer/set/lightsMove",this); |
---|
208 | fpCommandLightsMove->SetGuidance |
---|
209 | ("Lights move with camera or with object"); |
---|
210 | fpCommandLightsMove->SetParameterName("lightsMove",omitable = false); |
---|
211 | fpCommandLightsMove->SetCandidates |
---|
212 | ("cam camera with-camera obj object with-object"); |
---|
213 | |
---|
214 | fpCommandLightsThetaPhi = new G4UIcommand |
---|
215 | ("/vis/viewer/set/lightsThetaPhi", this); |
---|
216 | fpCommandLightsThetaPhi->SetGuidance |
---|
217 | ("Set direction from target to lights."); |
---|
218 | parameter = new G4UIparameter("theta", 'd', omitable = true); |
---|
219 | parameter -> SetDefaultValue(60.); |
---|
220 | fpCommandLightsThetaPhi -> SetParameter (parameter); |
---|
221 | parameter = new G4UIparameter("phi", 'd', omitable = true); |
---|
222 | parameter -> SetDefaultValue(45.); |
---|
223 | fpCommandLightsThetaPhi -> SetParameter (parameter); |
---|
224 | parameter = new G4UIparameter ("unit", 's', omitable = true); |
---|
225 | parameter -> SetDefaultValue ("deg"); |
---|
226 | fpCommandLightsThetaPhi -> SetParameter (parameter); |
---|
227 | |
---|
228 | fpCommandLightsVector = new G4UIcommand |
---|
229 | ("/vis/viewer/set/lightsVector", this); |
---|
230 | fpCommandLightsVector->SetGuidance |
---|
231 | ("Set direction from target to lights."); |
---|
232 | parameter = new G4UIparameter("x", 'd', omitable = true); |
---|
233 | parameter -> SetDefaultValue (1); |
---|
234 | fpCommandLightsVector -> SetParameter (parameter); |
---|
235 | parameter = new G4UIparameter("y", 'd', omitable = true); |
---|
236 | parameter -> SetDefaultValue (1); |
---|
237 | fpCommandLightsVector -> SetParameter (parameter); |
---|
238 | parameter = new G4UIparameter ("z", 'd', omitable = true); |
---|
239 | parameter -> SetDefaultValue (1); |
---|
240 | fpCommandLightsVector -> SetParameter (parameter); |
---|
241 | |
---|
242 | fpCommandLineSegments = new G4UIcmdWithAnInteger |
---|
243 | ("/vis/viewer/set/lineSegmentsPerCircle",this); |
---|
244 | fpCommandLineSegments->SetGuidance |
---|
245 | ("Set number of sides per circle for polygon/polyhedron drawing."); |
---|
246 | fpCommandLineSegments->SetGuidance |
---|
247 | ("Refers to graphical representation of objects with curved lines/surfaces."); |
---|
248 | fpCommandLineSegments->SetParameterName("line-segments",omitable = true); |
---|
249 | fpCommandLineSegments->SetDefaultValue(24); |
---|
250 | |
---|
251 | fpCommandPicking = new G4UIcmdWithABool |
---|
252 | ("/vis/viewer/set/picking",this); |
---|
253 | fpCommandPicking->SetGuidance("Sets picking, if available."); |
---|
254 | fpCommandPicking->SetGuidance |
---|
255 | ("If true, view is set up for picking, if available." |
---|
256 | "\nFor required actions, watch for instructions for viewer."); |
---|
257 | fpCommandPicking->SetParameterName("picking",omitable = true); |
---|
258 | fpCommandPicking->SetDefaultValue(true); |
---|
259 | |
---|
260 | fpCommandProjection = new G4UIcommand("/vis/viewer/set/projection",this); |
---|
261 | fpCommandProjection->SetGuidance |
---|
262 | ("Orthogonal or perspective projection."); |
---|
263 | parameter = new G4UIparameter("projection",'s',omitable = true); |
---|
264 | parameter->SetParameterCandidates("o orthogonal p perspective"); |
---|
265 | parameter->SetDefaultValue("orthogonal"); |
---|
266 | fpCommandProjection->SetParameter(parameter); |
---|
267 | parameter = new G4UIparameter("field-half-angle",'d',omitable = true); |
---|
268 | parameter->SetDefaultValue(30.); |
---|
269 | fpCommandProjection->SetParameter(parameter); |
---|
270 | parameter = new G4UIparameter("unit",'s',omitable = true); |
---|
271 | parameter->SetDefaultValue("deg"); |
---|
272 | fpCommandProjection->SetParameter(parameter); |
---|
273 | |
---|
274 | fpCommandSectionPlane = new G4UIcommand("/vis/viewer/set/sectionPlane",this); |
---|
275 | fpCommandSectionPlane -> SetGuidance |
---|
276 | ("Set plane for drawing section (DCUT)."); |
---|
277 | fpCommandSectionPlane -> SetGuidance |
---|
278 | ("E.g., for a y-z plane at x = 1 cm:" |
---|
279 | "\n\"/vis/viewer/set/sectionPlane on 1 0 0 cm 1 0 0\"." |
---|
280 | "\nTo turn off: /vis/viewer/set/sectionPlane off"); |
---|
281 | parameter = new G4UIparameter("Selector",'c',true); |
---|
282 | parameter -> SetDefaultValue ("on"); |
---|
283 | fpCommandSectionPlane->SetParameter(parameter); |
---|
284 | parameter = new G4UIparameter("x",'d',omitable = true); |
---|
285 | parameter -> SetDefaultValue (0); |
---|
286 | parameter -> SetGuidance ("Coordinate of point on the plane."); |
---|
287 | fpCommandSectionPlane->SetParameter(parameter); |
---|
288 | parameter = new G4UIparameter("y",'d',omitable = true); |
---|
289 | parameter -> SetDefaultValue (0); |
---|
290 | parameter -> SetGuidance ("Coordinate of point on the plane."); |
---|
291 | fpCommandSectionPlane->SetParameter(parameter); |
---|
292 | parameter = new G4UIparameter("z",'d',omitable = true); |
---|
293 | parameter -> SetDefaultValue (0); |
---|
294 | parameter -> SetGuidance ("Coordinate of point on the plane."); |
---|
295 | fpCommandSectionPlane->SetParameter(parameter); |
---|
296 | parameter = new G4UIparameter("unit",'s',omitable = true); |
---|
297 | parameter -> SetDefaultValue ("m"); |
---|
298 | parameter -> SetGuidance ("Unit of point on the plane."); |
---|
299 | fpCommandSectionPlane->SetParameter(parameter); |
---|
300 | parameter = new G4UIparameter("nx",'d',omitable = true); |
---|
301 | parameter -> SetDefaultValue (1); |
---|
302 | parameter -> SetGuidance ("Component of plane normal."); |
---|
303 | fpCommandSectionPlane->SetParameter(parameter); |
---|
304 | parameter = new G4UIparameter("ny",'d',omitable = true); |
---|
305 | parameter -> SetDefaultValue (0); |
---|
306 | parameter -> SetGuidance ("Component of plane normal."); |
---|
307 | fpCommandSectionPlane->SetParameter(parameter); |
---|
308 | parameter = new G4UIparameter("nz",'d',omitable = true); |
---|
309 | parameter -> SetDefaultValue (0); |
---|
310 | parameter -> SetGuidance ("Component of plane normal."); |
---|
311 | fpCommandSectionPlane->SetParameter(parameter); |
---|
312 | |
---|
313 | fpCommandStyle = new G4UIcmdWithAString ("/vis/viewer/set/style",this); |
---|
314 | fpCommandStyle->SetGuidance |
---|
315 | ("Set style of drawing - w[ireframe] or s[urface]."); |
---|
316 | fpCommandStyle->SetGuidance |
---|
317 | ("(Hidden line drawing is controlled by \"/vis/viewer/set/hiddenEdge\".)"); |
---|
318 | fpCommandStyle->SetParameterName ("style",omitable = false); |
---|
319 | |
---|
320 | fpCommandTargetPoint = new G4UIcmdWith3VectorAndUnit |
---|
321 | ("/vis/viewer/set/targetPoint", this); |
---|
322 | fpCommandTargetPoint->SetGuidance |
---|
323 | ("Set target point."); |
---|
324 | fpCommandTargetPoint->SetGuidance |
---|
325 | ("This sets the \"Current Target Point\" relative to the \"Standard"); |
---|
326 | fpCommandTargetPoint->SetGuidance |
---|
327 | ("Target Point\" so that the actual target point is as requested."); |
---|
328 | fpCommandTargetPoint->SetGuidance |
---|
329 | ("(See G4ViewParameters.hh for an explanation of target points.)"); |
---|
330 | fpCommandTargetPoint->SetParameterName("x", "y", "z", omitable = false); |
---|
331 | fpCommandTargetPoint->SetUnitCategory("Length"); |
---|
332 | |
---|
333 | fpCommandUpThetaPhi = new G4UIcommand |
---|
334 | ("/vis/viewer/set/upThetaPhi", this); |
---|
335 | fpCommandUpThetaPhi -> SetGuidance ("Set up vector."); |
---|
336 | fpCommandUpThetaPhi -> SetGuidance |
---|
337 | ("Viewer will attempt always to show this direction upwards."); |
---|
338 | parameter = new G4UIparameter("theta", 'd', omitable = true); |
---|
339 | parameter -> SetDefaultValue (90.); |
---|
340 | fpCommandUpThetaPhi -> SetParameter (parameter); |
---|
341 | parameter = new G4UIparameter("phi", 'd', omitable = true); |
---|
342 | parameter -> SetDefaultValue (90.); |
---|
343 | fpCommandUpThetaPhi -> SetParameter (parameter); |
---|
344 | parameter = new G4UIparameter ("unit", 's', omitable = true); |
---|
345 | parameter -> SetDefaultValue ("deg"); |
---|
346 | fpCommandUpThetaPhi -> SetParameter (parameter); |
---|
347 | |
---|
348 | fpCommandUpVector = new G4UIcommand |
---|
349 | ("/vis/viewer/set/upVector", this); |
---|
350 | fpCommandUpVector -> SetGuidance ("Set up vector."); |
---|
351 | fpCommandUpVector -> SetGuidance |
---|
352 | ("Viewer will attempt always to show this direction upwards."); |
---|
353 | parameter = new G4UIparameter("x", 'd', omitable = true); |
---|
354 | parameter -> SetDefaultValue (0.); |
---|
355 | fpCommandUpVector -> SetParameter (parameter); |
---|
356 | parameter = new G4UIparameter("y", 'd', omitable = true); |
---|
357 | parameter -> SetDefaultValue (1.); |
---|
358 | fpCommandUpVector -> SetParameter (parameter); |
---|
359 | parameter = new G4UIparameter ("z", 'd', omitable = true); |
---|
360 | parameter -> SetDefaultValue (0.); |
---|
361 | fpCommandUpVector -> SetParameter (parameter); |
---|
362 | |
---|
363 | fpCommandViewpointThetaPhi = new G4UIcommand |
---|
364 | ("/vis/viewer/set/viewpointThetaPhi", this); |
---|
365 | fpCommandViewpointThetaPhi -> SetGuidance |
---|
366 | ("Set direction from target to camera."); |
---|
367 | fpCommandViewpointThetaPhi -> SetGuidance |
---|
368 | ("Also changes lightpoint direction if lights are set to move with camera."); |
---|
369 | parameter = new G4UIparameter("theta", 'd', omitable = true); |
---|
370 | parameter -> SetDefaultValue (60.); |
---|
371 | fpCommandViewpointThetaPhi -> SetParameter (parameter); |
---|
372 | parameter = new G4UIparameter("phi", 'd', omitable = true); |
---|
373 | parameter -> SetDefaultValue (45.); |
---|
374 | fpCommandViewpointThetaPhi -> SetParameter (parameter); |
---|
375 | parameter = new G4UIparameter ("unit", 's', omitable = true); |
---|
376 | parameter -> SetDefaultValue ("deg"); |
---|
377 | fpCommandViewpointThetaPhi -> SetParameter (parameter); |
---|
378 | |
---|
379 | fpCommandViewpointVector = new G4UIcommand |
---|
380 | ("/vis/viewer/set/viewpointVector", this); |
---|
381 | fpCommandViewpointVector -> SetGuidance |
---|
382 | ("Set direction from target to camera."); |
---|
383 | fpCommandViewpointVector -> SetGuidance |
---|
384 | ("Also changes lightpoint direction if lights are set to move with camera."); |
---|
385 | parameter = new G4UIparameter("x", 'd', omitable = true); |
---|
386 | parameter -> SetDefaultValue (1.); |
---|
387 | fpCommandViewpointVector -> SetParameter (parameter); |
---|
388 | parameter = new G4UIparameter("y", 'd', omitable = true); |
---|
389 | parameter -> SetDefaultValue (1.); |
---|
390 | fpCommandViewpointVector -> SetParameter (parameter); |
---|
391 | parameter = new G4UIparameter ("z", 'd', omitable = true); |
---|
392 | parameter -> SetDefaultValue (1.); |
---|
393 | fpCommandViewpointVector -> SetParameter (parameter); |
---|
394 | } |
---|
395 | |
---|
396 | G4VisCommandsViewerSet::~G4VisCommandsViewerSet() { |
---|
397 | delete fpCommandAll; |
---|
398 | delete fpCommandAuxEdge; |
---|
399 | delete fpCommandAutoRefresh; |
---|
400 | delete fpCommandBackground; |
---|
401 | delete fpCommandCulling; |
---|
402 | delete fpCommandCutawayMode; |
---|
403 | delete fpCommandEdge; |
---|
404 | delete fpCommandExplodeFactor; |
---|
405 | delete fpCommandGlobalLineWidthScale; |
---|
406 | delete fpCommandGlobalMarkerScale; |
---|
407 | delete fpCommandHiddenEdge; |
---|
408 | delete fpCommandHiddenMarker; |
---|
409 | delete fpCommandLineSegments; |
---|
410 | delete fpCommandLightsMove; |
---|
411 | delete fpCommandLightsThetaPhi; |
---|
412 | delete fpCommandLightsVector; |
---|
413 | delete fpCommandPicking; |
---|
414 | delete fpCommandProjection; |
---|
415 | delete fpCommandSectionPlane; |
---|
416 | delete fpCommandStyle; |
---|
417 | delete fpCommandTargetPoint; |
---|
418 | delete fpCommandUpThetaPhi; |
---|
419 | delete fpCommandUpVector; |
---|
420 | delete fpCommandViewpointThetaPhi; |
---|
421 | delete fpCommandViewpointVector; |
---|
422 | } |
---|
423 | |
---|
424 | G4String G4VisCommandsViewerSet::GetCurrentValue(G4UIcommand*) { |
---|
425 | return ""; |
---|
426 | } |
---|
427 | |
---|
428 | void G4VisCommandsViewerSet::SetNewValue |
---|
429 | (G4UIcommand* command,G4String newValue) { |
---|
430 | |
---|
431 | G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); |
---|
432 | |
---|
433 | G4VViewer* currentViewer = fpVisManager->GetCurrentViewer(); |
---|
434 | if (!currentViewer) { |
---|
435 | if (verbosity >= G4VisManager::errors) { |
---|
436 | G4cout << |
---|
437 | "ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer." |
---|
438 | << G4endl; |
---|
439 | } |
---|
440 | return; |
---|
441 | } |
---|
442 | |
---|
443 | G4ViewParameters vp = currentViewer->GetViewParameters(); |
---|
444 | |
---|
445 | if (command == fpCommandAll) { |
---|
446 | G4VViewer* fromViewer = fpVisManager->GetViewer(newValue); |
---|
447 | if (!fromViewer) { |
---|
448 | if (verbosity >= G4VisManager::errors) { |
---|
449 | G4cout << |
---|
450 | "ERROR: G4VisCommandsViewerSet::SetNewValue: all:" |
---|
451 | "\n unrecognised from-viewer." |
---|
452 | << G4endl; |
---|
453 | } |
---|
454 | return; |
---|
455 | } |
---|
456 | if (fromViewer == currentViewer) { |
---|
457 | if (verbosity >= G4VisManager::warnings) { |
---|
458 | G4cout << |
---|
459 | "WARNING: G4VisCommandsViewerSet::SetNewValue: all:" |
---|
460 | "\n from-viewer and current viewer are identical." |
---|
461 | << G4endl; |
---|
462 | } |
---|
463 | return; |
---|
464 | } |
---|
465 | // Copy view parameters except for autoRefresh... |
---|
466 | G4bool currentAutoRefresh = |
---|
467 | currentViewer->GetViewParameters().IsAutoRefresh(); |
---|
468 | vp = fromViewer->GetViewParameters(); |
---|
469 | vp.SetAutoRefresh(currentAutoRefresh); |
---|
470 | if (verbosity >= G4VisManager::confirmations) { |
---|
471 | G4cout << "View parameters of viewer \"" << currentViewer->GetName() |
---|
472 | << "\"\n set to those of viewer \"" << fromViewer->GetName() |
---|
473 | << "\"." |
---|
474 | << G4endl; |
---|
475 | } |
---|
476 | } |
---|
477 | |
---|
478 | else if (command == fpCommandAutoRefresh) { |
---|
479 | G4bool autoRefresh = G4UIcommand::ConvertToBool(newValue); |
---|
480 | vp.SetAutoRefresh(autoRefresh); |
---|
481 | if (verbosity >= G4VisManager::confirmations) { |
---|
482 | G4cout << "Views will "; |
---|
483 | if (!vp.IsAutoRefresh()) G4cout << "not "; |
---|
484 | G4cout << "be automatically refreshed after a change of view parameters." |
---|
485 | << G4endl; |
---|
486 | } |
---|
487 | if (!vp.IsAutoRefresh()) { |
---|
488 | currentViewer->SetViewParameters(vp); |
---|
489 | return; // Avoid a refresh id auto-refresh has been set to off... |
---|
490 | } // ...otherwise take normal action. |
---|
491 | } |
---|
492 | |
---|
493 | else if (command == fpCommandAuxEdge) { |
---|
494 | vp.SetAuxEdgeVisible(G4UIcommand::ConvertToBool(newValue)); |
---|
495 | if (verbosity >= G4VisManager::confirmations) { |
---|
496 | G4cout << "Auxiliary edges will "; |
---|
497 | if (!vp.IsAuxEdgeVisible()) G4cout << "not "; |
---|
498 | G4cout << "be visible." << G4endl; |
---|
499 | } |
---|
500 | } |
---|
501 | |
---|
502 | else if (command == fpCommandBackground) { |
---|
503 | G4String redOrString; |
---|
504 | G4double green, blue, opacity; |
---|
505 | std::istringstream iss(newValue); |
---|
506 | iss >> redOrString >> green >> blue >> opacity; |
---|
507 | G4Colour colour(0.,0.,0.); // Default black and opaque. |
---|
508 | const size_t iPos0 = 0; |
---|
509 | if (std::isalpha(redOrString[iPos0])) { |
---|
510 | G4Colour::GetColour(redOrString, colour); // Remains default (black) if |
---|
511 | // not found. |
---|
512 | } else { |
---|
513 | colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue)); |
---|
514 | } |
---|
515 | colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity); |
---|
516 | vp.SetBackgroundColour(colour); |
---|
517 | if (verbosity >= G4VisManager::confirmations) { |
---|
518 | G4cout << "Background colour " |
---|
519 | << vp.GetBackgroundColour() |
---|
520 | << " requested." |
---|
521 | << G4endl; |
---|
522 | } |
---|
523 | } |
---|
524 | |
---|
525 | else if (command == fpCommandCulling) { |
---|
526 | G4String cullingOption, stringFlag, unit; |
---|
527 | G4double density; |
---|
528 | std::istringstream is (newValue); |
---|
529 | is >> cullingOption >> stringFlag >> density >> unit; |
---|
530 | G4bool boolFlag = G4UIcommand::ConvertToBool(stringFlag); |
---|
531 | if (cullingOption == "global") { |
---|
532 | vp.SetCulling(boolFlag); |
---|
533 | if (verbosity >= G4VisManager::confirmations) { |
---|
534 | G4cout << |
---|
535 | "G4VisCommandsViewerSet::SetNewValue: culling: global culling flag" |
---|
536 | " set to " << G4UIcommand::ConvertToString(boolFlag) << |
---|
537 | ".\n Does not change specific culling flags." |
---|
538 | << G4endl; |
---|
539 | } |
---|
540 | } |
---|
541 | else if (cullingOption == "coveredDaughters") { |
---|
542 | vp.SetCullingCovered(boolFlag); |
---|
543 | if (verbosity >= G4VisManager::confirmations) { |
---|
544 | G4cout << |
---|
545 | "G4VisCommandsViewerSet::SetNewValue: culling: culling covered" |
---|
546 | "\n daughters flag set to " |
---|
547 | << G4UIcommand::ConvertToString(boolFlag) << |
---|
548 | ". Daughters covered by opaque mothers" |
---|
549 | "\n will be culled, i.e., not drawn, if this flag is true." |
---|
550 | "\n Note: this is only effective in surface drawing style," |
---|
551 | "\n and then only if the volumes are visible and opaque, and then" |
---|
552 | "\n only if no sections or cutaways are in operation." |
---|
553 | << G4endl; |
---|
554 | } |
---|
555 | } |
---|
556 | else if (cullingOption == "invisible") { |
---|
557 | vp.SetCullingInvisible(boolFlag); |
---|
558 | if (verbosity >= G4VisManager::confirmations) { |
---|
559 | G4cout << |
---|
560 | "G4VisCommandsViewerSet::SetNewValue: culling: culling invisible" |
---|
561 | "\n flag set to " |
---|
562 | << boolFlag << G4UIcommand::ConvertToString(boolFlag) << |
---|
563 | ". Volumes marked invisible will be culled," |
---|
564 | "\n i.e., not drawn, if this flag is true." |
---|
565 | << G4endl; |
---|
566 | } |
---|
567 | } |
---|
568 | else if (cullingOption == "density") { |
---|
569 | vp.SetDensityCulling(boolFlag); |
---|
570 | if (boolFlag) { |
---|
571 | density *= G4UnitDefinition::GetValueOf(unit); |
---|
572 | vp.SetVisibleDensity(density); |
---|
573 | } |
---|
574 | else { |
---|
575 | density = vp.GetVisibleDensity(); |
---|
576 | } |
---|
577 | if (verbosity >= G4VisManager::confirmations) { |
---|
578 | G4cout << |
---|
579 | "G4VisCommandsViewerSet::SetNewValue: culling: culling by density" |
---|
580 | "\n flag set to " << G4UIcommand::ConvertToString(boolFlag) << |
---|
581 | ". Volumes with density less than " << |
---|
582 | G4BestUnit(density,"Volumic Mass") << |
---|
583 | "\n will be culled, i.e., not drawn, if this flag is true." |
---|
584 | << G4endl; |
---|
585 | } |
---|
586 | } |
---|
587 | else { |
---|
588 | if (verbosity >= G4VisManager::errors) { |
---|
589 | G4cout << |
---|
590 | "ERROR: G4VisCommandsViewerSet::SetNewValue: culling:" |
---|
591 | "\n option not recognised." |
---|
592 | << G4endl; |
---|
593 | } |
---|
594 | } |
---|
595 | } |
---|
596 | |
---|
597 | else if (command == fpCommandCutawayMode) { |
---|
598 | if (newValue == "add" || newValue == "union") |
---|
599 | vp.SetCutawayMode(G4ViewParameters::cutawayUnion); |
---|
600 | if (newValue == "multiply" || newValue == "intersection") |
---|
601 | vp.SetCutawayMode(G4ViewParameters::cutawayIntersection); |
---|
602 | |
---|
603 | if (verbosity >= G4VisManager::confirmations) { |
---|
604 | G4cout << "Cutaway mode set to "; |
---|
605 | if (vp.GetCutawayMode() == G4ViewParameters::cutawayUnion) |
---|
606 | G4cout << "cutawayUnion"; |
---|
607 | if (vp.GetCutawayMode() == G4ViewParameters::cutawayIntersection) |
---|
608 | G4cout << "cutawayIntersection"; |
---|
609 | G4cout << G4endl; |
---|
610 | } |
---|
611 | } |
---|
612 | |
---|
613 | else if (command == fpCommandEdge) { |
---|
614 | G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle(); |
---|
615 | if (G4UIcommand::ConvertToBool(newValue)) { |
---|
616 | switch (existingStyle) { |
---|
617 | case G4ViewParameters::wireframe: |
---|
618 | break; |
---|
619 | case G4ViewParameters::hlr: |
---|
620 | break; |
---|
621 | case G4ViewParameters::hsr: |
---|
622 | vp.SetDrawingStyle(G4ViewParameters::hlhsr); |
---|
623 | break; |
---|
624 | case G4ViewParameters::hlhsr: |
---|
625 | break; |
---|
626 | } |
---|
627 | } |
---|
628 | else { |
---|
629 | switch (existingStyle) { |
---|
630 | case G4ViewParameters::wireframe: |
---|
631 | break; |
---|
632 | case G4ViewParameters::hlr: |
---|
633 | break; |
---|
634 | case G4ViewParameters::hsr: |
---|
635 | break; |
---|
636 | case G4ViewParameters::hlhsr: |
---|
637 | vp.SetDrawingStyle(G4ViewParameters::hsr); |
---|
638 | break; |
---|
639 | } |
---|
640 | } |
---|
641 | if (verbosity >= G4VisManager::confirmations) { |
---|
642 | G4cout << "Drawing style of viewer \"" << currentViewer->GetName() |
---|
643 | << "\" set to " << vp.GetDrawingStyle() |
---|
644 | << G4endl; |
---|
645 | } |
---|
646 | } |
---|
647 | |
---|
648 | else if (command == fpCommandExplodeFactor) { |
---|
649 | G4double explodeFactor, x, y, z; |
---|
650 | G4String unitString; |
---|
651 | std::istringstream is (newValue); |
---|
652 | is >> explodeFactor >> x >> y >> z >> unitString; |
---|
653 | G4double unit = G4UIcommand::ValueOf(unitString); |
---|
654 | vp.SetExplodeFactor(explodeFactor); |
---|
655 | vp.SetExplodeCentre(G4Point3D(x * unit, y * unit, z * unit)); |
---|
656 | if (verbosity >= G4VisManager::confirmations) { |
---|
657 | G4cout << "Explode factor changed to " << vp.GetExplodeFactor() |
---|
658 | << " from centre " << vp.GetExplodeCentre() |
---|
659 | << G4endl; |
---|
660 | } |
---|
661 | } |
---|
662 | |
---|
663 | else if (command == fpCommandGlobalLineWidthScale) { |
---|
664 | G4double globalLineWidthScale |
---|
665 | = fpCommandGlobalLineWidthScale->GetNewDoubleValue(newValue); |
---|
666 | vp.SetGlobalLineWidthScale(globalLineWidthScale); |
---|
667 | if (verbosity >= G4VisManager::confirmations) { |
---|
668 | G4cout << "Global Line Width Scale changed to " |
---|
669 | << vp.GetGlobalLineWidthScale() << G4endl; |
---|
670 | } |
---|
671 | } |
---|
672 | |
---|
673 | else if (command == fpCommandGlobalMarkerScale) { |
---|
674 | G4double globalMarkerScale |
---|
675 | = fpCommandGlobalMarkerScale->GetNewDoubleValue(newValue); |
---|
676 | vp.SetGlobalMarkerScale(globalMarkerScale); |
---|
677 | if (verbosity >= G4VisManager::confirmations) { |
---|
678 | G4cout << "Global Marker Scale changed to " |
---|
679 | << vp.GetGlobalMarkerScale() << G4endl; |
---|
680 | } |
---|
681 | } |
---|
682 | |
---|
683 | else if (command == fpCommandHiddenEdge) { |
---|
684 | G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle(); |
---|
685 | if (G4UIcommand::ConvertToBool(newValue)) { |
---|
686 | switch (existingStyle) { |
---|
687 | case G4ViewParameters::wireframe: |
---|
688 | vp.SetDrawingStyle(G4ViewParameters::hlr); |
---|
689 | break; |
---|
690 | case G4ViewParameters::hlr: |
---|
691 | break; |
---|
692 | case G4ViewParameters::hsr: |
---|
693 | vp.SetDrawingStyle(G4ViewParameters::hlhsr); |
---|
694 | break; |
---|
695 | case G4ViewParameters::hlhsr: |
---|
696 | break; |
---|
697 | } |
---|
698 | } |
---|
699 | else { |
---|
700 | switch (existingStyle) { |
---|
701 | case G4ViewParameters::wireframe: |
---|
702 | break; |
---|
703 | case G4ViewParameters::hlr: |
---|
704 | vp.SetDrawingStyle(G4ViewParameters::wireframe); |
---|
705 | break; |
---|
706 | case G4ViewParameters::hsr: |
---|
707 | break; |
---|
708 | case G4ViewParameters::hlhsr: |
---|
709 | vp.SetDrawingStyle(G4ViewParameters::hsr); |
---|
710 | break; |
---|
711 | } |
---|
712 | } |
---|
713 | if (verbosity >= G4VisManager::confirmations) { |
---|
714 | G4cout << "Drawing style of viewer \"" << currentViewer->GetName() |
---|
715 | << "\" set to " << vp.GetDrawingStyle() |
---|
716 | << G4endl; |
---|
717 | } |
---|
718 | } |
---|
719 | |
---|
720 | else if (command == fpCommandHiddenMarker) { |
---|
721 | G4bool hidden = G4UIcommand::ConvertToBool(newValue); |
---|
722 | if (hidden) vp.SetMarkerHidden(); |
---|
723 | else vp.SetMarkerNotHidden(); |
---|
724 | if (verbosity >= G4VisManager::confirmations) { |
---|
725 | G4cout << "Markers will "; |
---|
726 | if (vp.IsMarkerNotHidden()) G4cout << "not "; |
---|
727 | G4cout << "be hidden under solid objects." << G4endl; |
---|
728 | } |
---|
729 | } |
---|
730 | |
---|
731 | else if (command == fpCommandLightsMove) { |
---|
732 | G4String s (newValue); |
---|
733 | if (s.find("cam") != G4String::npos) vp.SetLightsMoveWithCamera(true); |
---|
734 | else if(s.find("obj") != G4String::npos) vp.SetLightsMoveWithCamera(false); |
---|
735 | else { |
---|
736 | if (verbosity >= G4VisManager::errors) { |
---|
737 | G4cout << "ERROR: \"" << newValue << "\" not recognised." |
---|
738 | " Looking for \"cam\" or \"obj\" in string." << G4endl; |
---|
739 | } |
---|
740 | } |
---|
741 | if (verbosity >= G4VisManager::confirmations) { |
---|
742 | G4cout << "Lights move with "; |
---|
743 | if (vp.GetLightsMoveWithCamera()) |
---|
744 | G4cout << "camera (object appears to rotate)."; |
---|
745 | else G4cout << "object (the viewer appears to be moving)."; |
---|
746 | G4cout << G4endl; |
---|
747 | } |
---|
748 | } |
---|
749 | |
---|
750 | else if (command == fpCommandLightsThetaPhi) { |
---|
751 | G4double theta, phi; |
---|
752 | ConvertToDoublePair(newValue, theta, phi); |
---|
753 | G4double x = std::sin (theta) * std::cos (phi); |
---|
754 | G4double y = std::sin (theta) * std::sin (phi); |
---|
755 | G4double z = std::cos (theta); |
---|
756 | fLightsVector = G4ThreeVector (x, y, z); |
---|
757 | vp.SetLightpointDirection(fLightsVector); |
---|
758 | if (verbosity >= G4VisManager::confirmations) { |
---|
759 | G4cout << "Lights direction set to " |
---|
760 | << vp.GetLightpointDirection() << G4endl; |
---|
761 | } |
---|
762 | } |
---|
763 | |
---|
764 | else if (command == fpCommandLightsVector) { |
---|
765 | fLightsVector = G4UIcommand::ConvertTo3Vector(newValue); |
---|
766 | vp.SetLightpointDirection(fLightsVector); |
---|
767 | if (verbosity >= G4VisManager::confirmations) { |
---|
768 | G4cout << "Lights direction set to " |
---|
769 | << vp.GetLightpointDirection() << G4endl; |
---|
770 | } |
---|
771 | } |
---|
772 | |
---|
773 | else if (command == fpCommandLineSegments) { |
---|
774 | G4int nSides = G4UIcommand::ConvertToInt(newValue); |
---|
775 | nSides = vp.SetNoOfSides(nSides); |
---|
776 | if (verbosity >= G4VisManager::confirmations) { |
---|
777 | G4cout << |
---|
778 | "Number of line segements per circle in polygon approximation is " |
---|
779 | << nSides << G4endl; |
---|
780 | } |
---|
781 | } |
---|
782 | |
---|
783 | else if (command == fpCommandPicking) { |
---|
784 | vp.SetPicking(G4UIcommand::ConvertToBool(newValue)); |
---|
785 | if (verbosity >= G4VisManager::confirmations) { |
---|
786 | G4cout << "Picking "; |
---|
787 | if (vp.IsPicking()) G4cout << "requested."; |
---|
788 | else G4cout << "inhibited."; |
---|
789 | G4cout << G4endl; |
---|
790 | } |
---|
791 | } |
---|
792 | |
---|
793 | else if (command == fpCommandProjection) { |
---|
794 | G4double fieldHalfAngle; |
---|
795 | const size_t iPos0 = 0; |
---|
796 | if (newValue[iPos0] == 'o') { // "orthogonal" |
---|
797 | fieldHalfAngle = 0.; |
---|
798 | } |
---|
799 | else if (newValue[iPos0] == 'p') { // "perspective" |
---|
800 | G4String dummy; |
---|
801 | G4String unit; |
---|
802 | std::istringstream is (newValue); |
---|
803 | is >> dummy >> fieldHalfAngle >> unit; |
---|
804 | fieldHalfAngle *= G4UIcommand::ValueOf(unit); |
---|
805 | if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) { |
---|
806 | if (verbosity >= G4VisManager::errors) { |
---|
807 | G4cout << |
---|
808 | "ERROR: Field half angle should be 0 < angle <= 89.5 degrees."; |
---|
809 | G4cout << G4endl; |
---|
810 | } |
---|
811 | return; |
---|
812 | } |
---|
813 | } |
---|
814 | else { |
---|
815 | if (verbosity >= G4VisManager::errors) { |
---|
816 | G4cout << "ERROR: \"" << newValue << "\" not recognised." |
---|
817 | " Looking for 'o' or 'p' first character." << G4endl; |
---|
818 | } |
---|
819 | return; |
---|
820 | } |
---|
821 | vp.SetFieldHalfAngle(fieldHalfAngle); |
---|
822 | if (verbosity >= G4VisManager::confirmations) { |
---|
823 | G4cout << "Projection style of viewer \"" << currentViewer->GetName() |
---|
824 | << "\" set to "; |
---|
825 | if (fieldHalfAngle == 0.) { |
---|
826 | G4cout << "orthogonal."; |
---|
827 | } |
---|
828 | else { |
---|
829 | G4cout << "perspective\n with half angle " << fieldHalfAngle / deg |
---|
830 | << " degrees."; |
---|
831 | } |
---|
832 | G4cout << G4endl; |
---|
833 | } |
---|
834 | } |
---|
835 | |
---|
836 | else if (command == fpCommandSectionPlane) { |
---|
837 | G4String choice, unit; |
---|
838 | G4double x, y, z, nx, ny, nz; |
---|
839 | std::istringstream is (newValue); |
---|
840 | is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz; |
---|
841 | |
---|
842 | G4int iSelector = -1; |
---|
843 | if (choice.compareTo("off",G4String::ignoreCase) == 0 || |
---|
844 | !G4UIcommand::ConvertToBool(choice)) iSelector = 0; |
---|
845 | if (choice.compareTo("on",G4String::ignoreCase) == 0 || |
---|
846 | G4UIcommand::ConvertToBool(choice)) iSelector = 1; |
---|
847 | if (iSelector < 0) { |
---|
848 | if (verbosity >= G4VisManager::errors) { |
---|
849 | G4cout << "Choice not recognised (on/true or off/false)." << G4endl; |
---|
850 | G4cout << "Section drawing is currently: "; |
---|
851 | if (vp.IsSection ()) G4cout << "on"; |
---|
852 | else G4cout << "off"; |
---|
853 | G4cout << ".\nSection plane is currently: " |
---|
854 | << vp.GetSectionPlane (); |
---|
855 | G4cout << G4endl; |
---|
856 | } |
---|
857 | return; |
---|
858 | } |
---|
859 | |
---|
860 | G4double F = 1.; |
---|
861 | switch (iSelector) { |
---|
862 | default: |
---|
863 | case 0: |
---|
864 | vp.UnsetSectionPlane(); |
---|
865 | break; |
---|
866 | case 1: |
---|
867 | F = G4UIcommand::ValueOf(unit); |
---|
868 | x *= F; y *= F; z *= F; |
---|
869 | vp.SetSectionPlane(G4Plane3D(G4Normal3D(nx,ny,nz), G4Point3D(x,y,z))); |
---|
870 | vp.SetViewpointDirection(G4Normal3D(nx,ny,nz)); |
---|
871 | break; |
---|
872 | } |
---|
873 | |
---|
874 | if (verbosity >= G4VisManager::confirmations) { |
---|
875 | G4cout << "Section drawing is now: "; |
---|
876 | if (vp.IsSection ()) G4cout << "on"; |
---|
877 | else G4cout << "off"; |
---|
878 | G4cout << ".\nSection plane is now: " |
---|
879 | << vp.GetSectionPlane (); |
---|
880 | G4cout << G4endl; |
---|
881 | } |
---|
882 | } |
---|
883 | |
---|
884 | else if (command == fpCommandStyle) { |
---|
885 | G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle(); |
---|
886 | const size_t iPos0 = 0; |
---|
887 | if (newValue[iPos0] == 'w') { // "wireframe" |
---|
888 | switch (existingStyle) { |
---|
889 | case G4ViewParameters::wireframe: |
---|
890 | break; |
---|
891 | case G4ViewParameters::hlr: |
---|
892 | break; |
---|
893 | case G4ViewParameters::hsr: |
---|
894 | vp.SetDrawingStyle(G4ViewParameters::wireframe); |
---|
895 | break; |
---|
896 | case G4ViewParameters::hlhsr: |
---|
897 | vp.SetDrawingStyle(G4ViewParameters::hlr); |
---|
898 | break; |
---|
899 | } |
---|
900 | } |
---|
901 | else if (newValue[iPos0] == 's') { // "surface" |
---|
902 | switch (existingStyle) { |
---|
903 | case G4ViewParameters::wireframe: |
---|
904 | vp.SetDrawingStyle(G4ViewParameters::hsr); |
---|
905 | break; |
---|
906 | case G4ViewParameters::hlr: |
---|
907 | vp.SetDrawingStyle(G4ViewParameters::hlhsr); |
---|
908 | break; |
---|
909 | case G4ViewParameters::hsr: |
---|
910 | break; |
---|
911 | case G4ViewParameters::hlhsr: |
---|
912 | break; |
---|
913 | } |
---|
914 | } |
---|
915 | else { |
---|
916 | if (verbosity >= G4VisManager::errors) { |
---|
917 | G4cout << "ERROR: \"" << newValue << "\" not recognised." |
---|
918 | " Looking for 'w' or 's' first character." << G4endl; |
---|
919 | } |
---|
920 | return; |
---|
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 == fpCommandTargetPoint) { |
---|
930 | G4ThreeVector targetPoint = |
---|
931 | fpCommandTargetPoint->GetNew3VectorValue(newValue); |
---|
932 | const G4Point3D& standardTargetPoint = |
---|
933 | currentViewer->GetSceneHandler()->GetScene()->GetStandardTargetPoint(); |
---|
934 | vp.SetCurrentTargetPoint(targetPoint - standardTargetPoint); |
---|
935 | if (verbosity >= G4VisManager::confirmations) { |
---|
936 | G4cout << "Target point set to " |
---|
937 | << fpCommandTargetPoint->ConvertToStringWithBestUnit |
---|
938 | (targetPoint) |
---|
939 | << "\n\"Current Target Point\" set to " |
---|
940 | << fpCommandTargetPoint->ConvertToStringWithBestUnit |
---|
941 | (vp.GetCurrentTargetPoint()) |
---|
942 | << "\n\"Standard Target Point\" is " |
---|
943 | << fpCommandTargetPoint->ConvertToStringWithBestUnit |
---|
944 | (standardTargetPoint) |
---|
945 | << G4endl; |
---|
946 | } |
---|
947 | } |
---|
948 | |
---|
949 | else if (command == fpCommandUpThetaPhi) { |
---|
950 | G4double theta, phi; |
---|
951 | ConvertToDoublePair(newValue, theta, phi); |
---|
952 | G4double x = std::sin (theta) * std::cos (phi); |
---|
953 | G4double y = std::sin (theta) * std::sin (phi); |
---|
954 | G4double z = std::cos (theta); |
---|
955 | fUpVector = G4ThreeVector (x, y, z); |
---|
956 | vp.SetUpVector(fUpVector); |
---|
957 | if (verbosity >= G4VisManager::confirmations) { |
---|
958 | G4cout << "Up direction set to " << vp.GetUpVector() << G4endl; |
---|
959 | } |
---|
960 | } |
---|
961 | |
---|
962 | else if (command == fpCommandUpVector) { |
---|
963 | fUpVector = G4UIcommand::ConvertTo3Vector(newValue).unit(); |
---|
964 | vp.SetUpVector(fUpVector); |
---|
965 | if (verbosity >= G4VisManager::confirmations) { |
---|
966 | G4cout << "Up direction set to " << vp.GetUpVector() << G4endl; |
---|
967 | } |
---|
968 | } |
---|
969 | |
---|
970 | else if (command == fpCommandViewpointThetaPhi) { |
---|
971 | G4double theta, phi; |
---|
972 | ConvertToDoublePair(newValue, theta, phi); |
---|
973 | G4double x = std::sin (theta) * std::cos (phi); |
---|
974 | G4double y = std::sin (theta) * std::sin (phi); |
---|
975 | G4double z = std::cos (theta); |
---|
976 | fViewpointVector = G4ThreeVector (x, y, z); |
---|
977 | vp.SetViewAndLights(fViewpointVector); |
---|
978 | if (verbosity >= G4VisManager::confirmations) { |
---|
979 | G4cout << "Viewpoint direction set to " |
---|
980 | << vp.GetViewpointDirection() << G4endl; |
---|
981 | if (vp.GetLightsMoveWithCamera ()) { |
---|
982 | G4cout << "Lightpoint direction set to " |
---|
983 | << vp.GetActualLightpointDirection () << G4endl; |
---|
984 | } |
---|
985 | } |
---|
986 | } |
---|
987 | |
---|
988 | else if (command == fpCommandViewpointVector) { |
---|
989 | fViewpointVector = G4UIcommand::ConvertTo3Vector(newValue).unit(); |
---|
990 | vp.SetViewAndLights(fViewpointVector); |
---|
991 | if (verbosity >= G4VisManager::confirmations) { |
---|
992 | G4cout << "Viewpoint direction set to " |
---|
993 | << vp.GetViewpointDirection() << G4endl; |
---|
994 | if (vp.GetLightsMoveWithCamera ()) { |
---|
995 | G4cout << "Lightpoint direction set to " |
---|
996 | << vp.GetActualLightpointDirection () << G4endl; |
---|
997 | } |
---|
998 | } |
---|
999 | } |
---|
1000 | |
---|
1001 | else { |
---|
1002 | if (verbosity >= G4VisManager::errors) { |
---|
1003 | G4cout << |
---|
1004 | "ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command." |
---|
1005 | << G4endl; |
---|
1006 | } |
---|
1007 | return; |
---|
1008 | } |
---|
1009 | |
---|
1010 | SetViewParameters(currentViewer,vp); |
---|
1011 | } |
---|