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 = {
120 {
"driver", std::string(
GDEFAULTVIEWERDRIVER),
"Geant4 visualization driver. Use TOOLSSG_OFFSCREEN in batch mode. "},
124 {
"background",
"0 0.07059 0.16863",
"Geant4 viewer background color as '<red> <green> <blue>'"},
125 {
"cloudPoints", 1000,
"Number of points used for cloud volume rendering"}
128 help =
"Defines the Geant4 viewer properties: \n ";
129 help +=
" - screen dimensions \n ";
130 help +=
" - screen position \n ";
131 help +=
" - resolution in terms of segments per circle \n \n ";
132 help +=
" - viewer background color as '<red> <green> <blue>' \n ";
133 help +=
" - number of cloud points for cloud volume rendering \n \n ";
134 help +=
" Examples: \n \n ";
135 help +=
" -g4view=\"[{dimension: 1200x1000}]\"\n";
136 help +=
" -g4view=\"[{driver: OGL, dimension: 1100x800, position: +200+100, segsPerCircle: 100, background: 0 0.07059 0.16863}]\" \n";
137 help +=
" -g4view=\"[{driver: TOOLSSG_OFFSCREEN, segsPerCircle: 200, cloudPoints: 3000}]\" takes a screenshot at the end of each run \n";
139 goptions.defineOption(
"g4view",
"Defines the geant4 viewer properties", g4view, help);
142 std::vector<GVariable> g4camera = {
143 {
"phi",
"0*deg",
"Geant4 camera phi"},
144 {
"theta",
"0*deg",
"Geant4 camera theta"}
147 help =
"Defines the geant4 camera view point \n \n ";
148 help +=
"Example: -g4camera=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
150 goptions.defineOption(
"g4camera",
"Defines the geant4 camera view point", g4camera, help);
153 std::vector<GVariable> g4light = {
154 {
"phi",
"0*deg",
"Geant4 light source phi"},
155 {
"theta",
"0*deg",
"Geant4 light source theta"}
158 help =
"Defines the geant4 light source direction \n \n ";
159 help +=
"Example: -g4light=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
161 goptions.defineOption(
"g4light",
"Defines the geant4 light source direction", g4light, help);
164 help =
"Defines the dawn camera view point and takes a dawn screenshot \n \n ";
165 help +=
"Example: -dawn=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
167 std::vector<GVariable> dawn = {
168 {
"phi",
"30*deg",
"dawn camera phi"},
169 {
"theta",
"30*deg",
"dawn camera theta"}
172 goptions.defineOption(
"dawn",
"Defines the dawn view point", dawn, help);
173 goptions.defineSwitch(
"useDawn",
"Take a dawn screenshot");
176 std::vector<GVariable> g4decoration = {
177 {
"scale",
false,
"add a simple scale line"},
178 {
"scaleLength", 10.0,
"scale length"},
179 {
"scaleUnit",
"mm",
"scale length unit"},
180 {
"scaleDirection",
"z",
"scale direction: x, y, or z"},
181 {
"scaleColor",
"0.9 0.9 0.9",
"scale color as 'r g b' or a named color"},
182 {
"axes",
false,
"add simple XYZ axes"},
183 {
"eventID",
false,
"add event ID text at end of event"},
184 {
"eventIDSize", 24,
"event ID font size in points"},
185 {
"date",
false,
"add a date stamp"},
186 {
"dateSize", 24,
"date font size in points"},
187 {
"logo2D",
false,
"add the 2D Geant4 logo"},
188 {
"logo",
false,
"add the 3D Geant4 logo"},
189 {
"frame",
false,
"add a frame around the view"},
190 {
"frameColor",
"red",
"frame color"},
191 {
"frameLineWidth", 2.0,
"frame line width"}
194 help =
"Adds optional Geant4 scene decorations. \n \n";
195 help +=
"Example: -g4decoration=\"[{scale: true, axes: true, eventID: true, date: true, logo2D: true, logo: true, frame: true}]\" \n";
197 goptions.defineOption(
"g4decoration",
"Adds optional Geant4 scene decorations", g4decoration, 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.