45G4OpenGLViewerMessenger::fpInstance = 0;
54G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
59 fpDirectory->
SetGuidance(
"G4OpenGLViewer commands.");
63 fpCommandExport->
SetGuidance (
"Export a screenshot of current OpenGL viewer");
65 (
"If name is \"\", filename and extension will have the current value");
67 (
"If name is \"toto.png\", set the name to \"toto\" and the format to \"png\".");
69 (
"If name is \"toto\", set the name to \"toto\" and the format to current format.");
71 (
"Will also add an incremented suffix at the end of the name, except if name is"
72 "\nthe same as previous it will not reset the incremented suffix.");
74 (
"Setting size is available only on eps/pdf/svg/ps formats.");
76 parameterExport =
new G4UIparameter (
"name",
's', omitable =
true);
79 (
"By default, will take a default value or the last \"/vis/ogl/set/printFilename\""
82 parameterExport =
new G4UIparameter (
"width",
'd', omitable =
true);
84 (
"By default, will take the current width of the viewer or \"/vis/ogl/set/printSize\""
85 "\nif set. This parameter is only useful for eps/pdf/svg/ps formats !");
88 parameterExport =
new G4UIparameter (
"height",
'd', omitable =
true);
90 (
"By default, will take the current height of the viewer or \"/vis/ogl/set/printSize\""
91 "\nif set. This parameter is only useful for eps/pdf/svg/ps formats !");
95 fpCommandFlushAt =
new G4UIcommand(
"/vis/ogl/flushAt",
this);
97 (
"Controls the rate at which graphics primitives are flushed to screen.");
99 (
"Flushing to screen is an expensive operation so to speed drawing choose"
100 "\nan action suitable for your application. Note that detectors are flushed"
101 "\nto screen anyway at end of drawing, and events are flushed to screen"
102 "\nanyway depending on /vis/scene/endOfEventAction and endOfRunAction.");
104 (
"For NthPrimitive and NthEvent the second parameter N is operative.");
106 (
"For \"never\", detectors and events are still flushed as described above.");
108 parameterFlushAt =
new G4UIparameter (
"action",
's', omitable =
true);
110 (
"endOfEvent endOfRun eachPrimitive NthPrimitive NthEvent never");
113 parameterFlushAt =
new G4UIparameter (
"N",
'i', omitable =
true);
118 fpDirectorySet->
SetGuidance(
"G4OpenGLViewer set commands.");
120 fpCommandDisplayListLimit =
123 (
"This command is no longer relevant. There is no longer any limit on the"
124 "\nnumber of display lists - except, of course, the available memory in"
125 "\nyour computer. Keep an eye on that. Good luck!");
127 fpCommandExportFormat =
128 new G4UIcommand(
"/vis/ogl/set/exportFormat",
this);
129 fpCommandExportFormat->
SetGuidance (
"Set export format");
130 fpCommandExportFormat->
SetGuidance (
"By default, pdf/eps/svg/ps are available. Depending of viewers several other format are available.");
131 fpCommandExportFormat->
SetGuidance (
"Try /vis/ogl/set/exportFormat without parameters to see them.");
132 fpCommandExportFormat->
SetGuidance (
"Changing format will reset the incremental suffix to 0.");
134 parameterExportFormat =
new G4UIparameter (
"format",
's', omitable =
true);
136 fpCommandExportFormat->
SetParameter(parameterExportFormat);
138 fpCommandPrintFilename =
139 new G4UIcommand(
"/vis/ogl/set/printFilename",
this);
140 fpCommandPrintFilename->
SetGuidance (
"Set print filename");
141 fpCommandPrintFilename->
SetGuidance (
"Setting 'incremental' will increment filename by one at each new print, starting at 0");
143 parameterPrintFilename =
new G4UIparameter (
"name",
's', omitable =
true);
145 fpCommandPrintFilename->
SetParameter(parameterPrintFilename);
146 parameterPrintFilename =
new G4UIparameter (
"incremental",
'b', omitable =
true);
148 fpCommandPrintFilename->
SetParameter(parameterPrintFilename);
151 fpCommandPrintMode->
SetGuidance(
"Set print mode, only available for \"ps\" format");
158 fpCommandPrintSize->
SetGuidance (
"Set print size");
159 fpCommandPrintSize->
SetGuidance (
"Tip : -1 will mean 'print size' = 'window size'");
160 fpCommandPrintSize->
SetGuidance (
" Setting size greater than your maximum graphic card capacity , will set the size to maximum size.");
162 parameterPrintSize =
new G4UIparameter (
"width",
'd', omitable =
false);
165 parameterPrintSize =
new G4UIparameter (
"height",
'd', omitable =
false);
169 fpCommandTransparency =
172 (
"True/false to enable/disable rendering of transparent objects.");
174 (
"transparency-enabled", omitable =
true);
180 delete fpCommandTransparency;
181 delete fpCommandPrintSize;
182 delete fpCommandPrintMode;
183 delete fpCommandPrintFilename;
184 delete fpCommandExportFormat;
185 delete fpCommandDisplayListLimit;
186 delete fpDirectorySet;
187 delete fpCommandFlushAt;
188 delete fpCommandExport;
202 "G4OpenGLViewerMessenger::SetNewValue: No current viewer."
203 "\n \"/vis/open\", or similar, to get one."
209 if (!pSceneHandler) {
211 "G4OpenGLViewerMessenger::SetNewValue: This viewer has no scene handler."
212 "\n Shouldn't happen - please report circumstances."
213 "\n (Viewer is \"" << pViewer->
GetName() <<
"\".)"
214 "\n Try \"/vis/open\", or similar, to get one."
222 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type"
225 "\".)\n Use \"/vis/viewer/select\" or \"/vis/open\"."
232 if (!pOGLSceneHandler) {
234 "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type"
235 "\n OGL. (Viewer is \"" << pViewer->
GetName() <<
"\".)"
236 "\n (Scene handler is \"" << pSceneHandler->
GetName() <<
"\".)"
237 "\n Use \"/vis/sceneHandler/list\" and \"/vis/sceneHandler/select\""
238 "\n or \"/vis/open\"."
243 if (command == fpCommandExport)
247 std::istringstream iss(newValue);
248 iss >> name >> width >> height;
256 if (command == fpCommandExportFormat)
259 std::istringstream iss(newValue);
266 if (command == fpCommandFlushAt)
268 static G4bool firstTime =
true;
269 static std::map<G4String,G4OpenGLSceneHandler::FlushAction> actionMap;
280 G4int entitiesFlushInterval;
281 std::istringstream iss(newValue);
282 iss >> action >> entitiesFlushInterval;
288 if (command == fpCommandPrintFilename)
292 std::istringstream iss(newValue);
299 if (command == fpCommandPrintMode)
301 if (newValue ==
"vectored") pOGLViewer->
fVectoredPs =
true;
303 if (newValue ==
"pixmap") pOGLViewer->
fVectoredPs =
false;
307 if (command == fpCommandPrintSize)
310 std::istringstream iss(newValue);
317 if (command == fpCommandTransparency)
332 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS."
333 "\n (It is \"" << pViewer->
GetName() <<
"\".)"
334 "\n This feature is only implemented for OGL Stored viewers."
335 "\n Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
344 if (!pOGLSSceneHandler) {
346 "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type"
347 "\n OGLS (Stored). (Viewer is \"" << pViewer->
GetName() <<
"\".)"
348 "\n (Scene handler is \"" << pSceneHandler->
GetName() <<
"\".)"
349 "\n This feature is only implemented for OGL Stored"
350 "\n scene handlers. Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"."
355 if (command == fpCommandDisplayListLimit)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
static void SetFlushAction(FlushAction action)
static void SetEntitiesFlushInterval(G4int interval)
static G4OpenGLViewerMessenger * GetInstance()
~G4OpenGLViewerMessenger()
void SetNewValue(G4UIcommand *, G4String)
bool setExportImageFormat(std::string format, bool quiet=false)
bool setExportFilename(G4String name, G4bool inc=true)
void setExportSize(G4int, G4int)
G4bool transparency_enabled
virtual bool exportImage(std::string name="", int width=-1, int height=-1)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
const G4String & GetGuidanceLine(G4int i) const
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
static G4bool ConvertToBool(const char *st)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)
void SetParameterCandidates(const char *theString)
const G4String & GetName() const
const G4String & GetName() const
G4VSceneHandler * GetSceneHandler() const
G4bool IsAutoRefresh() const
G4VViewer * GetCurrentViewer() const
static G4VisManager * GetInstance()