29 #ifdef G4VIS_BUILD_OPENGL_DRIVER
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.");
72 parameterExport =
new G4UIparameter (
"name",
's', omitable =
true);
74 parameterExport->
SetGuidance(
"by default, will take a default value or the last /vis/ogl/set/printFilename value if set");
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 !");
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 !");
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.");
100 parameterFlushAt =
new G4UIparameter (
"action",
's', omitable =
true);
102 (
"endOfEvent endOfRun eachPrimitive NthPrimitive NthEvent never");
105 parameterFlushAt =
new G4UIparameter (
"N",
'i', omitable =
true);
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\".");
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);
130 parameter =
new G4UIparameter (
"screenX",
'd', omitable =
true);
135 parameter =
new G4UIparameter (
"screenY",
'd', omitable =
true);
140 parameter =
new G4UIparameter (
"screenSize",
'd', omitable =
true);
147 parameter =
new G4UIparameter (
"green",
'd', omitable =
true);
151 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
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);
173 parameter =
new G4UIparameter (
"originX",
'd', omitable =
true);
176 parameter =
new G4UIparameter (
"originY",
'd', omitable =
true);
179 parameter =
new G4UIparameter (
"originZ",
'd', omitable =
true);
182 parameter =
new G4UIparameter (
"space_unit",
's', omitable =
true);
185 parameter =
new G4UIparameter (
"originT",
'd', omitable =
true);
188 parameter =
new G4UIparameter (
"time_unit",
's', omitable =
true);
195 parameter =
new G4UIparameter (
"green",
'd', omitable =
true);
199 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
207 (
"Set/reset display list limit (to avoid memory exhaustion).");
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);
220 parameter =
new G4UIparameter (
"end-time-unit",
's', omitable =
false);
223 parameter =
new G4UIparameter (
"time-range",
'd', omitable =
true);
226 parameter =
new G4UIparameter (
"time-range-unit",
's', omitable =
true);
233 (
"Deprecated. Use /vis/ogl/flushAt.");
235 (
"(This is equivalent to \"/vis/ogl/flushAt NthPrimitive N\"");
241 (
"DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
242 "\n 0: no fade; 1: maximum fade with time within range.");
248 new G4UIcommand(
"/vis/ogl/set/printFilename",
this);
252 parameterPrintFilename =
new G4UIparameter (
"name",
's', omitable =
true);
255 parameterPrintFilename =
new G4UIparameter (
"incremental",
'b', omitable =
true);
260 new G4UIcommand(
"/vis/ogl/set/exportFormat",
this);
266 parameterExportFormat =
new G4UIparameter (
"format",
's', omitable =
true);
271 (
"/vis/ogl/set/printMode",
this);
283 parameterPrintSize =
new G4UIparameter (
"width",
'd', omitable =
false);
286 parameterPrintSize =
new G4UIparameter (
"height",
'd', omitable =
false);
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);
298 parameter =
new G4UIparameter (
"start-time-unit",
's', omitable =
false);
301 parameter =
new G4UIparameter (
"time-range",
'd', omitable =
true);
304 parameter =
new G4UIparameter (
"time-range-unit",
's', omitable =
true);
311 (
"True/false to enable/disable rendering of transparent objects.");
313 (
"transparency-enabled", omitable =
true);
348 "G4OpenGLViewerMessenger::SetNewValue: No current viewer."
349 "\n \"/vis/open\", or similar, to get one."
355 if (!pSceneHandler) {
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."
365 G4OpenGLViewer* pOGLViewer =
dynamic_cast<G4OpenGLViewer*
>(pViewer);
368 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type"
371 "\".)\n Use \"/vis/viewer/select\" or \"/vis/open\"."
376 G4OpenGLSceneHandler* pOGLSceneHandler =
377 dynamic_cast<G4OpenGLSceneHandler*
>(pSceneHandler);
378 if (!pOGLSceneHandler) {
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\"."
391 pOGLViewer->setExportImageFormat(
"eps",
true);
392 pOGLViewer->exportImage();
394 if (pOGLViewer->fVP.IsAutoRefresh())
402 std::istringstream iss(newValue);
404 pOGLViewer->setExportImageFormat(name);
413 std::istringstream iss(newValue);
414 iss >> name >> width >> height;
415 pOGLViewer->exportImage(name, width, height);
417 if (pOGLViewer->fVP.IsAutoRefresh())
425 std::istringstream iss(newValue);
428 pOGLViewer->setExportSize(width,height);
436 std::istringstream iss(newValue);
439 pOGLViewer->setExportFilename(name,inc);
445 if (newValue ==
"vectored") pOGLViewer->fVectoredPs =
true;
446 if (newValue ==
"pixmap") pOGLViewer->fVectoredPs =
false;
452 pOGLViewer->transparency_enabled = command->
ConvertToBool(newValue);
453 if (pOGLViewer->fVP.IsAutoRefresh())
460 G4int entitiesFlushInterval =
462 pOGLSceneHandler->SetFlushAction(G4OpenGLSceneHandler::NthPrimitive);
463 pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
470 std::map<G4String,G4OpenGLSceneHandler::FlushAction> actionMap;
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;
481 G4int entitiesFlushInterval;
482 std::istringstream iss(newValue);
483 iss >> action >> entitiesFlushInterval;
484 pOGLSceneHandler->SetFlushAction(actionMap[action]);
485 pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
489 G4OpenGLStoredViewer* pOGLSViewer =
490 dynamic_cast<G4OpenGLStoredViewer*
>(pViewer);
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...\"."
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);
518 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/displayHeadTime."
525 G4String display, originX, originY, originZ, unitS, originT, unitT;
527 std::istringstream iss(newValue);
529 >> originX >> originY >> originZ >> unitS
531 >> red >> green >>
blue;
532 pOGLSViewer->fVP.SetDisplayLightFront(command->
ConvertToBool(display));
533 pOGLSViewer->fVP.SetDisplayLightFrontX
535 pOGLSViewer->fVP.SetDisplayLightFrontY
537 pOGLSViewer->fVP.SetDisplayLightFrontZ
539 pOGLSViewer->fVP.SetDisplayLightFrontT
541 pOGLSViewer->fVP.SetDisplayLightFrontRed(red);
542 pOGLSViewer->fVP.SetDisplayLightFrontGreen(green);
543 pOGLSViewer->fVP.SetDisplayLightFrontBlue(blue);
545 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/displayLightFront."
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)));
561 (
G4String(time_range_string +
' ' + time_range_unit));
562 if (timeRange > 0.) {
563 pOGLSViewer->fVP.SetStartTime
564 (pOGLSViewer->fVP.GetEndTime() - timeRange);
566 if (pOGLSViewer->fVP.IsAutoRefresh())
569 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/endTime."
577 if (pOGLSViewer->fVP.IsAutoRefresh())
580 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
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)));
596 (
G4String(time_range_string +
' ' + time_range_unit));
597 if (timeRange > 0.) {
598 pOGLSViewer->fVP.SetEndTime
599 (pOGLSViewer->fVP.GetStartTime() + timeRange);
601 if (pOGLSViewer->fVP.IsAutoRefresh())
604 <<
"DEPRECATED. Use /vis/viewer/set/timeWindow/startTime."
609 G4OpenGLStoredSceneHandler* pOGLSSceneHandler =
612 if (!pOGLSSceneHandler) {
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...\"."
625 G4int displayListLimit =
627 pOGLSSceneHandler->SetDisplayListLimit(displayListLimit);
const G4String & GetName() const
void SetGuidance(const char *aGuidance)
G4UIcommand * fpCommandStartTime
static G4double ConvertToDouble(const char *st)
G4UIcmdWithAnInteger * fpCommandEventsDrawInterval
static constexpr G4double fVeryLongTime
G4UIcommand * fpCommandFlushAt
G4int ApplyCommand(const char *aCommand)
void SetDefaultValue(G4bool defVal)
G4UIdirectory * fpDirectory
void SetDefaultValue(G4int defVal)
~G4OpenGLViewerMessenger()
G4UIdirectory * fpDirectorySet
static G4bool ConvertToBool(const char *st)
static G4VisManager * GetInstance()
void SetRange(const char *rs)
void SetNewValue(G4UIcommand *, G4String)
void SetDefaultValue(const char *defVal)
static G4OpenGLViewerMessenger * GetInstance()
G4UIcmdWithAString * fpCommandPrintMode
void SetGuidance(const char *theGuidance)
static G4UImanager * GetUIpointer()
void SetParameterRange(const char *theRange)
G4UIcmdWithADouble * fpCommandFade
void SetParameter(G4UIparameter *const newParameter)
void SetDefaultValue(const char *theDefaultValue)
G4VSceneHandler * GetSceneHandler() const
static G4OpenGLViewerMessenger * fpInstance
G4UIcommand * fpCommandExport
G4UIcommand * fpCommandDisplayLightFront
G4UIcommand * fpCommandPrintFilename
G4VViewer * GetCurrentViewer() const
G4UIcommand * fpCommandPrintSize
const G4String & GetName() const
void SetCandidates(const char *candidateList)
G4UIcommand * fpCommandEndTime
G4UIcommand * fpCommandDisplayHeadTime
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
G4OpenGLViewerMessenger()
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithoutParameter * fpCommandPrintEPS
G4UIcmdWithAnInteger * fpCommandDisplayListLimit
static G4double ConvertToDimensionedDouble(const char *st)
void SetParameterCandidates(const char *theString)
G4UIcommand * fpCommandExportFormat