12YAML::Node getG4ViewValue(
const std::shared_ptr<GOptions>& gopts,
const std::string& key) {
13 auto node = gopts->getOptionNode(
"g4view");
14 if (node.IsMap() && node[key]) {
17 return gopts->getOptionMapInNode(
"g4view", key);
21T getOptionValueOrDefault(
const std::shared_ptr<GOptions>& gopts,
22 const std::string& option,
23 const std::string& key,
24 const T& defaultValue) {
25 auto node = gopts->getOptionNode(option);
27 return gopts->get_variable_in_option<T>(node, key, defaultValue);
29 return gopts->getOptionMapInNode(option, key).as<T>();
38 g4view.
driver = getG4ViewValue(gopts,
"driver").as<std::string>();
39 g4view.
dimension = getG4ViewValue(gopts,
"dimension").as<std::string>();
40 g4view.
position = getG4ViewValue(gopts,
"position").as<std::string>();
41 g4view.
segsPerCircle = getG4ViewValue(gopts,
"segsPerCircle").as<
int>();
42 g4view.
background = getG4ViewValue(gopts,
"background").as<std::string>();
43 g4view.
cloudPoints = getG4ViewValue(gopts,
"cloudPoints").as<
int>();
53 gcamera.
phi = gopts->getOptionMapInNode(
"g4camera",
"phi").as<std::string>();
54 gcamera.
theta = gopts->getOptionMapInNode(
"g4camera",
"theta").as<std::string>();
64 glight.
phi = gopts->getOptionMapInNode(
"g4light",
"phi").as<std::string>();
65 glight.
theta = gopts->getOptionMapInNode(
"g4light",
"theta").as<std::string>();
74 auto phi = gopts->getOptionMapInNode(
"dawn",
"phi").as<std::string>();
75 auto theta = gopts->getOptionMapInNode(
"dawn",
"theta").as<std::string>();
90 decorations.
scale = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"scale",
false);
91 decorations.
scaleLength = getOptionValueOrDefault<double>(gopts,
"g4decoration",
"scaleLength", 10.0);
92 decorations.
scaleUnit = getOptionValueOrDefault<std::string>(gopts,
"g4decoration",
"scaleUnit",
"mm");
93 decorations.
scaleDirection = getOptionValueOrDefault<std::string>(gopts,
"g4decoration",
"scaleDirection",
"z");
94 decorations.
scaleColor = getOptionValueOrDefault<std::string>(gopts,
"g4decoration",
"scaleColor",
"0.9 0.9 0.9");
95 decorations.
axes = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"axes",
false);
96 decorations.
eventID = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"eventID",
false);
97 decorations.
eventIDSize = getOptionValueOrDefault<int>(gopts,
"g4decoration",
"eventIDSize", 24);
98 decorations.
date = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"date",
false);
99 decorations.
dateSize = getOptionValueOrDefault<int>(gopts,
"g4decoration",
"dateSize", 24);
100 decorations.
logo2D = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"logo2D",
false);
101 decorations.
logo = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"logo",
false);
102 decorations.
frame = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"frame",
false);
103 decorations.
frameColor = getOptionValueOrDefault<std::string>(gopts,
"g4decoration",
"frameColor",
"red");
104 decorations.
frameLineWidth = getOptionValueOrDefault<double>(gopts,
"g4decoration",
"frameLineWidth", 2.0);
119 std::vector<GVariable> g4view = {
121 "Geant4 visualization driver. See the detailed help for driver tradeoffs. "},
125 {
"background",
"0 0.07059 0.16863",
"Geant4 viewer background color as '<red> <green> <blue>'"},
126 {
"cloudPoints", 1000,
"Number of points used for cloud volume rendering"}
129 help =
"Defines the Geant4 viewer properties: \n ";
130 help +=
" - screen dimensions \n ";
131 help +=
" - screen position \n ";
132 help +=
" - resolution in terms of segments per circle \n \n ";
133 help +=
" - viewer background color as '<red> <green> <blue>' \n ";
134 help +=
" - number of cloud points for cloud volume rendering \n \n ";
135 help +=
"Viewer drivers (interactive-driver availability depends on the Geant4 build and platform):\n";
136 help +=
" - ASCIITree (ATree): writes the geometry hierarchy as text; headless, but not graphical.\n";
137 help +=
" - DAWNFILE (DAWNFILE): exports for high-quality DAWN rendering; external DAWN is required.\n";
138 help +=
" - RayTracer (RT): software ray tracing to JPEG; realistic, but slower and not interactive.\n";
139 help +=
" - VRML2FILE (VRML2FILE): exports a portable 3D scene for an external VRML viewer.\n";
140 help +=
" - gMocrenFile (gMocrenFile): exports medical volume data for the specialized gMocren viewer.\n";
141 help +=
" - TOOLSSG_OFFSCREEN (TSG_OFFSCREEN, TSG_FILE): headless image/vector output for batch jobs.\n";
142 help +=
" - OpenGLImmediateQt (OGLIQt, OGLI): Qt/OpenGL with low scene memory, but slower redraws.\n";
143 help +=
" - OpenGLStoredQt (OGLSQt, OGLS): Qt/OpenGL with fast redraw and picking; uses more memory.\n";
144 help +=
" - OpenGLImmediateX (OGLIX, OGLIQt_FALLBACK): X11/OpenGL immediate mode; requires X.\n";
145 help +=
" - OpenGLStoredX (OGLSX, OGLSQt_FALLBACK): fast X11/OpenGL redraw; uses more memory.\n";
146 help +=
" - RayTracerX (RTX): ray-traced JPEG plus an X window; high quality, but slow and X-only.\n";
147 help +=
" - TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG_QT_GLES_FALLBACK): interactive "
148 "X11/GLES; avoids Qt, but requires an X server and GLES support.\n\n";
149 help +=
" Examples: \n \n ";
150 help +=
" -g4view=\"[{dimension: 1200x1000}]\"\n";
151 help +=
" -g4view=\"[{driver: OGL, dimension: 1100x800, position: +200+100, segsPerCircle: 100, background: 0 0.07059 0.16863}]\" \n";
152 help +=
" -g4view=\"[{driver: TOOLSSG_OFFSCREEN, segsPerCircle: 200, cloudPoints: 3000}]\" takes a screenshot at the end of each run \n";
154 goptions.defineOption(
"g4view",
"Defines the geant4 viewer properties", g4view, help);
157 std::vector<GVariable> g4camera = {
158 {
"phi",
"0*deg",
"Geant4 camera phi"},
159 {
"theta",
"0*deg",
"Geant4 camera theta"}
162 help =
"Defines the geant4 camera view point \n \n ";
163 help +=
"Example: -g4camera=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
165 goptions.defineOption(
"g4camera",
"Defines the geant4 camera view point", g4camera, help);
168 std::vector<GVariable> g4light = {
169 {
"phi",
"0*deg",
"Geant4 light source phi"},
170 {
"theta",
"0*deg",
"Geant4 light source theta"}
173 help =
"Defines the geant4 light source direction \n \n ";
174 help +=
"Example: -g4light=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
176 goptions.defineOption(
"g4light",
"Defines the geant4 light source direction", g4light, help);
179 help =
"Defines the dawn camera view point and takes a dawn screenshot \n \n ";
180 help +=
"Example: -dawn=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
182 std::vector<GVariable> dawn = {
183 {
"phi",
"30*deg",
"dawn camera phi"},
184 {
"theta",
"30*deg",
"dawn camera theta"}
187 goptions.defineOption(
"dawn",
"Defines the dawn view point", dawn, help);
188 goptions.defineSwitch(
"useDawn",
"Take a dawn screenshot");
191 std::vector<GVariable> g4decoration = {
192 {
"scale",
false,
"add a simple scale line"},
193 {
"scaleLength", 10.0,
"scale length"},
194 {
"scaleUnit",
"mm",
"scale length unit"},
195 {
"scaleDirection",
"z",
"scale direction: x, y, or z"},
196 {
"scaleColor",
"0.9 0.9 0.9",
"scale color as 'r g b' or a named color"},
197 {
"axes",
false,
"add simple XYZ axes"},
198 {
"eventID",
false,
"add event ID text at end of event"},
199 {
"eventIDSize", 24,
"event ID font size in points"},
200 {
"date",
false,
"add a date stamp"},
201 {
"dateSize", 24,
"date font size in points"},
202 {
"logo2D",
false,
"add the 2D Geant4 logo"},
203 {
"logo",
false,
"add the 3D Geant4 logo"},
204 {
"frame",
false,
"add a frame around the view"},
205 {
"frameColor",
"red",
"frame color"},
206 {
"frameLineWidth", 2.0,
"frame line width"}
209 help =
"Adds optional Geant4 scene decorations. \n \n";
210 help +=
"Example: -g4decoration=\"[{scale: true, axes: true, eventID: true, date: true, logo2D: true, logo: true, frame: true}]\" \n";
212 goptions.defineOption(
"g4decoration",
"Adds optional Geant4 scene decorations", g4decoration, help);
214 help =
"Display magnetic field lines in the initial visualization scene. \n \n";
215 help +=
"The value is the number of field-line integration points. Set to 0 to disable. \n \n";
216 help +=
"Example: -show_field_lines=100 \n";
217 goptions.defineOption(
GVariable(
"show_field_lines", 0,
"number of field-line points to display"), help);
219 help =
"Display auxiliary edges in the initial visualization scene. \n \n";
220 help +=
"Example: -show_auxiliary_edges=true \n";
221 goptions.defineOption(
GVariable(
"show_auxiliary_edges",
false,
"show auxiliary volume edges"), help);
Scene text option structures and helpers for the g4display module.
Conventions and constants used by the g4display module.
#define GDEFAULTVIEWERDRIVER
#define GDEFAULTVSEGPERCIRCLE
#define GDEFAULTVIEWERPOS
#define GDEFAULTVIEWERSIZE
Option structures and helpers for g4display configuration.
constexpr const char * G4SCENE_LOGGER
constexpr const char * G4DISPLAY_LOGGER
G4Light getG4Light(const std::shared_ptr< GOptions > &gopts)
Read the g4light option node and return a projected G4Light struct.
G4Dawn getG4Dawn(const std::shared_ptr< GOptions > &gopts)
Read the dawn option node and return a projected G4Dawn struct.
G4View getG4View(const std::shared_ptr< GOptions > &gopts)
Read the g4view option node and return a projected G4View struct.
GOptions addSceneTextsOptions()
Define the g4text structured option schema.
GOptions defineOptions()
Define the full set of g4display options.
G4Camera getG4Camera(const std::shared_ptr< GOptions > &gopts)
Read the g4camera option node and return a projected G4Camera struct.
G4Decorations getG4Decorations(const std::shared_ptr< GOptions > &gopts)
Read the g4decoration option node and return scene decoration settings.
Camera angle configuration derived from the g4camera option node.
DAWN view configuration derived from the dawn option node.
Optional scene decorations derived from the g4decoration option node.
std::string scaleDirection
Light angle configuration derived from the g4light option node.
Viewer configuration derived from the g4view option node.