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