Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLViewerMessenger.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#ifdef G4VIS_BUILD_OPENGL_DRIVER
29
31
32#include "G4OpenGLViewer.hh"
35#include "G4UImanager.hh"
36#include "G4UIcommand.hh"
37#include "G4UIdirectory.hh"
39#include "G4UIcmdWithADouble.hh"
40#include "G4UIcmdWithABool.hh"
41#include "G4UIcmdWithAString.hh"
43#include "G4VisManager.hh"
44#include <sstream>
45
47G4OpenGLViewerMessenger::fpInstance = 0;
48
51{
52 if (!fpInstance) fpInstance = new G4OpenGLViewerMessenger;
53 return fpInstance;
54}
55
56G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
57{
58 G4bool omitable;
59
60 fpDirectory = new G4UIdirectory("/vis/ogl/");
61 fpDirectory->SetGuidance("G4OpenGLViewer commands.");
62
63 fpCommandExport =
64 new G4UIcommand("/vis/ogl/export", this);
65 fpCommandExport->SetGuidance ("Export a screenshot of current OpenGL viewer");
66 fpCommandExport->SetGuidance
67 ("If name is \"\", filename and extension will have the current value");
68 fpCommandExport->SetGuidance
69 ("If name is \"toto.png\", set the name to \"toto\" and the format to \"png\".");
70 fpCommandExport->SetGuidance
71 ("If name is \"toto\", set the name to \"toto\" and the format to current format.");
72 fpCommandExport->SetGuidance
73 ("Will also add an incremented suffix at the end of the name, except if name is"
74 "\nthe same as previous it will not reset the incremented suffix.");
75 fpCommandExport->SetGuidance
76 ("Setting size is available only on eps/pdf/svg/ps formats.");
77 G4UIparameter* parameterExport;
78 parameterExport = new G4UIparameter ("name", 's', omitable = true);
79 parameterExport->SetDefaultValue("!");
80 parameterExport->SetGuidance
81 ("By default, will take a default value or the last \"/vis/ogl/set/printFilename\""
82 " value if set.");
83 fpCommandExport->SetParameter(parameterExport);
84 parameterExport = new G4UIparameter ("width", 'd', omitable = true);
85 parameterExport->SetGuidance
86 ("By default, will take the current width of the viewer or \"/vis/ogl/set/printSize\""
87 "\nif set. This parameter is only useful for eps/pdf/svg/ps formats !");
88 parameterExport->SetDefaultValue(-1);
89 fpCommandExport->SetParameter(parameterExport);
90 parameterExport = new G4UIparameter ("height", 'd', omitable = true);
91 parameterExport->SetGuidance
92 ("By default, will take the current height of the viewer or \"/vis/ogl/set/printSize\""
93 "\nif set. This parameter is only useful for eps/pdf/svg/ps formats !");
94 parameterExport->SetDefaultValue(-1);
95 fpCommandExport->SetParameter(parameterExport);
96
97 fpCommandFlushAt = new G4UIcommand("/vis/ogl/flushAt", this);
98 fpCommandFlushAt->SetGuidance
99 ("Controls the rate at which graphics primitives are flushed to screen.");
100 fpCommandFlushAt->SetGuidance
101 ("Flushing to screen is an expensive operation so to speed drawing choose"
102 "\nan action suitable for your application. Note that detectors are flushed"
103 "\nto screen anyway at end of drawing, and events are flushed to screen"
104 "\nanyway depending on /vis/scene/endOfEventAction and endOfRunAction.");
105 fpCommandFlushAt->SetGuidance
106 ("For NthPrimitive and NthEvent the second parameter N is operative.");
107 fpCommandFlushAt->SetGuidance
108 ("For \"never\", detectors and events are still flushed as described above.");
109 G4UIparameter* parameterFlushAt;
110 parameterFlushAt = new G4UIparameter ("action", 's', omitable = true);
111 parameterFlushAt->SetParameterCandidates
112 ("endOfEvent endOfRun eachPrimitive NthPrimitive NthEvent never");
113 parameterFlushAt->SetDefaultValue("NthEvent");
114 fpCommandFlushAt->SetParameter(parameterFlushAt);
115 parameterFlushAt = new G4UIparameter ("N", 'i', omitable = true);
116 parameterFlushAt->SetDefaultValue(100);
117 fpCommandFlushAt->SetParameter(parameterFlushAt);
118
119 fpCommandPrintEPS =
120 new G4UIcmdWithoutParameter("/vis/ogl/printEPS", this);
121 fpCommandPrintEPS->SetGuidance("Print Encapsulated PostScript file.");
122 fpCommandPrintEPS->SetGuidance
123 ("See \"/vis/ogl/export\" for other file formats.");
124 fpCommandPrintEPS->SetGuidance
125 ("Generates files with names G4OpenGL_viewer-name_nnnn.eps, where nnnn is a"
126 "\nsequence number, starting at 0000."
127 "\nCan be \"vectored\" or \"pixmap\" - see \"/vis/ogl/set/printMode\".");
128
129 fpDirectorySet = new G4UIdirectory ("/vis/ogl/set/");
130 fpDirectorySet->SetGuidance("G4OpenGLViewer set commands.");
131
132 G4UIparameter* parameter;
133
134 fpCommandDisplayHeadTime =
135 new G4UIcommand("/vis/ogl/set/displayHeadTime", this);
136 fpCommandDisplayHeadTime->SetGuidance
137 ("DEPRECATED. Use /vis/viewer/set/timeWindow/displayHeadTime."
138 "\n Display head time of range in 2D text.");
139 parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false);
140 parameter->SetDefaultValue(false);
141 fpCommandDisplayHeadTime->SetParameter(parameter);
142 parameter = new G4UIparameter ("screenX", 'd', omitable = true);
143 parameter->SetGuidance("-1 < screenX < 1");
144 parameter->SetParameterRange("screenX >= -1. && screenX <= 1.");
145 parameter->SetDefaultValue(-0.9);
146 fpCommandDisplayHeadTime->SetParameter(parameter);
147 parameter = new G4UIparameter ("screenY", 'd', omitable = true);
148 parameter->SetGuidance("-1 < screenY < 1");
149 parameter->SetParameterRange("screenY >= -1. && screenY <= 1.");
150 parameter->SetDefaultValue(-0.9);
151 fpCommandDisplayHeadTime->SetParameter(parameter);
152 parameter = new G4UIparameter ("screenSize", 'd', omitable = true);
153 parameter->SetDefaultValue(24.);
154 fpCommandDisplayHeadTime->SetParameter(parameter);
155 parameter = new G4UIparameter ("red", 'd', omitable = true);
156 parameter->SetParameterRange("red >= 0. && red <= 1.");
157 parameter->SetDefaultValue(0.);
158 fpCommandDisplayHeadTime->SetParameter(parameter);
159 parameter = new G4UIparameter ("green", 'd', omitable = true);
160 parameter->SetParameterRange("green >= 0. && green <= 1.");
161 parameter->SetDefaultValue(1.);
162 fpCommandDisplayHeadTime->SetParameter(parameter);
163 parameter = new G4UIparameter ("blue", 'd', omitable = true);
164 parameter->SetParameterRange("blue >= 0. && blue <= 1.");
165 parameter->SetDefaultValue(1.);
166 fpCommandDisplayHeadTime->SetParameter(parameter);
167
168 fpCommandDisplayLightFront =
169 new G4UIcommand("/vis/ogl/set/displayLightFront", this);
170 fpCommandDisplayLightFront->SetGuidance
171 ("DEPRECATED. Use /vis/viewer/set/timeWindow/displayLightFront."
172 "\n Display the light front at head time.");
173 fpCommandDisplayLightFront->SetGuidance
174 ("Tip: The trajectories can appear of jump ahead of the light front"
175 "\nbecause their time range overlaps the viewer's time range. To"
176 "\naverage out this discrete time effect, advance the light front by"
177 "\nhalf the trajectories interval. E.g., if the trajectory time slice"
178 "\ninterval is 0.01 ns:"
179 "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.005 ns"
180 "\nTo prevent them beating the light front at all:"
181 "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.01 ns");
182 parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false);
183 parameter->SetDefaultValue(false);
184 fpCommandDisplayLightFront->SetParameter(parameter);
185 parameter = new G4UIparameter ("originX", 'd', omitable = true);
186 parameter->SetDefaultValue(0.);
187 fpCommandDisplayLightFront->SetParameter(parameter);
188 parameter = new G4UIparameter ("originY", 'd', omitable = true);
189 parameter->SetDefaultValue(0.);
190 fpCommandDisplayLightFront->SetParameter(parameter);
191 parameter = new G4UIparameter ("originZ", 'd', omitable = true);
192 parameter->SetDefaultValue(0.);
193 fpCommandDisplayLightFront->SetParameter(parameter);
194 parameter = new G4UIparameter ("space_unit", 's', omitable = true);
195 parameter->SetDefaultValue("m");
196 fpCommandDisplayLightFront->SetParameter(parameter);
197 parameter = new G4UIparameter ("originT", 'd', omitable = true);
198 parameter->SetDefaultValue(0.);
199 fpCommandDisplayLightFront->SetParameter(parameter);
200 parameter = new G4UIparameter ("time_unit", 's', omitable = true);
201 parameter->SetDefaultValue("s");
202 fpCommandDisplayLightFront->SetParameter(parameter);
203 parameter = new G4UIparameter ("red", 'd', omitable = true);
204 parameter->SetParameterRange("red >= 0. && red <= 1.");
205 parameter->SetDefaultValue(0.);
206 fpCommandDisplayLightFront->SetParameter(parameter);
207 parameter = new G4UIparameter ("green", 'd', omitable = true);
208 parameter->SetParameterRange("green >= 0. && green <= 1.");
209 parameter->SetDefaultValue(1.);
210 fpCommandDisplayLightFront->SetParameter(parameter);
211 parameter = new G4UIparameter ("blue", 'd', omitable = true);
212 parameter->SetParameterRange("blue >= 0. && blue <= 1.");
213 parameter->SetDefaultValue(0.);
214 fpCommandDisplayLightFront->SetParameter(parameter);
215
216 fpCommandDisplayListLimit =
217 new G4UIcmdWithAnInteger("/vis/ogl/set/displayListLimit", this);
218 fpCommandDisplayListLimit->SetGuidance
219 ("Set/reset display list number of primitive limit (to avoid memory exhaustion).");
220 fpCommandDisplayListLimit->SetParameterName("limit", omitable = true);
221 fpCommandDisplayListLimit->SetDefaultValue(50000);
222 fpCommandDisplayListLimit->SetRange("limit>=10000");
223
224 fpCommandEndTime =
225 new G4UIcommand("/vis/ogl/set/endTime", this);
226 fpCommandEndTime->SetGuidance
227 ("DEPRECATED. Use /vis/viewer/set/timeWindow/endTime."
228 "\n Set end and range of time window.");
229 parameter = new G4UIparameter ("end-time", 'd', omitable = false);
231 fpCommandEndTime->SetParameter(parameter);
232 parameter = new G4UIparameter ("end-time-unit", 's', omitable = false);
233 parameter->SetDefaultValue("ns");
234 fpCommandEndTime->SetParameter(parameter);
235 parameter = new G4UIparameter ("time-range", 'd', omitable = true);
236 parameter->SetDefaultValue(-1.);
237 fpCommandEndTime->SetParameter(parameter);
238 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
239 parameter->SetDefaultValue("ns");
240 fpCommandEndTime->SetParameter(parameter);
241
242 fpCommandEventsDrawInterval =
243 new G4UIcmdWithAnInteger("/vis/ogl/set/eventsDrawInterval", this);
244 fpCommandEventsDrawInterval->SetGuidance
245 ("Deprecated. Use /vis/ogl/flushAt.");
246 fpCommandEventsDrawInterval->SetGuidance
247 ("(This is equivalent to \"/vis/ogl/flushAt NthPrimitive N\"");
248 fpCommandEventsDrawInterval->SetParameterName("N", omitable = true);
249 fpCommandEventsDrawInterval->SetDefaultValue(1);
250
251 fpCommandExportFormat =
252 new G4UIcommand("/vis/ogl/set/exportFormat", this);
253 fpCommandExportFormat->SetGuidance ("Set export format");
254 fpCommandExportFormat->SetGuidance ("By default, pdf/eps/svg/ps are available. Depending of viewers several other format are available.");
255 fpCommandExportFormat->SetGuidance ("Try /vis/ogl/set/exportFormat without parameters to see them.");
256 fpCommandExportFormat->SetGuidance ("Changing format will reset the incremental suffix to 0.");
257 G4UIparameter* parameterExportFormat;
258 parameterExportFormat = new G4UIparameter ("format", 's', omitable = true);
259 parameterExportFormat->SetDefaultValue("");
260 fpCommandExportFormat->SetParameter(parameterExportFormat);
261
262 fpCommandFade = new G4UIcmdWithADouble("/vis/ogl/set/fade", this);
263 fpCommandFade->SetGuidance
264 ("DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
265 "\n 0: no fade; 1: maximum fade with time within range.");
266 fpCommandFade->SetParameterName("fadefactor", omitable = false);
267 fpCommandFade->SetRange("fadefactor>=0.&&fadefactor<=1.");
268 fpCommandFade->SetDefaultValue(0.);
269
270 fpCommandPrintFilename =
271 new G4UIcommand("/vis/ogl/set/printFilename", this);
272 fpCommandPrintFilename->SetGuidance ("Set print filename");
273 fpCommandPrintFilename->SetGuidance ("Setting 'incremental' will increment filename by one at each new print, starting at 0");
274 G4UIparameter* parameterPrintFilename;
275 parameterPrintFilename = new G4UIparameter ("name", 's', omitable = true);
276 parameterPrintFilename->SetDefaultValue("G4OpenGL");
277 fpCommandPrintFilename->SetParameter(parameterPrintFilename);
278 parameterPrintFilename = new G4UIparameter ("incremental", 'b', omitable = true);
279 parameterPrintFilename->SetDefaultValue(1);
280 fpCommandPrintFilename->SetParameter(parameterPrintFilename);
281
282 fpCommandPrintMode = new G4UIcmdWithAString("/vis/ogl/set/printMode",this);
283 fpCommandPrintMode->SetGuidance("Set print mode, only available for \"ps\" format");
284 fpCommandPrintMode->SetParameterName("print_mode",omitable = true);
285 fpCommandPrintMode->SetCandidates("vectored pixmap");
286 fpCommandPrintMode->SetDefaultValue("vectored");
287
288 fpCommandPrintSize =
289 new G4UIcommand("/vis/ogl/set/printSize", this);
290 fpCommandPrintSize->SetGuidance ("Set print size");
291 fpCommandPrintSize->SetGuidance ("Tip : -1 will mean 'print size' = 'window size'");
292 fpCommandPrintSize->SetGuidance (" Setting size greater than your maximum graphic card capacity , will set the size to maximum size.");
293 G4UIparameter* parameterPrintSize;
294 parameterPrintSize = new G4UIparameter ("width", 'd', omitable = false);
295 parameterPrintSize->SetDefaultValue(-1);
296 fpCommandPrintSize->SetParameter(parameterPrintSize);
297 parameterPrintSize = new G4UIparameter ("height", 'd', omitable = false);
298 parameterPrintSize->SetDefaultValue(-1);
299 fpCommandPrintSize->SetParameter(parameterPrintSize);
300
301 fpCommandStartTime =
302 new G4UIcommand("/vis/ogl/set/startTime", this);
303 fpCommandStartTime->SetGuidance
304 ("DEPRECATED. Use /vis/viewer/set/timeWindow/startTime."
305 "\n Set start and range of time window.");
306 parameter = new G4UIparameter ("start-time", 'd', omitable = false);
308 fpCommandStartTime->SetParameter(parameter);
309 parameter = new G4UIparameter ("start-time-unit", 's', omitable = false);
310 parameter->SetDefaultValue("ns");
311 fpCommandStartTime->SetParameter(parameter);
312 parameter = new G4UIparameter ("time-range", 'd', omitable = true);
313 parameter->SetDefaultValue(-1.);
314 fpCommandStartTime->SetParameter(parameter);
315 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
316 parameter->SetDefaultValue("ns");
317 fpCommandStartTime->SetParameter(parameter);
318
319 fpCommandTransparency =
320 new G4UIcmdWithABool("/vis/ogl/set/transparency", this);
321 fpCommandTransparency->SetGuidance
322 ("True/false to enable/disable rendering of transparent objects.");
323 fpCommandTransparency->SetParameterName
324 ("transparency-enabled", omitable = true);
325 fpCommandTransparency->SetDefaultValue(true);
326}
327
329{
330 delete fpCommandTransparency;
331 delete fpCommandStartTime;
332 delete fpCommandPrintSize;
333 delete fpCommandPrintMode;
334 delete fpCommandPrintFilename;
335 delete fpCommandFade;
336 delete fpCommandExportFormat;
337 delete fpCommandEventsDrawInterval;
338 delete fpCommandEndTime;
339 delete fpCommandDisplayListLimit;
340 delete fpCommandDisplayLightFront;
341 delete fpCommandDisplayHeadTime;
342 delete fpDirectorySet;
343 delete fpCommandPrintEPS;
344 delete fpCommandFlushAt;
345 delete fpCommandExport;
346 delete fpDirectory;
347
348 delete fpInstance;
349}
350
352(G4UIcommand* command, G4String newValue)
353{
355
356 G4VViewer* pViewer = pVisManager->GetCurrentViewer();
357 if (!pViewer) {
358 G4cout <<
359 "G4OpenGLViewerMessenger::SetNewValue: No current viewer."
360 "\n \"/vis/open\", or similar, to get one."
361 << G4endl;
362 return;
363 }
364
365 G4VSceneHandler* pSceneHandler = pViewer->GetSceneHandler();
366 if (!pSceneHandler) {
367 G4cout <<
368 "G4OpenGLViewerMessenger::SetNewValue: This viewer has no scene handler."
369 "\n Shouldn't happen - please report circumstances."
370 "\n (Viewer is \"" << pViewer->GetName() << "\".)"
371 "\n Try \"/vis/open\", or similar, to get one."
372 << G4endl;
373 return;
374 }
375
376 G4OpenGLViewer* pOGLViewer = dynamic_cast<G4OpenGLViewer*>(pViewer);
377 if (!pOGLViewer) {
378 G4cout <<
379 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type"
380 "\n OGL. (It is \""
381 << pViewer->GetName() <<
382 "\".)\n Use \"/vis/viewer/select\" or \"/vis/open\"."
383 << G4endl;
384 return;
385 }
386
387 G4OpenGLSceneHandler* pOGLSceneHandler =
388 dynamic_cast<G4OpenGLSceneHandler*>(pSceneHandler);
389 if (!pOGLSceneHandler) {
390 G4cout <<
391 "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type"
392 "\n OGL. (Viewer is \"" << pViewer->GetName() << "\".)"
393 "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)"
394 "\n Use \"/vis/sceneHandler/list\" and \"/vis/sceneHandler/select\""
395 "\n or \"/vis/open\"."
396 << G4endl;
397 return;
398 }
399
400 if (command == fpCommandExport)
401 {
403 G4int width,height;
404 std::istringstream iss(newValue);
405 iss >> name >> width >> height;
406 pOGLViewer->exportImage(name, width, height);
407
408 if (pOGLViewer->fVP.IsAutoRefresh())
409 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
410 return;
411 }
412
413 if (command == fpCommandExportFormat)
414 {
416 std::istringstream iss(newValue);
417 iss >> name;
418 pOGLViewer->setExportImageFormat(name);
419
420 return;
421 }
422
423 if (command == fpCommandEventsDrawInterval)
424 {
425 G4int entitiesFlushInterval =
426 fpCommandEventsDrawInterval->GetNewIntValue(newValue);
427 pOGLSceneHandler->SetFlushAction(G4OpenGLSceneHandler::NthPrimitive);
428 pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
429 return;
430 }
431
432 if (command == fpCommandFlushAt)
433 {
434 static G4bool firstTime = true;
435 static std::map<G4String,G4OpenGLSceneHandler::FlushAction> actionMap;
436 if (firstTime) {
437 actionMap["endOfEvent"] = G4OpenGLSceneHandler::endOfEvent;
438 actionMap["endOfRun"] = G4OpenGLSceneHandler::endOfRun;
439 actionMap["eachPrimitive"] = G4OpenGLSceneHandler::eachPrimitive;
440 actionMap["NthPrimitive"] = G4OpenGLSceneHandler::NthPrimitive;
441 actionMap["NthEvent"] = G4OpenGLSceneHandler::NthEvent;
442 actionMap["never"] = G4OpenGLSceneHandler::never;
443 firstTime = false;
444 }
445 G4String action;
446 G4int entitiesFlushInterval;
447 std::istringstream iss(newValue);
448 iss >> action >> entitiesFlushInterval;
449 pOGLSceneHandler->SetFlushAction(actionMap[action]);
450 pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
451 return;
452 }
453
454 if (command == fpCommandPrintEPS)
455 {
456 pOGLViewer->setExportImageFormat("eps",true);
457 pOGLViewer->exportImage();
458
459 if (pOGLViewer->fVP.IsAutoRefresh())
460 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
461 return;
462 }
463
464 if (command == fpCommandPrintFilename)
465 {
467 G4bool inc;
468 std::istringstream iss(newValue);
469 iss >> name
470 >> inc;
471 pOGLViewer->setExportFilename(name,inc);
472 return;
473 }
474
475 if (command == fpCommandPrintMode)
476 {
477 if (newValue == "vectored") pOGLViewer->fVectoredPs = true;
478
479 if (newValue == "pixmap") pOGLViewer->fVectoredPs = false;
480 return;
481 }
482
483 if (command == fpCommandPrintSize)
484 {
485 G4int width,height;
486 std::istringstream iss(newValue);
487 iss >> width
488 >> height;
489 pOGLViewer->setExportSize(width,height);
490 return;
491 }
492
493 if (command == fpCommandTransparency)
494 {
495 pOGLViewer->transparency_enabled = command->ConvertToBool(newValue);
496 if (pOGLViewer->fVP.IsAutoRefresh())
497 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
498 return;
499 }
500
501 // Stored viewer commands
502 G4OpenGLStoredViewer* pOGLSViewer =
503 dynamic_cast<G4OpenGLStoredViewer*>(pViewer);
504
505 if (!pOGLSViewer)
506 {
507 G4cout <<
508 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS."
509 "\n (It is \"" << pViewer->GetName() << "\".)"
510 "\n This feature is only implemented for OGL Stored viewers."
511 "\n Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
512 << G4endl;
513 return;
514 }
515
516 if (command == fpCommandDisplayHeadTime)
517 {
518 G4String display;
519 G4double screenX, screenY, screenSize, red, green, blue;
520 std::istringstream iss(newValue);
521 iss >> display >> screenX >> screenY
522 >> screenSize >> red >> green >> blue;
523 pOGLSViewer->fVP.SetDisplayHeadTime(command->ConvertToBool(display));
524 pOGLSViewer->fVP.SetDisplayHeadTimeX(screenX);
525 pOGLSViewer->fVP.SetDisplayHeadTimeY(screenY);
526 pOGLSViewer->fVP.SetDisplayHeadTimeSize(screenSize);
527 pOGLSViewer->fVP.SetDisplayHeadTimeRed(red);
528 pOGLSViewer->fVP.SetDisplayHeadTimeGreen(green);
529 pOGLSViewer->fVP.SetDisplayHeadTimeBlue(blue);
530 G4cout
531 << "DEPRECATED. Use /vis/viewer/set/timeWindow/displayHeadTime."
532 << G4endl;
533 return;
534 }
535
536 if (command == fpCommandDisplayLightFront)
537 {
538 G4String display, originX, originY, originZ, unitS, originT, unitT;
539 G4double red, green, blue;
540 std::istringstream iss(newValue);
541 iss >> display
542 >> originX >> originY >> originZ >> unitS
543 >> originT >> unitT
544 >> red >> green >> blue;
545 pOGLSViewer->fVP.SetDisplayLightFront(command->ConvertToBool(display));
546 pOGLSViewer->fVP.SetDisplayLightFrontX
547 (command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)));
548 pOGLSViewer->fVP.SetDisplayLightFrontY
549 (command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)));
550 pOGLSViewer->fVP.SetDisplayLightFrontZ
551 (command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)));
552 pOGLSViewer->fVP.SetDisplayLightFrontT
553 (command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)));
554 pOGLSViewer->fVP.SetDisplayLightFrontRed(red);
555 pOGLSViewer->fVP.SetDisplayLightFrontGreen(green);
556 pOGLSViewer->fVP.SetDisplayLightFrontBlue(blue);
557 G4cout
558 << "DEPRECATED. Use /vis/viewer/set/timeWindow/displayLightFront."
559 << G4endl;
560 return;
561 }
562
563 if (command == fpCommandEndTime)
564 {
565 G4String end_time_string, end_time_unit,
566 time_range_string, time_range_unit;
567 std::istringstream iss(newValue);
568 iss >> end_time_string >> end_time_unit
569 >> time_range_string >> time_range_unit;
570 pOGLSViewer->fVP.SetEndTime
572 (G4String(end_time_string + ' ' + end_time_unit)));
573 G4double timeRange = command->ConvertToDimensionedDouble
574 (G4String(time_range_string + ' ' + time_range_unit));
575 if (timeRange > 0.) {
576 pOGLSViewer->fVP.SetStartTime
577 (pOGLSViewer->fVP.GetEndTime() - timeRange);
578 }
579 if (pOGLSViewer->fVP.IsAutoRefresh())
580 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
581 G4cout
582 << "DEPRECATED. Use /vis/viewer/set/timeWindow/endTime."
583 << G4endl;
584 return;
585 }
586
587 if (command == fpCommandFade)
588 {
589 pOGLSViewer->fVP.SetFadeFactor(command->ConvertToDouble(newValue));
590 if (pOGLSViewer->fVP.IsAutoRefresh())
591 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
592 G4cout
593 << "DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
594 << G4endl;
595 return;
596 }
597
598 if (command == fpCommandStartTime)
599 {
600 G4String start_time_string, start_time_unit,
601 time_range_string, time_range_unit;
602 std::istringstream iss(newValue);
603 iss >> start_time_string >> start_time_unit
604 >> time_range_string >> time_range_unit;
605 pOGLSViewer->fVP.SetStartTime
607 (G4String(start_time_string + ' ' + start_time_unit)));
608 G4double timeRange = command->ConvertToDimensionedDouble
609 (G4String(time_range_string + ' ' + time_range_unit));
610 if (timeRange > 0.) {
611 pOGLSViewer->fVP.SetEndTime
612 (pOGLSViewer->fVP.GetStartTime() + timeRange);
613 }
614 if (pOGLSViewer->fVP.IsAutoRefresh())
615 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
616 G4cout
617 << "DEPRECATED. Use /vis/viewer/set/timeWindow/startTime."
618 << G4endl;
619 return;
620 }
621
622 // Scene handler commands
623 G4OpenGLStoredSceneHandler* pOGLSSceneHandler =
624 dynamic_cast<G4OpenGLStoredSceneHandler*>(pViewer->GetSceneHandler());
625
626 if (!pOGLSSceneHandler) {
627 G4cout <<
628 "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type"
629 "\n OGLS (Stored). (Viewer is \"" << pViewer->GetName() << "\".)"
630 "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)"
631 "\n This feature is only implemented for OGL Stored"
632 "\n scene handlers. Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
633 << G4endl;
634 return;
635 }
636
637 if (command == fpCommandDisplayListLimit)
638 {
639 G4int displayListLimit =
640 fpCommandDisplayListLimit->GetNewIntValue(newValue);
641 pOGLSSceneHandler->SetDisplayListLimit(displayListLimit);
642 return;
643 }
644}
645
646#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4OpenGLViewerMessenger * GetInstance()
void SetNewValue(G4UIcommand *, G4String)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
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)
static G4int GetNewIntValue(const char *paramString)
void SetDefaultValue(G4int defVal)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
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
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)
const G4String & GetName() const
const G4String & GetName() const
G4VSceneHandler * GetSceneHandler() const
static constexpr G4double fVeryLongTime
G4VViewer * GetCurrentViewer() const
static G4VisManager * GetInstance()
const char * name(G4int ptype)