28#ifndef G4TOOLSSGOFFSCREENVIEWER_HH
29#define G4TOOLSSGOFFSCREENVIEWER_HH
36#include <tools/toojpeg>
38#include <tools/offscreen/sg_viewer>
46 :
parent(a_session,a_scene_handler,a_name)
73 fSGViewer->set_png_writer(tools::fpng::write);
74 fSGViewer->set_jpeg_writer(tools::toojpeg::write);
128 void SetSize(
unsigned int a_w,
unsigned int a_h) {
171 cmd_format =
new G4UIcommand(
"/vis/tsg/offscreen/set/format",
this);
174 cmd_format->
SetGuidance(
"- zb_png: tools::sg offscreen zbuffer put in a png file.");
175 cmd_format->
SetGuidance(
"- zb_jpeg: tools::sg offscreen zbuffer put in a jpeg file.");
176 cmd_format->
SetGuidance(
"- zb_ps: tools::sg offscreen zbuffer put in a PostScript file.");
177 cmd_format->
SetGuidance(
"- gl2ps_eps: gl2ps producing eps");
178 cmd_format->
SetGuidance(
"- gl2ps_ps: gl2ps producing ps");
179 cmd_format->
SetGuidance(
"- gl2ps_pdf: gl2ps producing pdf");
180 cmd_format->
SetGuidance(
"- gl2ps_svg: gl2ps producing svg");
181 cmd_format->
SetGuidance(
"- gl2ps_tex: gl2ps producing tex");
182 cmd_format->
SetGuidance(
"- gl2ps_pgf: gl2ps producing pgf");
190 cmd_file =
new G4UIcommand(
"/vis/tsg/offscreen/set/file",
this);
192 cmd_file->
SetGuidance(
"Default file name is \"auto\" and default format is zb_png.");
193 cmd_file->
SetGuidance(
"If file name is \"auto\", the output file name is built from");
194 cmd_file->
SetGuidance(
"a viewer index counter with the form:");
195 cmd_file->
SetGuidance(
" g4tsg_offscreen_<format>_<index>.<format extension>");
197 cmd_file->
SetGuidance(
" g4tsg_offscreen_zb_png_1.png");
198 cmd_file->
SetGuidance(
" g4tsg_offscreen_zb_png_2.png");
200 cmd_file->
SetGuidance(
"or if format is changed to \"gl2ps_pdf\":");
201 cmd_file->
SetGuidance(
" g4tsg_offscreen_gl2ps_pdf_3.pdf");
202 cmd_file->
SetGuidance(
"If a prefix parameter is given, the output file name is built from");
203 cmd_file->
SetGuidance(
"a global index counter with the form:");
204 cmd_file->
SetGuidance(
" <prefix><index>.<format extension>");
206 cmd_file->
SetGuidance(
" /vis/tsg/offscreen/set/file auto my_prefix_");
211 cmd_file->
SetGuidance(
"You can reset the index by specifying true as last argument:");
212 cmd_file->
SetGuidance(
" /vis/tsg/offscreen/set/file auto other_prefix_ true");
232 cmd_size =
new G4UIcommand(
"/vis/tsg/offscreen/set/size",
this);
233 cmd_size->
SetGuidance(
"Set viewer size in pixels.");
235 (
"If width and/or height is set to zero, the viewer size specified with /vis/viewer/create (/vis/open) is taken.");
236 cmd_size->
SetGuidance(
" About the picture size, note that the gl2ps files will grow with the number of primitives");
237 cmd_size->
SetGuidance(
"(gl2ps does not have a zbuffer logic). The \"zb\" files will not grow with the number of");
238 cmd_size->
SetGuidance(
"primitives, but with the size of the viewer. It should be preferred for scenes with");
239 cmd_size->
SetGuidance(
"a lot of objects to render. With zb, to have a better rendering, do not hesitate to");
240 cmd_size->
SetGuidance(
"have a large viewer size.");
252 cmd_do_transparency =
new G4UIcmdWithABool(
"/vis/tsg/offscreen/set/transparency",
this);
253 cmd_do_transparency->
SetGuidance(
"True/false to enable/disable rendering of transparent objects.");
254 cmd_do_transparency->
SetGuidance(
"This may be usefull if using file formats, as the gl2ps ones, unable to handle transparency.");
260 cmd_gl2ps_sort =
new G4UIcommand(
"/vis/tsg/offscreen/gl2ps/set/sort",
this);
261 cmd_gl2ps_sort->
SetGuidance(
"Set gl2ps sort algorithm when creating the file.");
263 cmd_gl2ps_sort->
SetGuidance(
"The sort argument could be:");
267 cmd_gl2ps_sort->
SetGuidance(
"The default being BSP_SORT");
275 cmd_gl2ps_opts =
new G4UIcommand(
"/vis/tsg/offscreen/gl2ps/set/options",
this);
276 cmd_gl2ps_opts->
SetGuidance(
"Set gl2ps options passed when creating the file.");
278 cmd_gl2ps_opts->
SetGuidance(
"Options is a list of items separated by |. An item can be:");
281 cmd_gl2ps_opts->
SetGuidance(
" SIMPLE_LINE_OFFSET");
289 cmd_gl2ps_opts->
SetGuidance(
" USE_CURRENT_VIEWPORT");
292 cmd_gl2ps_opts->
SetGuidance(
" TIGHT_BOUNDING_BOX");
296 cmd_gl2ps_opts->
SetGuidance(
"The default (typical) list of options is:");
297 cmd_gl2ps_opts->
SetGuidance(
" SILENT|OCCLUSION_CULL|BEST_ROOT|DRAW_BACKGROUND");
300 parameter->
SetDefaultValue(
"SILENT|OCCLUSION_CULL|BEST_ROOT|DRAW_BACKGROUND");
305 virtual ~Messenger() {
309 delete cmd_do_transparency;
310 delete cmd_gl2ps_sort;
311 delete cmd_gl2ps_opts;
323 G4cout <<
"G4ToolsSGOffscreenViewer::Messenger::SetNewValue:"
324 <<
" current viewer is not a G4ToolsSGOffscreenViewer." <<
G4endl;
327 std::vector<std::string> args;
328 tools::double_quotes_tokenize(a_value,args);
330 if(a_cmd==cmd_format) {
332 G4cout <<
"G4ToolsSGOffscreenViewer::Messenger::SetNewValue:"
333 <<
" unknown file format " << args[0] <<
"." <<
G4endl;
337 }
else if(a_cmd==cmd_file) {
339 tsg_viewer->
SetFileName(args[0],args[1],reset_index);
340 }
else if(a_cmd==cmd_size) {
342 if(!tools::to(args[0],w)) w = 0;
343 if(!tools::to(args[1],h)) h = 0;
345 }
else if(a_cmd==cmd_do_transparency) {
348 }
else if(a_cmd==cmd_gl2ps_sort) {
350 }
else if(a_cmd==cmd_gl2ps_opts) {
371 if(a_format==
"gl2ps_eps")
return true;
372 if(a_format==
"gl2ps_ps")
return true;
373 if(a_format==
"gl2ps_pdf")
return true;
374 if(a_format==
"gl2ps_svg")
return true;
375 if(a_format==
"gl2ps_tex")
return true;
376 if(a_format==
"gl2ps_pgf")
return true;
377 if(a_format==
"zb_ps")
return true;
378 if(a_format==
"zb_png")
return true;
379 if(a_format==
"zb_jpeg")
return true;
384 if(a_format==
"gl2ps_eps") {a_ext =
"eps";
return true;}
385 if(a_format==
"gl2ps_ps") {a_ext =
"ps";
return true;}
386 if(a_format==
"gl2ps_pdf") {a_ext =
"pdf";
return true;}
387 if(a_format==
"gl2ps_svg") {a_ext =
"svg";
return true;}
388 if(a_format==
"gl2ps_tex") {a_ext =
"tex";
return true;}
389 if(a_format==
"gl2ps_pgf") {a_ext =
"pgf";
return true;}
390 if(a_format==
"zb_ps") {a_ext =
"ps";
return true;}
391 if(a_format==
"zb_png") {a_ext =
"png";
return true;}
392 if(a_format==
"zb_jpeg") {a_ext =
"jpeg";
return true;}
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
std::size_t GetParameterEntries() const
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
static G4bool ConvertToBool(const char *st)
void SetDefaultValue(const char *theDefaultValue)
G4ViewParameters fDefaultVP
static G4VisManager * GetVisManager()
void SetAutoRefresh(G4bool)
void SetGlobalMarkerScale(G4double globalMarkerScale)
G4int GetWindowAbsoluteLocationHintY(G4int) const
unsigned int GetWindowSizeHintX() const
G4int GetWindowAbsoluteLocationHintX(G4int) const
unsigned int GetWindowSizeHintY() const
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()