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 const auto phi = gopts->getOptionMapInNode(
"dawn",
"phi");
75 const auto theta = gopts->getOptionMapInNode(
"dawn",
"theta");
76 if (phi && !phi.IsNull()) gdawn.
phi = phi.as<std::string>();
77 if (theta && !theta.IsNull()) gdawn.
theta = theta.as<std::string>();
85 decorations.
scale = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"scale",
false);
86 decorations.
scaleLength = getOptionValueOrDefault<double>(gopts,
"g4decoration",
"scaleLength", 10.0);
87 decorations.
scaleUnit = getOptionValueOrDefault<std::string>(gopts,
"g4decoration",
"scaleUnit",
"mm");
88 decorations.
scaleDirection = getOptionValueOrDefault<std::string>(gopts,
"g4decoration",
"scaleDirection",
"z");
89 decorations.
scaleColor = getOptionValueOrDefault<std::string>(gopts,
"g4decoration",
"scaleColor",
"0.9 0.9 0.9");
90 decorations.
axes = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"axes",
false);
91 decorations.
eventID = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"eventID",
false);
92 decorations.
eventIDSize = getOptionValueOrDefault<int>(gopts,
"g4decoration",
"eventIDSize", 24);
93 decorations.
date = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"date",
false);
94 decorations.
dateSize = getOptionValueOrDefault<int>(gopts,
"g4decoration",
"dateSize", 24);
95 decorations.
logo2D = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"logo2D",
false);
96 decorations.
logo = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"logo",
false);
97 decorations.
frame = getOptionValueOrDefault<bool>(gopts,
"g4decoration",
"frame",
false);
98 decorations.
frameColor = getOptionValueOrDefault<std::string>(gopts,
"g4decoration",
"frameColor",
"red");
99 decorations.
frameLineWidth = getOptionValueOrDefault<double>(gopts,
"g4decoration",
"frameLineWidth", 2.0);
114 std::vector<GVariable> g4view = {
116 "Geant4 visualization driver. See the detailed help for driver tradeoffs. "},
120 {
"background",
"0 0.07059 0.16863",
"Geant4 viewer background color as '<red> <green> <blue>'"},
121 {
"cloudPoints", 1000,
"Number of points used for cloud volume rendering"}
124 help =
"Defines the Geant4 viewer properties: \n ";
125 help +=
" - screen dimensions \n ";
126 help +=
" - screen position \n ";
127 help +=
" - resolution in terms of segments per circle \n \n ";
128 help +=
" - viewer background color as '<red> <green> <blue>' \n ";
129 help +=
" - number of cloud points for cloud volume rendering \n \n ";
130 help +=
"Viewer drivers (interactive-driver availability depends on the Geant4 build and platform):\n";
131 help +=
" - ASCIITree (ATree): writes the geometry hierarchy as text; headless, but not graphical.\n";
132 help +=
" - DAWNFILE (DAWNFILE): exports for high-quality DAWN rendering; external DAWN is required.\n";
133 help +=
" - RayTracer (RT): software ray tracing to JPEG; realistic, but slower and not interactive.\n";
134 help +=
" - VRML2FILE (VRML2FILE): exports a portable 3D scene for an external VRML viewer.\n";
135 help +=
" - gMocrenFile (gMocrenFile): exports medical volume data for the specialized gMocren viewer.\n";
136 help +=
" - TOOLSSG_OFFSCREEN (TSG_OFFSCREEN, TSG_FILE): headless image/vector output for batch jobs.\n";
137 help +=
" - OpenGLImmediateQt (OGLIQt, OGLI): Qt/OpenGL with low scene memory, but slower redraws.\n";
138 help +=
" - OpenGLStoredQt (OGLSQt, OGLS): Qt/OpenGL with fast redraw and picking; uses more memory.\n";
139 help +=
" - OpenGLImmediateX (OGLIX, OGLIQt_FALLBACK): X11/OpenGL immediate mode; requires X.\n";
140 help +=
" - OpenGLStoredX (OGLSX, OGLSQt_FALLBACK): fast X11/OpenGL redraw; uses more memory.\n";
141 help +=
" - RayTracerX (RTX): ray-traced JPEG plus an X window; high quality, but slow and X-only.\n";
142 help +=
" - TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG_QT_GLES_FALLBACK): interactive "
143 "X11/GLES; avoids Qt, but requires an X server and GLES support.\n\n";
144 help +=
" Examples: \n \n ";
145 help +=
" -g4view=\"[{dimension: 1200x1000}]\"\n";
146 help +=
" -g4view=\"[{driver: OGL, dimension: 1100x800, position: +200+100, segsPerCircle: 100, background: 0 0.07059 0.16863}]\" \n";
147 help +=
" -g4view=\"[{driver: TOOLSSG_OFFSCREEN, segsPerCircle: 200, cloudPoints: 3000}]\" takes a screenshot at the end of each run \n";
149 goptions.defineOption(
"g4view",
"Defines the geant4 viewer properties", g4view, help);
152 std::vector<GVariable> g4camera = {
153 {
"phi",
"0*deg",
"Geant4 camera phi"},
154 {
"theta",
"0*deg",
"Geant4 camera theta"}
157 help =
"Defines the geant4 camera view point \n \n ";
158 help +=
"Example: -g4camera=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
160 goptions.defineOption(
"g4camera",
"Defines the geant4 camera view point", g4camera, help);
163 std::vector<GVariable> g4light = {
164 {
"phi",
"0*deg",
"Geant4 light source phi"},
165 {
"theta",
"0*deg",
"Geant4 light source theta"}
168 help =
"Defines the geant4 light source direction \n \n ";
169 help +=
"Example: -g4light=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
171 goptions.defineOption(
"g4light",
"Defines the geant4 light source direction", g4light, help);
174 help =
"Defines the dawn camera view point and takes a dawn screenshot \n \n ";
175 help +=
"Example: -dawn=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
177 std::vector<GVariable> dawn = {
178 {
"phi",
"30*deg",
"dawn camera phi"},
179 {
"theta",
"30*deg",
"dawn camera theta"}
182 goptions.defineOption(
"dawn",
"Defines the dawn view point", dawn, help);
183 goptions.defineSwitch(
"useDawn",
"Take a dawn screenshot");
186 std::vector<GVariable> g4decoration = {
187 {
"scale",
false,
"add a simple scale line"},
188 {
"scaleLength", 10.0,
"scale length"},
189 {
"scaleUnit",
"mm",
"scale length unit"},
190 {
"scaleDirection",
"z",
"scale direction: x, y, or z"},
191 {
"scaleColor",
"0.9 0.9 0.9",
"scale color as 'r g b' or a named color"},
192 {
"axes",
false,
"add simple XYZ axes"},
193 {
"eventID",
false,
"add event ID text at end of event"},
194 {
"eventIDSize", 24,
"event ID font size in points"},
195 {
"date",
false,
"add a date stamp"},
196 {
"dateSize", 24,
"date font size in points"},
197 {
"logo2D",
false,
"add the 2D Geant4 logo"},
198 {
"logo",
false,
"add the 3D Geant4 logo"},
199 {
"frame",
false,
"add a frame around the view"},
200 {
"frameColor",
"red",
"frame color"},
201 {
"frameLineWidth", 2.0,
"frame line width"}
204 help =
"Adds optional Geant4 scene decorations. \n \n";
205 help +=
"Example: -g4decoration=\"[{scale: true, axes: true, eventID: true, date: true, logo2D: true, logo: true, frame: true}]\" \n";
207 goptions.defineOption(
"g4decoration",
"Adds optional Geant4 scene decorations", g4decoration, help);
209 help =
"Display magnetic field lines in the initial visualization scene. \n \n";
210 help +=
"The value is the number of field-line integration points. Set to 0 to disable. \n \n";
211 help +=
"Example: -show_field_lines=100 \n";
212 goptions.defineOption(
GVariable(
"show_field_lines", 0,
"number of field-line points to display"), help);
214 help =
"Display auxiliary edges in the initial visualization scene. \n \n";
215 help +=
"Example: -show_auxiliary_edges=true \n";
216 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.
Option structures and helpers for g4display configuration.
constexpr const char * G4SCENE_LOGGER
constexpr const char * G4DISPLAY_LOGGER
constexpr char GDEFAULTVIEWERSIZE[]
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.
constexpr int GDEFAULTVSEGPERCIRCLE
constexpr char GDEFAULTVIEWERPOS[]
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.
constexpr char GDEFAULTVIEWERDRIVER[]
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.
std::optional< std::string > phi
std::optional< std::string > theta
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.