Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id: G4OpenGLViewerMessenger.cc 101105 2016-11-07 08:09:26Z 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 
48 G4OpenGLViewerMessenger::fpInstance = 0;
49 
52 {
53  if (!fpInstance) fpInstance = new G4OpenGLViewerMessenger;
54  return fpInstance;
55 }
56 
57 G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
58 {
59  G4bool omitable;
60 
61  fpDirectory = new G4UIdirectory("/vis/ogl/");
62  fpDirectory->SetGuidance("G4OpenGLViewer commands.");
63 
64  fpCommandExport =
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);
88  fpCommandFlushAt->SetGuidance
89  ("Controls the rate at which graphics primitives are flushed to screen.");
90  fpCommandFlushAt->SetGuidance
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.");
95  fpCommandFlushAt->SetGuidance
96  ("For NthPrimitive and NthEvent the second parameter N is operative.");
97  fpCommandFlushAt->SetGuidance
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 
109  fpCommandPrintEPS =
110  new G4UIcmdWithoutParameter("/vis/ogl/printEPS", this);
111  fpCommandPrintEPS->SetGuidance("Print Encapsulated PostScript file.");
112  fpCommandPrintEPS->SetGuidance
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 
122  fpCommandDisplayHeadTime =
123  new G4UIcommand("/vis/ogl/set/displayHeadTime", this);
124  fpCommandDisplayHeadTime->SetGuidance
125  ("Display head time of range in 2D text.");
126  parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false);
127  parameter->SetDefaultValue(false);
128  fpCommandDisplayHeadTime->SetParameter(parameter);
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);
133  fpCommandDisplayHeadTime->SetParameter(parameter);
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);
138  fpCommandDisplayHeadTime->SetParameter(parameter);
139  parameter = new G4UIparameter ("screenSize", 'd', omitable = true);
140  parameter->SetDefaultValue(24.);
141  fpCommandDisplayHeadTime->SetParameter(parameter);
142  parameter = new G4UIparameter ("red", 'd', omitable = true);
143  parameter->SetParameterRange("red >= 0. && red <= 1.");
144  parameter->SetDefaultValue(0.);
145  fpCommandDisplayHeadTime->SetParameter(parameter);
146  parameter = new G4UIparameter ("green", 'd', omitable = true);
147  parameter->SetParameterRange("green >= 0. && green <= 1.");
148  parameter->SetDefaultValue(1.);
149  fpCommandDisplayHeadTime->SetParameter(parameter);
150  parameter = new G4UIparameter ("blue", 'd', omitable = true);
151  parameter->SetParameterRange("blue >= 0. && blue <= 1.");
152  parameter->SetDefaultValue(1.);
153  fpCommandDisplayHeadTime->SetParameter(parameter);
154 
155  fpCommandDisplayLightFront =
156  new G4UIcommand("/vis/ogl/set/displayLightFront", this);
157  fpCommandDisplayLightFront->SetGuidance
158  ("Display the light front at head time.");
159  fpCommandDisplayLightFront->SetGuidance
160  ("Tip: The trajectories can appear of jump ahead of the light front"
161  "\nbecause their time range overlaps the viewer's time range. To"
162  "\naverage out this discrete time effect, advance the light front by"
163  "\nhalf the trajectories interval. E.g., if the trajectory time slice"
164  "\ninterval is 0.01 ns:"
165  "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.005 ns"
166  "\nTo prevent them beating the light front at all:"
167  "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.01 ns");
168  parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false);
169  parameter->SetDefaultValue(false);
170  fpCommandDisplayLightFront->SetParameter(parameter);
171  parameter = new G4UIparameter ("originX", 'd', omitable = true);
172  parameter->SetDefaultValue(0.);
173  fpCommandDisplayLightFront->SetParameter(parameter);
174  parameter = new G4UIparameter ("originY", 'd', omitable = true);
175  parameter->SetDefaultValue(0.);
176  fpCommandDisplayLightFront->SetParameter(parameter);
177  parameter = new G4UIparameter ("originZ", 'd', omitable = true);
178  parameter->SetDefaultValue(0.);
179  fpCommandDisplayLightFront->SetParameter(parameter);
180  parameter = new G4UIparameter ("space_unit", 's', omitable = true);
181  parameter->SetDefaultValue("m");
182  fpCommandDisplayLightFront->SetParameter(parameter);
183  parameter = new G4UIparameter ("originT", 'd', omitable = true);
184  parameter->SetDefaultValue(0.);
185  fpCommandDisplayLightFront->SetParameter(parameter);
186  parameter = new G4UIparameter ("time_unit", 's', omitable = true);
187  parameter->SetDefaultValue("s");
188  fpCommandDisplayLightFront->SetParameter(parameter);
189  parameter = new G4UIparameter ("red", 'd', omitable = true);
190  parameter->SetParameterRange("red >= 0. && red <= 1.");
191  parameter->SetDefaultValue(0.);
192  fpCommandDisplayLightFront->SetParameter(parameter);
193  parameter = new G4UIparameter ("green", 'd', omitable = true);
194  parameter->SetParameterRange("green >= 0. && green <= 1.");
195  parameter->SetDefaultValue(1.);
196  fpCommandDisplayLightFront->SetParameter(parameter);
197  parameter = new G4UIparameter ("blue", 'd', omitable = true);
198  parameter->SetParameterRange("blue >= 0. && blue <= 1.");
199  parameter->SetDefaultValue(0.);
200  fpCommandDisplayLightFront->SetParameter(parameter);
201 
202  fpCommandDisplayListLimit =
203  new G4UIcmdWithAnInteger("/vis/ogl/set/displayListLimit", this);
204  fpCommandDisplayListLimit->SetGuidance
205  ("Set/reset display list limit (to avoid memory exhaustion).");
206  fpCommandDisplayListLimit->SetParameterName("limit", omitable = true);
207  fpCommandDisplayListLimit->SetDefaultValue(50000);
208  fpCommandDisplayListLimit->SetRange("limit>=10000");
209 
210  fpCommandEndTime =
211  new G4UIcommand("/vis/ogl/set/endTime", this);
212  fpCommandEndTime->SetGuidance("Set end and range of track time.");
213  parameter = new G4UIparameter ("end-time", 'd', omitable = false);
214  parameter->SetDefaultValue(DBL_MAX);
215  fpCommandEndTime->SetParameter(parameter);
216  parameter = new G4UIparameter ("end-time-unit", 's', omitable = false);
217  parameter->SetDefaultValue("ns");
218  fpCommandEndTime->SetParameter(parameter);
219  parameter = new G4UIparameter ("time-range", 'd', omitable = true);
220  parameter->SetDefaultValue(-1.);
221  fpCommandEndTime->SetParameter(parameter);
222  parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
223  parameter->SetDefaultValue("ns");
224  fpCommandEndTime->SetParameter(parameter);
225 
226  fpCommandEventsDrawInterval =
227  new G4UIcmdWithAnInteger("/vis/ogl/set/eventsDrawInterval", this);
228  fpCommandEventsDrawInterval->SetGuidance
229  ("Deprecated. Use /vis/ogl/flushAt.");
230  fpCommandEventsDrawInterval->SetGuidance
231  ("(This is equivalent to \"/vis/ogl/flushAt NthPrimitive N\"");
232  fpCommandEventsDrawInterval->SetParameterName("N", omitable = true);
233  fpCommandEventsDrawInterval->SetDefaultValue(1);
234 
235  fpCommandFade = new G4UIcmdWithADouble("/vis/ogl/set/fade", this);
236  fpCommandFade->SetGuidance
237  ("0: no fade; 1: maximum fade with time within range.");
238  fpCommandFade->SetParameterName("fadefactor", omitable = false);
239  fpCommandFade->SetRange("fadefactor>=0.&&fadefactor<=1.");
240  fpCommandFade->SetDefaultValue(0.);
241 
242  fpCommandPrintFilename =
243  new G4UIcommand("/vis/ogl/set/printFilename", this);
244  fpCommandPrintFilename->SetGuidance ("Set print filename");
245  fpCommandPrintFilename->SetGuidance ("Setting 'incremental' will increment filename by one at each new print, starting at 0");
246  G4UIparameter* parameterPrintFilename;
247  parameterPrintFilename = new G4UIparameter ("name", 's', omitable = true);
248  parameterPrintFilename->SetDefaultValue("G4OpenGL");
249  fpCommandPrintFilename->SetParameter(parameterPrintFilename);
250  parameterPrintFilename = new G4UIparameter ("incremental", 'b', omitable = true);
251  parameterPrintFilename->SetDefaultValue(1);
252  fpCommandPrintFilename->SetParameter(parameterPrintFilename);
253 
254  fpCommandExportFormat =
255  new G4UIcommand("/vis/ogl/set/exportFormat", this);
256  fpCommandExportFormat->SetGuidance ("Set export format");
257  fpCommandExportFormat->SetGuidance ("By default, pdf/eps/svg/ps are available. Depending of viewers several other format are available.");
258  fpCommandExportFormat->SetGuidance ("Try /vis/ogl/set/exportFormat without parameters to see them.");
259  fpCommandExportFormat->SetGuidance ("Changing format will reset the incremental suffix to 0.");
260  G4UIparameter* parameterExportFormat;
261  parameterExportFormat = new G4UIparameter ("format", 's', omitable = true);
262  parameterExportFormat->SetDefaultValue("");
263  fpCommandExportFormat->SetParameter(parameterExportFormat);
264 
265  fpCommandPrintMode = new G4UIcmdWithAString
266  ("/vis/ogl/set/printMode",this);
267  fpCommandPrintMode->SetGuidance("Set print mode, only available for \"ps\" format");
268  fpCommandPrintMode->SetParameterName("print_mode",omitable = true);
269  fpCommandPrintMode->SetCandidates("vectored pixmap");
270  fpCommandPrintMode->SetDefaultValue("vectored");
271 
272  fpCommandPrintSize =
273  new G4UIcommand("/vis/ogl/set/printSize", this);
274  fpCommandPrintSize->SetGuidance ("Set print size");
275  fpCommandPrintSize->SetGuidance ("Tip : -1 will mean 'print size' = 'window size'");
276  fpCommandPrintSize->SetGuidance (" Setting size greatter than your maximum graphic card capacity , will set the size to maximum size.");
277  G4UIparameter* parameterPrintSize;
278  parameterPrintSize = new G4UIparameter ("width", 'd', omitable = false);
279  parameterPrintSize->SetDefaultValue(-1);
280  fpCommandPrintSize->SetParameter(parameterPrintSize);
281  parameterPrintSize = new G4UIparameter ("height", 'd', omitable = false);
282  parameterPrintSize->SetDefaultValue(-1);
283  fpCommandPrintSize->SetParameter(parameterPrintSize);
284 
285  fpCommandStartTime =
286  new G4UIcommand("/vis/ogl/set/startTime", this);
287  fpCommandStartTime->SetGuidance("Set start and range of track time.");
288  parameter = new G4UIparameter ("start-time", 'd', omitable = false);
289  parameter->SetDefaultValue(-DBL_MAX);
290  fpCommandStartTime->SetParameter(parameter);
291  parameter = new G4UIparameter ("start-time-unit", 's', omitable = false);
292  parameter->SetDefaultValue("ns");
293  fpCommandStartTime->SetParameter(parameter);
294  parameter = new G4UIparameter ("time-range", 'd', omitable = true);
295  parameter->SetDefaultValue(-1.);
296  fpCommandStartTime->SetParameter(parameter);
297  parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
298  parameter->SetDefaultValue("ns");
299  fpCommandStartTime->SetParameter(parameter);
300 
301  fpCommandTransparency =
302  new G4UIcmdWithABool("/vis/ogl/set/transparency", this);
303  fpCommandTransparency->SetGuidance
304  ("True/false to enable/disable rendering of transparent objects.");
305  fpCommandTransparency->SetParameterName
306  ("transparency-enabled", omitable = true);
307  fpCommandTransparency->SetDefaultValue(true);
308 }
309 
311 {
312  delete fpCommandTransparency;
313  delete fpCommandStartTime;
314  delete fpCommandPrintSize;
315  delete fpCommandPrintMode;
316  delete fpCommandPrintFilename;
317  delete fpCommandFade;
318  delete fpCommandExportFormat;
319  delete fpCommandEventsDrawInterval;
320  delete fpCommandEndTime;
321  delete fpCommandDisplayListLimit;
322  delete fpCommandDisplayLightFront;
323  delete fpCommandDisplayHeadTime;
324  delete fpDirectorySet;
325  delete fpCommandPrintEPS;
326  delete fpCommandFlushAt;
327  delete fpCommandExport;
328  delete fpDirectory;
329 
330  delete fpInstance;
331 }
332 
334 (G4UIcommand* command, G4String newValue)
335 {
336  G4VisManager* pVisManager = G4VisManager::GetInstance();
337 
338  G4VViewer* pViewer = pVisManager->GetCurrentViewer();
339  if (!pViewer) {
340  G4cout <<
341  "G4OpenGLViewerMessenger::SetNewValue: No current viewer."
342  "\n \"/vis/open\", or similar, to get one."
343  << G4endl;
344  return;
345  }
346 
347  G4VSceneHandler* pSceneHandler = pViewer->GetSceneHandler();
348  if (!pSceneHandler) {
349  G4cout <<
350  "G4OpenGLViewerMessenger::SetNewValue: This viewer has no scene handler."
351  "\n Shouldn't happen - please report circumstances."
352  "\n (Viewer is \"" << pViewer->GetName() << "\".)"
353  "\n Try \"/vis/open\", or similar, to get one."
354  << G4endl;
355  return;
356  }
357 
358  G4OpenGLViewer* pOGLViewer = dynamic_cast<G4OpenGLViewer*>(pViewer);
359  if (!pOGLViewer) {
360  G4cout <<
361  "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type"
362  "\n OGL. (It is \""
363  << pViewer->GetName() <<
364  "\".)\n Use \"/vis/viewer/select\" or \"/vis/open\"."
365  << G4endl;
366  return;
367  }
368 
369  G4OpenGLSceneHandler* pOGLSceneHandler =
370  dynamic_cast<G4OpenGLSceneHandler*>(pSceneHandler);
371  if (!pOGLSceneHandler) {
372  G4cout <<
373  "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type"
374  "\n OGL. (Viewer is \"" << pViewer->GetName() << "\".)"
375  "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)"
376  "\n Use \"/vis/sceneHandler/list\" and \"/vis/sceneHandler/select\""
377  "\n or \"/vis/open\"."
378  << G4endl;
379  return;
380  }
381 
382  if (command == fpCommandPrintEPS)
383  {
384  pOGLViewer->setExportImageFormat("eps",true);
385  pOGLViewer->exportImage();
386 
387  if (pOGLViewer->fVP.IsAutoRefresh())
388  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
389  return;
390  }
391 
392  if (command == fpCommandExportFormat)
393  {
394  G4String name;
395  std::istringstream iss(newValue);
396  iss >> name;
397  pOGLViewer->setExportImageFormat(name);
398 
399  return;
400  }
401 
402  if (command == fpCommandExport)
403  {
404  G4String name;
405  G4int width,height;
406  std::istringstream iss(newValue);
407  iss >> name >> width >> height;
408  pOGLViewer->exportImage(name, width, height);
409 
410  if (pOGLViewer->fVP.IsAutoRefresh())
411  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
412  return;
413  }
414 
415  if (command == fpCommandPrintSize)
416  {
417  G4int width,height;
418  std::istringstream iss(newValue);
419  iss >> width
420  >> height;
421  pOGLViewer->setExportSize(width,height);
422  return;
423  }
424 
425  if (command == fpCommandPrintFilename)
426  {
427  G4String name;
428  G4bool inc;
429  std::istringstream iss(newValue);
430  iss >> name
431  >> inc;
432  pOGLViewer->setExportFilename(name,inc);
433  return;
434  }
435 
436  if (command == fpCommandPrintMode)
437  {
438  if (newValue == "vectored") pOGLViewer->fVectoredPs = true;
439  if (newValue == "pixmap") pOGLViewer->fVectoredPs = false;
440  return;
441  }
442 
443  if (command == fpCommandTransparency)
444  {
445  pOGLViewer->transparency_enabled = command->ConvertToBool(newValue);
446  if (pOGLViewer->fVP.IsAutoRefresh())
447  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
448  return;
449  }
450 
451  if (command == fpCommandEventsDrawInterval)
452  {
453  G4int entitiesFlushInterval =
454  fpCommandEventsDrawInterval->GetNewIntValue(newValue);
455  pOGLSceneHandler->SetFlushAction(G4OpenGLSceneHandler::NthPrimitive);
456  pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
457  return;
458  }
459 
460  if (command == fpCommandFlushAt)
461  {
462 // G4bool firstTime = true;
463  std::map<G4String,G4OpenGLSceneHandler::FlushAction> actionMap;
464 // if (firstTime) {
465  actionMap["endOfEvent"] = G4OpenGLSceneHandler::endOfEvent;
466  actionMap["endOfRun"] = G4OpenGLSceneHandler::endOfRun;
467  actionMap["eachPrimitive"] = G4OpenGLSceneHandler::eachPrimitive;
468  actionMap["NthPrimitive"] = G4OpenGLSceneHandler::NthPrimitive;
469  actionMap["NthEvent"] = G4OpenGLSceneHandler::NthEvent;
470  actionMap["never"] = G4OpenGLSceneHandler::never;
471 // firstTime = false;
472 // }
473  G4String action;
474  G4int entitiesFlushInterval;
475  std::istringstream iss(newValue);
476  iss >> action >> entitiesFlushInterval;
477  pOGLSceneHandler->SetFlushAction(actionMap[action]);
478  pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
479  return;
480  }
481 
482  G4OpenGLStoredViewer* pOGLSViewer =
483  dynamic_cast<G4OpenGLStoredViewer*>(pViewer);
484 
485  if (!pOGLSViewer)
486  {
487  G4cout <<
488  "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS."
489  "\n (It is \"" << pViewer->GetName() << "\".)"
490  "\n This feature is only implemented for OGL Stored viewers."
491  "\n Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
492  << G4endl;
493  return;
494  }
495 
496  if (command == fpCommandDisplayHeadTime)
497  {
498  G4String display;
499  G4double screenX, screenY, screenSize, red, green, blue;
500  std::istringstream iss(newValue);
501  iss >> display >> screenX >> screenY
502  >> screenSize >> red >> green >> blue;
503  pOGLSViewer->fDisplayHeadTime = command->ConvertToBool(display);
504  pOGLSViewer->fDisplayHeadTimeX = screenX;
505  pOGLSViewer->fDisplayHeadTimeY = screenY;
506  pOGLSViewer->fDisplayHeadTimeSize = screenSize;
507  pOGLSViewer->fDisplayHeadTimeRed = red;
508  pOGLSViewer->fDisplayHeadTimeGreen = green;
509  pOGLSViewer->fDisplayHeadTimeBlue = blue;
510  return;
511  }
512 
513  if (command == fpCommandDisplayLightFront)
514  {
515  G4String display, originX, originY, originZ, unitS, originT, unitT;
516  G4double red, green, blue;
517  std::istringstream iss(newValue);
518  iss >> display
519  >> originX >> originY >> originZ >> unitS
520  >> originT >> unitT
521  >> red >> green >> blue;
522  pOGLSViewer->fDisplayLightFront = command->ConvertToBool(display);
523  pOGLSViewer->fDisplayLightFrontX =
524  command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS));
525  pOGLSViewer->fDisplayLightFrontY =
526  command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS));
527  pOGLSViewer->fDisplayLightFrontZ =
528  command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS));
529  pOGLSViewer->fDisplayLightFrontT =
530  command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT));
531  pOGLSViewer->fDisplayLightFrontRed = red;
532  pOGLSViewer->fDisplayLightFrontGreen = green;
533  pOGLSViewer->fDisplayLightFrontBlue = blue;
534  return;
535  }
536 
537  if (command == fpCommandEndTime)
538  {
539  G4String end_time_string, end_time_unit,
540  time_range_string, time_range_unit;
541  std::istringstream iss(newValue);
542  iss >> end_time_string >> end_time_unit
543  >> time_range_string >> time_range_unit;
544  pOGLSViewer->fEndTime = command->ConvertToDimensionedDouble
545  (G4String(end_time_string + ' ' + end_time_unit));
546  G4double timeRange = command->ConvertToDimensionedDouble
547  (G4String(time_range_string + ' ' + time_range_unit));
548  if (timeRange > 0.) {
549  pOGLSViewer->fStartTime = pOGLSViewer->fEndTime - timeRange;
550  }
551  if (pOGLSViewer->fVP.IsAutoRefresh())
552  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
553  return;
554  }
555 
556  if (command == fpCommandFade)
557  {
558  pOGLSViewer->fFadeFactor = command->ConvertToDouble(newValue);
559  if (pOGLSViewer->fVP.IsAutoRefresh())
560  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
561  return;
562  }
563 
564  if (command == fpCommandStartTime)
565  {
566  G4String start_time_string, start_time_unit,
567  time_range_string, time_range_unit;
568  std::istringstream iss(newValue);
569  iss >> start_time_string >> start_time_unit
570  >> time_range_string >> time_range_unit;
571  pOGLSViewer->fStartTime = command->ConvertToDimensionedDouble
572  (G4String(start_time_string + ' ' + start_time_unit));
573  G4double timeRange = command->ConvertToDimensionedDouble
574  (G4String(time_range_string + ' ' + time_range_unit));
575  if (timeRange > 0.) {
576  pOGLSViewer->fEndTime = pOGLSViewer->fStartTime + timeRange;
577  }
578  if (pOGLSViewer->fVP.IsAutoRefresh())
579  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
580  return;
581  }
582 
583  G4OpenGLStoredSceneHandler* pOGLSSceneHandler =
584  dynamic_cast<G4OpenGLStoredSceneHandler*>(pViewer->GetSceneHandler());
585 
586  if (!pOGLSSceneHandler) {
587  G4cout <<
588  "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type"
589  "\n OGLS (Stored). (Viewer is \"" << pViewer->GetName() << "\".)"
590  "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)"
591  "\n This feature is only implemented for OGL Stored"
592  "\n scene handlers. Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
593  << G4endl;
594  return;
595  }
596 
597  if (command == fpCommandDisplayListLimit)
598  {
599  G4int displayListLimit =
600  fpCommandDisplayListLimit->GetNewIntValue(newValue);
601  pOGLSSceneHandler->SetDisplayListLimit(displayListLimit);
602  return;
603  }
604 }
605 
606 #endif
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
const G4String & GetName() const
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
const XML_Char * name
Definition: expat.h:151
Definition: test07.cc:36
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)
void SetDefaultValue(const char *theDefaultValue)
const G4String & GetName() const
#define width
void SetNewValue(G4UIcommand *, G4String)
Definition: test07.cc:36
int G4int
Definition: G4Types.hh:78
static G4double ConvertToDimensionedDouble(const char *st)
Definition: G4UIcommand.cc:463
void SetDefaultValue(G4bool defVal)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4GLOB_DLL std::ostream G4cout
static G4OpenGLViewerMessenger * GetInstance()
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:437
bool G4bool
Definition: G4Types.hh:79
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
static G4VisManager * GetInstance()
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:455
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4VSceneHandler * GetSceneHandler() const
void SetDefaultValue(G4double defVal)
void SetCandidates(const char *candidateList)
#define G4endl
Definition: G4ios.hh:61
G4VViewer * GetCurrentViewer() const
void SetDefaultValue(G4int defVal)
double G4double
Definition: G4Types.hh:76
void SetGuidance(const char *theGuidance)
#define DBL_MAX
Definition: templates.hh:83
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447