ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGLViewerMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4OpenGLViewerMessenger.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 
28 #ifdef G4VIS_BUILD_OPENGL_DRIVER
29 
31 
32 #include "G4OpenGLViewer.hh"
33 #include "G4OpenGLStoredViewer.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"
42 #include "G4UIcmdWithAnInteger.hh"
43 #include "G4VisManager.hh"
44 #include <sstream>
45 
48 
51 {
53  return fpInstance;
54 }
55 
57 {
58  G4bool omitable;
59 
60  fpDirectory = new G4UIdirectory("/vis/ogl/");
61  fpDirectory->SetGuidance("G4OpenGLViewer commands.");
62 
64  new G4UIcommand("/vis/ogl/export", this);
65  fpCommandExport->SetGuidance ("export a screenshot of current OpenGL viewer");
66  fpCommandExport->SetGuidance ("If name is \"\", filename and extension will have the default value");
67  fpCommandExport->SetGuidance ("If name is \"toto.png\", set the name to \"toto\" and the format to \"png\". No incremented suffix is added.");
68  fpCommandExport->SetGuidance ("If name is \"toto\", set the name to \"toto\" and the format to default (or current format if specify). Will also add an incremented suffix at the end of the file, except if name is the same as previous it will not reset incremented suffix.");
69  fpCommandExport->SetGuidance ("Setting size is available only on eps/pdf/svg/ps formats");
70  G4UIparameter* parameterExport;
71  parameterExport = new G4UIparameter ("name", 's', omitable = true);
72  parameterExport->SetDefaultValue("!");
73  parameterExport->SetGuidance("by default, will take a default value or the last /vis/ogl/set/printFilename value if set");
74  fpCommandExport->SetParameter(parameterExport);
75  parameterExport = new G4UIparameter ("width", 'd', omitable = true);
76  parameterExport->SetGuidance("By default, will take the current width of the viewer or /vis/ogl/set/printSize if set");
77  parameterExport->SetGuidance("This parameter is only useful for eps/pdf/svg/ps formats !");
78  parameterExport->SetDefaultValue(-1);
79  fpCommandExport->SetParameter(parameterExport);
80  parameterExport = new G4UIparameter ("height", 'd', omitable = true);
81  parameterExport->SetGuidance("By default, will take the current height of the viewer or /vis/ogl/set/printSize if set");
82  parameterExport->SetGuidance("This parameter is only useful for eps/pdf/svg/ps formats !");
83  parameterExport->SetDefaultValue(-1);
84  fpCommandExport->SetParameter(parameterExport);
85 
86  fpCommandFlushAt = new G4UIcommand("/vis/ogl/flushAt", this);
88  ("Controls the rate at which graphics primitives are flushed to screen.");
90  ("Flushing to screen is an expensive operation so to speed drawing choose"
91  "\nan action suitable for your application. Note that detectors are flushed"
92  "\nto screen anyway at end of drawing, and events are flushed to screen"
93  "\nanyway depending on /vis/scene/endOfEventAction and endOfRunAction.");
95  ("For NthPrimitive and NthEvent the second parameter N is operative.");
97  ("For \"never\", detectors and events are still flushed as described above.");
98  G4UIparameter* parameterFlushAt;
99  parameterFlushAt = new G4UIparameter ("action", 's', omitable = true);
100  parameterFlushAt->SetParameterCandidates
101  ("endOfEvent endOfRun eachPrimitive NthPrimitive NthEvent never");
102  parameterFlushAt->SetDefaultValue("NthEvent");
103  fpCommandFlushAt->SetParameter(parameterFlushAt);
104  parameterFlushAt = new G4UIparameter ("N", 'i', omitable = true);
105  parameterFlushAt->SetDefaultValue(100);
106  fpCommandFlushAt->SetParameter(parameterFlushAt);
107 
109  new G4UIcmdWithoutParameter("/vis/ogl/printEPS", this);
110  fpCommandPrintEPS->SetGuidance("Print Encapsulated PostScript file.");
112  ("Generates files with names G4OpenGL_n.eps, where n is a sequence"
113  "\nnumber, starting at 0."
114  "\nCan be \"vectored\" or \"pixmap\" - see \"/vis/ogl/set/printMode\".");
115 
116  fpDirectorySet = new G4UIdirectory ("/vis/ogl/set/");
117  fpDirectorySet->SetGuidance("G4OpenGLViewer set commands.");
118 
119  G4UIparameter* parameter;
120 
122  new G4UIcommand("/vis/ogl/set/displayHeadTime", this);
124  ("DEPRECATED. Use /vis/viewer/set/timeWindow/displayHeadTime."
125  "\n Display head time of range in 2D text.");
126  parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false);
127  parameter->SetDefaultValue(false);
129  parameter = new G4UIparameter ("screenX", 'd', omitable = true);
130  parameter->SetGuidance("-1 < screenX < 1");
131  parameter->SetParameterRange("screenX >= -1. && screenX <= 1.");
132  parameter->SetDefaultValue(-0.9);
134  parameter = new G4UIparameter ("screenY", 'd', omitable = true);
135  parameter->SetGuidance("-1 < screenY < 1");
136  parameter->SetParameterRange("screenY >= -1. && screenY <= 1.");
137  parameter->SetDefaultValue(-0.9);
139  parameter = new G4UIparameter ("screenSize", 'd', omitable = true);
140  parameter->SetDefaultValue(24.);
142  parameter = new G4UIparameter ("red", 'd', omitable = true);
143  parameter->SetParameterRange("red >= 0. && red <= 1.");
144  parameter->SetDefaultValue(0.);
146  parameter = new G4UIparameter ("green", 'd', omitable = true);
147  parameter->SetParameterRange("green >= 0. && green <= 1.");
148  parameter->SetDefaultValue(1.);
150  parameter = new G4UIparameter ("blue", 'd', omitable = true);
151  parameter->SetParameterRange("blue >= 0. && blue <= 1.");
152  parameter->SetDefaultValue(1.);
154 
156  new G4UIcommand("/vis/ogl/set/displayLightFront", this);
158  ("DEPRECATED. Use /vis/viewer/set/timeWindow/displayLightFront."
159  "\n Display the light front at head time.");
161  ("Tip: The trajectories can appear of jump ahead of the light front"
162  "\nbecause their time range overlaps the viewer's time range. To"
163  "\naverage out this discrete time effect, advance the light front by"
164  "\nhalf the trajectories interval. E.g., if the trajectory time slice"
165  "\ninterval is 0.01 ns:"
166  "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.005 ns"
167  "\nTo prevent them beating the light front at all:"
168  "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.01 ns");
169  parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false);
170  parameter->SetDefaultValue(false);
172  parameter = new G4UIparameter ("originX", 'd', omitable = true);
173  parameter->SetDefaultValue(0.);
175  parameter = new G4UIparameter ("originY", 'd', omitable = true);
176  parameter->SetDefaultValue(0.);
178  parameter = new G4UIparameter ("originZ", 'd', omitable = true);
179  parameter->SetDefaultValue(0.);
181  parameter = new G4UIparameter ("space_unit", 's', omitable = true);
182  parameter->SetDefaultValue("m");
184  parameter = new G4UIparameter ("originT", 'd', omitable = true);
185  parameter->SetDefaultValue(0.);
187  parameter = new G4UIparameter ("time_unit", 's', omitable = true);
188  parameter->SetDefaultValue("s");
190  parameter = new G4UIparameter ("red", 'd', omitable = true);
191  parameter->SetParameterRange("red >= 0. && red <= 1.");
192  parameter->SetDefaultValue(0.);
194  parameter = new G4UIparameter ("green", 'd', omitable = true);
195  parameter->SetParameterRange("green >= 0. && green <= 1.");
196  parameter->SetDefaultValue(1.);
198  parameter = new G4UIparameter ("blue", 'd', omitable = true);
199  parameter->SetParameterRange("blue >= 0. && blue <= 1.");
200  parameter->SetDefaultValue(0.);
202 
204  new G4UIcmdWithAnInteger("/vis/ogl/set/displayListLimit", this);
206  ("Set/reset display list number of primitive limit (to avoid memory exhaustion).");
207  fpCommandDisplayListLimit->SetParameterName("limit", omitable = true);
209  fpCommandDisplayListLimit->SetRange("limit>=10000");
210 
212  new G4UIcommand("/vis/ogl/set/endTime", this);
214  ("DEPRECATED. Use /vis/viewer/set/timeWindow/endTime."
215  "\n Set end and range of time window.");
216  parameter = new G4UIparameter ("end-time", 'd', omitable = false);
218  fpCommandEndTime->SetParameter(parameter);
219  parameter = new G4UIparameter ("end-time-unit", 's', omitable = false);
220  parameter->SetDefaultValue("ns");
221  fpCommandEndTime->SetParameter(parameter);
222  parameter = new G4UIparameter ("time-range", 'd', omitable = true);
223  parameter->SetDefaultValue(-1.);
224  fpCommandEndTime->SetParameter(parameter);
225  parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
226  parameter->SetDefaultValue("ns");
227  fpCommandEndTime->SetParameter(parameter);
228 
230  new G4UIcmdWithAnInteger("/vis/ogl/set/eventsDrawInterval", this);
232  ("Deprecated. Use /vis/ogl/flushAt.");
234  ("(This is equivalent to \"/vis/ogl/flushAt NthPrimitive N\"");
235  fpCommandEventsDrawInterval->SetParameterName("N", omitable = true);
237 
238  fpCommandFade = new G4UIcmdWithADouble("/vis/ogl/set/fade", this);
240  ("DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
241  "\n 0: no fade; 1: maximum fade with time within range.");
242  fpCommandFade->SetParameterName("fadefactor", omitable = false);
243  fpCommandFade->SetRange("fadefactor>=0.&&fadefactor<=1.");
245 
247  new G4UIcommand("/vis/ogl/set/printFilename", this);
248  fpCommandPrintFilename->SetGuidance ("Set print filename");
249  fpCommandPrintFilename->SetGuidance ("Setting 'incremental' will increment filename by one at each new print, starting at 0");
250  G4UIparameter* parameterPrintFilename;
251  parameterPrintFilename = new G4UIparameter ("name", 's', omitable = true);
252  parameterPrintFilename->SetDefaultValue("G4OpenGL");
253  fpCommandPrintFilename->SetParameter(parameterPrintFilename);
254  parameterPrintFilename = new G4UIparameter ("incremental", 'b', omitable = true);
255  parameterPrintFilename->SetDefaultValue(1);
256  fpCommandPrintFilename->SetParameter(parameterPrintFilename);
257 
259  new G4UIcommand("/vis/ogl/set/exportFormat", this);
260  fpCommandExportFormat->SetGuidance ("Set export format");
261  fpCommandExportFormat->SetGuidance ("By default, pdf/eps/svg/ps are available. Depending of viewers several other format are available.");
262  fpCommandExportFormat->SetGuidance ("Try /vis/ogl/set/exportFormat without parameters to see them.");
263  fpCommandExportFormat->SetGuidance ("Changing format will reset the incremental suffix to 0.");
264  G4UIparameter* parameterExportFormat;
265  parameterExportFormat = new G4UIparameter ("format", 's', omitable = true);
266  parameterExportFormat->SetDefaultValue("");
267  fpCommandExportFormat->SetParameter(parameterExportFormat);
268 
270  ("/vis/ogl/set/printMode",this);
271  fpCommandPrintMode->SetGuidance("Set print mode, only available for \"ps\" format");
272  fpCommandPrintMode->SetParameterName("print_mode",omitable = true);
273  fpCommandPrintMode->SetCandidates("vectored pixmap");
274  fpCommandPrintMode->SetDefaultValue("vectored");
275 
277  new G4UIcommand("/vis/ogl/set/printSize", this);
278  fpCommandPrintSize->SetGuidance ("Set print size");
279  fpCommandPrintSize->SetGuidance ("Tip : -1 will mean 'print size' = 'window size'");
280  fpCommandPrintSize->SetGuidance (" Setting size greater than your maximum graphic card capacity , will set the size to maximum size.");
281  G4UIparameter* parameterPrintSize;
282  parameterPrintSize = new G4UIparameter ("width", 'd', omitable = false);
283  parameterPrintSize->SetDefaultValue(-1);
284  fpCommandPrintSize->SetParameter(parameterPrintSize);
285  parameterPrintSize = new G4UIparameter ("height", 'd', omitable = false);
286  parameterPrintSize->SetDefaultValue(-1);
287  fpCommandPrintSize->SetParameter(parameterPrintSize);
288 
290  new G4UIcommand("/vis/ogl/set/startTime", this);
292  ("DEPRECATED. Use /vis/viewer/set/timeWindow/startTime."
293  "\n Set start and range of time window.");
294  parameter = new G4UIparameter ("start-time", 'd', omitable = false);
296  fpCommandStartTime->SetParameter(parameter);
297  parameter = new G4UIparameter ("start-time-unit", 's', omitable = false);
298  parameter->SetDefaultValue("ns");
299  fpCommandStartTime->SetParameter(parameter);
300  parameter = new G4UIparameter ("time-range", 'd', omitable = true);
301  parameter->SetDefaultValue(-1.);
302  fpCommandStartTime->SetParameter(parameter);
303  parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
304  parameter->SetDefaultValue("ns");
305  fpCommandStartTime->SetParameter(parameter);
306 
308  new G4UIcmdWithABool("/vis/ogl/set/transparency", this);
310  ("True/false to enable/disable rendering of transparent objects.");
312  ("transparency-enabled", omitable = true);
314 }
315 
317 {
318  delete fpCommandTransparency;
319  delete fpCommandStartTime;
320  delete fpCommandPrintSize;
321  delete fpCommandPrintMode;
322  delete fpCommandPrintFilename;
323  delete fpCommandFade;
324  delete fpCommandExportFormat;
326  delete fpCommandEndTime;
330  delete fpDirectorySet;
331  delete fpCommandPrintEPS;
332  delete fpCommandFlushAt;
333  delete fpCommandExport;
334  delete fpDirectory;
335 
336  delete fpInstance;
337 }
338 
340 (G4UIcommand* command, G4String newValue)
341 {
342  G4VisManager* pVisManager = G4VisManager::GetInstance();
343 
344  G4VViewer* pViewer = pVisManager->GetCurrentViewer();
345  if (!pViewer) {
346  G4cout <<
347  "G4OpenGLViewerMessenger::SetNewValue: No current viewer."
348  "\n \"/vis/open\", or similar, to get one."
349  << G4endl;
350  return;
351  }
352 
353  G4VSceneHandler* pSceneHandler = pViewer->GetSceneHandler();
354  if (!pSceneHandler) {
355  G4cout <<
356  "G4OpenGLViewerMessenger::SetNewValue: This viewer has no scene handler."
357  "\n Shouldn't happen - please report circumstances."
358  "\n (Viewer is \"" << pViewer->GetName() << "\".)"
359  "\n Try \"/vis/open\", or similar, to get one."
360  << G4endl;
361  return;
362  }
363 
364  G4OpenGLViewer* pOGLViewer = dynamic_cast<G4OpenGLViewer*>(pViewer);
365  if (!pOGLViewer) {
366  G4cout <<
367  "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type"
368  "\n OGL. (It is \""
369  << pViewer->GetName() <<
370  "\".)\n Use \"/vis/viewer/select\" or \"/vis/open\"."
371  << G4endl;
372  return;
373  }
374 
375  G4OpenGLSceneHandler* pOGLSceneHandler =
376  dynamic_cast<G4OpenGLSceneHandler*>(pSceneHandler);
377  if (!pOGLSceneHandler) {
378  G4cout <<
379  "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type"
380  "\n OGL. (Viewer is \"" << pViewer->GetName() << "\".)"
381  "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)"
382  "\n Use \"/vis/sceneHandler/list\" and \"/vis/sceneHandler/select\""
383  "\n or \"/vis/open\"."
384  << G4endl;
385  return;
386  }
387 
388  if (command == fpCommandPrintEPS)
389  {
390  pOGLViewer->setExportImageFormat("eps",true);
391  pOGLViewer->exportImage();
392 
393  if (pOGLViewer->fVP.IsAutoRefresh())
394  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
395  return;
396  }
397 
398  if (command == fpCommandExportFormat)
399  {
400  G4String name;
401  std::istringstream iss(newValue);
402  iss >> name;
403  pOGLViewer->setExportImageFormat(name);
404 
405  return;
406  }
407 
408  if (command == fpCommandExport)
409  {
410  G4String name;
411  G4int width,height;
412  std::istringstream iss(newValue);
413  iss >> name >> width >> height;
414  pOGLViewer->exportImage(name, width, height);
415 
416  if (pOGLViewer->fVP.IsAutoRefresh())
417  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
418  return;
419  }
420 
421  if (command == fpCommandPrintSize)
422  {
423  G4int width,height;
424  std::istringstream iss(newValue);
425  iss >> width
426  >> height;
427  pOGLViewer->setExportSize(width,height);
428  return;
429  }
430 
431  if (command == fpCommandPrintFilename)
432  {
433  G4String name;
434  G4bool inc;
435  std::istringstream iss(newValue);
436  iss >> name
437  >> inc;
438  pOGLViewer->setExportFilename(name,inc);
439  return;
440  }
441 
442  if (command == fpCommandPrintMode)
443  {
444  if (newValue == "vectored") pOGLViewer->fVectoredPs = true;
445  if (newValue == "pixmap") pOGLViewer->fVectoredPs = false;
446  return;
447  }
448 
449  if (command == fpCommandTransparency)
450  {
451  pOGLViewer->transparency_enabled = command->ConvertToBool(newValue);
452  if (pOGLViewer->fVP.IsAutoRefresh())
453  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
454  return;
455  }
456 
457  if (command == fpCommandEventsDrawInterval)
458  {
459  G4int entitiesFlushInterval =
461  pOGLSceneHandler->SetFlushAction(G4OpenGLSceneHandler::NthPrimitive);
462  pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
463  return;
464  }
465 
466  if (command == fpCommandFlushAt)
467  {
468 // G4bool firstTime = true;
469  std::map<G4String,G4OpenGLSceneHandler::FlushAction> actionMap;
470 // if (firstTime) {
471  actionMap["endOfEvent"] = G4OpenGLSceneHandler::endOfEvent;
472  actionMap["endOfRun"] = G4OpenGLSceneHandler::endOfRun;
473  actionMap["eachPrimitive"] = G4OpenGLSceneHandler::eachPrimitive;
474  actionMap["NthPrimitive"] = G4OpenGLSceneHandler::NthPrimitive;
475  actionMap["NthEvent"] = G4OpenGLSceneHandler::NthEvent;
476  actionMap["never"] = G4OpenGLSceneHandler::never;
477 // firstTime = false;
478 // }
479  G4String action;
480  G4int entitiesFlushInterval;
481  std::istringstream iss(newValue);
482  iss >> action >> entitiesFlushInterval;
483  pOGLSceneHandler->SetFlushAction(actionMap[action]);
484  pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
485  return;
486  }
487 
488  G4OpenGLStoredViewer* pOGLSViewer =
489  dynamic_cast<G4OpenGLStoredViewer*>(pViewer);
490 
491  if (!pOGLSViewer)
492  {
493  G4cout <<
494  "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS."
495  "\n (It is \"" << pViewer->GetName() << "\".)"
496  "\n This feature is only implemented for OGL Stored viewers."
497  "\n Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
498  << G4endl;
499  return;
500  }
501 
502  if (command == fpCommandDisplayHeadTime)
503  {
504  G4String display;
505  G4double screenX, screenY, screenSize, red, green, blue;
506  std::istringstream iss(newValue);
507  iss >> display >> screenX >> screenY
508  >> screenSize >> red >> green >> blue;
509  pOGLSViewer->fVP.SetDisplayHeadTime(command->ConvertToBool(display));
510  pOGLSViewer->fVP.SetDisplayHeadTimeX(screenX);
511  pOGLSViewer->fVP.SetDisplayHeadTimeY(screenY);
512  pOGLSViewer->fVP.SetDisplayHeadTimeSize(screenSize);
513  pOGLSViewer->fVP.SetDisplayHeadTimeRed(red);
514  pOGLSViewer->fVP.SetDisplayHeadTimeGreen(green);
515  pOGLSViewer->fVP.SetDisplayHeadTimeBlue(blue);
516  G4cout
517  << "DEPRECATED. Use /vis/viewer/set/timeWindow/displayHeadTime."
518  << G4endl;
519  return;
520  }
521 
522  if (command == fpCommandDisplayLightFront)
523  {
524  G4String display, originX, originY, originZ, unitS, originT, unitT;
525  G4double red, green, blue;
526  std::istringstream iss(newValue);
527  iss >> display
528  >> originX >> originY >> originZ >> unitS
529  >> originT >> unitT
530  >> red >> green >> blue;
531  pOGLSViewer->fVP.SetDisplayLightFront(command->ConvertToBool(display));
532  pOGLSViewer->fVP.SetDisplayLightFrontX
533  (command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)));
534  pOGLSViewer->fVP.SetDisplayLightFrontY
535  (command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)));
536  pOGLSViewer->fVP.SetDisplayLightFrontZ
537  (command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)));
538  pOGLSViewer->fVP.SetDisplayLightFrontT
539  (command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)));
540  pOGLSViewer->fVP.SetDisplayLightFrontRed(red);
541  pOGLSViewer->fVP.SetDisplayLightFrontGreen(green);
542  pOGLSViewer->fVP.SetDisplayLightFrontBlue(blue);
543  G4cout
544  << "DEPRECATED. Use /vis/viewer/set/timeWindow/displayLightFront."
545  << G4endl;
546  return;
547  }
548 
549  if (command == fpCommandEndTime)
550  {
551  G4String end_time_string, end_time_unit,
552  time_range_string, time_range_unit;
553  std::istringstream iss(newValue);
554  iss >> end_time_string >> end_time_unit
555  >> time_range_string >> time_range_unit;
556  pOGLSViewer->fVP.SetEndTime
558  (G4String(end_time_string + ' ' + end_time_unit)));
559  G4double timeRange = command->ConvertToDimensionedDouble
560  (G4String(time_range_string + ' ' + time_range_unit));
561  if (timeRange > 0.) {
562  pOGLSViewer->fVP.SetStartTime
563  (pOGLSViewer->fVP.GetEndTime() - timeRange);
564  }
565  if (pOGLSViewer->fVP.IsAutoRefresh())
566  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
567  G4cout
568  << "DEPRECATED. Use /vis/viewer/set/timeWindow/endTime."
569  << G4endl;
570  return;
571  }
572 
573  if (command == fpCommandFade)
574  {
575  pOGLSViewer->fVP.SetFadeFactor(command->ConvertToDouble(newValue));
576  if (pOGLSViewer->fVP.IsAutoRefresh())
577  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
578  G4cout
579  << "DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
580  << G4endl;
581  return;
582  }
583 
584  if (command == fpCommandStartTime)
585  {
586  G4String start_time_string, start_time_unit,
587  time_range_string, time_range_unit;
588  std::istringstream iss(newValue);
589  iss >> start_time_string >> start_time_unit
590  >> time_range_string >> time_range_unit;
591  pOGLSViewer->fVP.SetStartTime
593  (G4String(start_time_string + ' ' + start_time_unit)));
594  G4double timeRange = command->ConvertToDimensionedDouble
595  (G4String(time_range_string + ' ' + time_range_unit));
596  if (timeRange > 0.) {
597  pOGLSViewer->fVP.SetEndTime
598  (pOGLSViewer->fVP.GetStartTime() + timeRange);
599  }
600  if (pOGLSViewer->fVP.IsAutoRefresh())
601  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
602  G4cout
603  << "DEPRECATED. Use /vis/viewer/set/timeWindow/startTime."
604  << G4endl;
605  return;
606  }
607 
608  G4OpenGLStoredSceneHandler* pOGLSSceneHandler =
609  dynamic_cast<G4OpenGLStoredSceneHandler*>(pViewer->GetSceneHandler());
610 
611  if (!pOGLSSceneHandler) {
612  G4cout <<
613  "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type"
614  "\n OGLS (Stored). (Viewer is \"" << pViewer->GetName() << "\".)"
615  "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)"
616  "\n This feature is only implemented for OGL Stored"
617  "\n scene handlers. Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
618  << G4endl;
619  return;
620  }
621 
622  if (command == fpCommandDisplayListLimit)
623  {
624  G4int displayListLimit =
626  pOGLSSceneHandler->SetDisplayListLimit(displayListLimit);
627  return;
628  }
629 }
630 
631 #endif