28 #ifdef G4VIS_BUILD_OPENGL_DRIVER
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.");
71 parameterExport =
new G4UIparameter (
"name",
's', omitable =
true);
73 parameterExport->
SetGuidance(
"by default, will take a default value or the last /vis/ogl/set/printFilename value if set");
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 !");
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 !");
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.");
99 parameterFlushAt =
new G4UIparameter (
"action",
's', omitable =
true);
101 (
"endOfEvent endOfRun eachPrimitive NthPrimitive NthEvent never");
104 parameterFlushAt =
new G4UIparameter (
"N",
'i', omitable =
true);
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\".");
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);
129 parameter =
new G4UIparameter (
"screenX",
'd', omitable =
true);
134 parameter =
new G4UIparameter (
"screenY",
'd', omitable =
true);
139 parameter =
new G4UIparameter (
"screenSize",
'd', omitable =
true);
146 parameter =
new G4UIparameter (
"green",
'd', omitable =
true);
150 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
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);
172 parameter =
new G4UIparameter (
"originX",
'd', omitable =
true);
175 parameter =
new G4UIparameter (
"originY",
'd', omitable =
true);
178 parameter =
new G4UIparameter (
"originZ",
'd', omitable =
true);
181 parameter =
new G4UIparameter (
"space_unit",
's', omitable =
true);
184 parameter =
new G4UIparameter (
"originT",
'd', omitable =
true);
187 parameter =
new G4UIparameter (
"time_unit",
's', omitable =
true);
194 parameter =
new G4UIparameter (
"green",
'd', omitable =
true);
198 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
206 (
"Set/reset display list number of primitive limit (to avoid memory exhaustion).");
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);
219 parameter =
new G4UIparameter (
"end-time-unit",
's', omitable =
false);
222 parameter =
new G4UIparameter (
"time-range",
'd', omitable =
true);
225 parameter =
new G4UIparameter (
"time-range-unit",
's', omitable =
true);
232 (
"Deprecated. Use /vis/ogl/flushAt.");
234 (
"(This is equivalent to \"/vis/ogl/flushAt NthPrimitive N\"");
240 (
"DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
241 "\n 0: no fade; 1: maximum fade with time within range.");
247 new G4UIcommand(
"/vis/ogl/set/printFilename",
this);
251 parameterPrintFilename =
new G4UIparameter (
"name",
's', omitable =
true);
254 parameterPrintFilename =
new G4UIparameter (
"incremental",
'b', omitable =
true);
259 new G4UIcommand(
"/vis/ogl/set/exportFormat",
this);
265 parameterExportFormat =
new G4UIparameter (
"format",
's', omitable =
true);
270 (
"/vis/ogl/set/printMode",
this);
282 parameterPrintSize =
new G4UIparameter (
"width",
'd', omitable =
false);
285 parameterPrintSize =
new G4UIparameter (
"height",
'd', omitable =
false);
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);
297 parameter =
new G4UIparameter (
"start-time-unit",
's', omitable =
false);
300 parameter =
new G4UIparameter (
"time-range",
'd', omitable =
true);
303 parameter =
new G4UIparameter (
"time-range-unit",
's', omitable =
true);
310 (
"True/false to enable/disable rendering of transparent objects.");
312 (
"transparency-enabled", omitable =
true);
347 "G4OpenGLViewerMessenger::SetNewValue: No current viewer."
348 "\n \"/vis/open\", or similar, to get one."
354 if (!pSceneHandler) {
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."
364 G4OpenGLViewer* pOGLViewer =
dynamic_cast<G4OpenGLViewer*
>(pViewer);
367 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type"
370 "\".)\n Use \"/vis/viewer/select\" or \"/vis/open\"."
375 G4OpenGLSceneHandler* pOGLSceneHandler =
376 dynamic_cast<G4OpenGLSceneHandler*
>(pSceneHandler);
377 if (!pOGLSceneHandler) {
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\"."
390 pOGLViewer->setExportImageFormat(
"eps",
true);
391 pOGLViewer->exportImage();
393 if (pOGLViewer->fVP.IsAutoRefresh())
401 std::istringstream iss(newValue);
403 pOGLViewer->setExportImageFormat(name);
412 std::istringstream iss(newValue);
413 iss >> name >> width >> height;
414 pOGLViewer->exportImage(name, width, height);
416 if (pOGLViewer->fVP.IsAutoRefresh())
424 std::istringstream iss(newValue);
427 pOGLViewer->setExportSize(width,height);
435 std::istringstream iss(newValue);
438 pOGLViewer->setExportFilename(name,inc);
444 if (newValue ==
"vectored") pOGLViewer->fVectoredPs =
true;
445 if (newValue ==
"pixmap") pOGLViewer->fVectoredPs =
false;
451 pOGLViewer->transparency_enabled = command->
ConvertToBool(newValue);
452 if (pOGLViewer->fVP.IsAutoRefresh())
459 G4int entitiesFlushInterval =
461 pOGLSceneHandler->SetFlushAction(G4OpenGLSceneHandler::NthPrimitive);
462 pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
469 std::map<G4String,G4OpenGLSceneHandler::FlushAction> actionMap;
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;
480 G4int entitiesFlushInterval;
481 std::istringstream iss(newValue);
482 iss >> action >> entitiesFlushInterval;
483 pOGLSceneHandler->SetFlushAction(actionMap[action]);
484 pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
488 G4OpenGLStoredViewer* pOGLSViewer =
489 dynamic_cast<G4OpenGLStoredViewer*
>(pViewer);
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...\"."
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);
517 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/displayHeadTime."
524 G4String display, originX, originY, originZ, unitS, originT, unitT;
526 std::istringstream iss(newValue);
528 >> originX >> originY >> originZ >> unitS
530 >> red >> green >> blue;
531 pOGLSViewer->fVP.SetDisplayLightFront(command->
ConvertToBool(display));
532 pOGLSViewer->fVP.SetDisplayLightFrontX
534 pOGLSViewer->fVP.SetDisplayLightFrontY
536 pOGLSViewer->fVP.SetDisplayLightFrontZ
538 pOGLSViewer->fVP.SetDisplayLightFrontT
540 pOGLSViewer->fVP.SetDisplayLightFrontRed(red);
541 pOGLSViewer->fVP.SetDisplayLightFrontGreen(green);
542 pOGLSViewer->fVP.SetDisplayLightFrontBlue(blue);
544 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/displayLightFront."
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)));
560 (
G4String(time_range_string +
' ' + time_range_unit));
561 if (timeRange > 0.) {
562 pOGLSViewer->fVP.SetStartTime
563 (pOGLSViewer->fVP.GetEndTime() - timeRange);
565 if (pOGLSViewer->fVP.IsAutoRefresh())
568 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/endTime."
576 if (pOGLSViewer->fVP.IsAutoRefresh())
579 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
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)));
595 (
G4String(time_range_string +
' ' + time_range_unit));
596 if (timeRange > 0.) {
597 pOGLSViewer->fVP.SetEndTime
598 (pOGLSViewer->fVP.GetStartTime() + timeRange);
600 if (pOGLSViewer->fVP.IsAutoRefresh())
603 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/startTime."
608 G4OpenGLStoredSceneHandler* pOGLSSceneHandler =
611 if (!pOGLSSceneHandler) {
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...\"."
624 G4int displayListLimit =
626 pOGLSSceneHandler->SetDisplayListLimit(displayListLimit);