g4display
Loading...
Searching...
No Matches
g4display_options.cc
Go to the documentation of this file.
1
// g4display_options.cc
2
//
3
// Implementation of g4display option projection and option schema definition.
4
// Doxygen documentation for public behavior is authoritative in g4display_options.h (see rule 7).
5
6
#include "
g4display_options.h
"
7
#include "
g4displayConventions.h
"
8
#include "
g4Text.h
"
9
10
namespace
g4display
{
11
// Read g4view option and return a projected G4View struct.
12
G4View
getG4View
(
const
std::shared_ptr<GOptions>& gopts) {
13
G4View
g4view;
14
15
// Project the YAML-like option node values into strongly-typed fields.
16
g4view.
driver
= gopts->getOptionMapInNode(
"g4view"
,
"driver"
).as<std::string>();
17
g4view.
dimension
= gopts->getOptionMapInNode(
"g4view"
,
"dimension"
).as<std::string>();
18
g4view.
position
= gopts->getOptionMapInNode(
"g4view"
,
"position"
).as<std::string>();
19
g4view.
segsPerCircle
= gopts->getOptionMapInNode(
"g4view"
,
"segsPerCircle"
).as<
int
>();
20
21
return
g4view;
22
}
23
24
// Read the g4camera option and return a G4Camera struct.
25
G4Camera
getG4Camera
(
const
std::shared_ptr<GOptions>& gopts) {
26
G4Camera
gcamera;
27
28
// Camera angles are stored as strings (often with units), and can be parsed later.
29
gcamera.
phi
= gopts->getOptionMapInNode(
"g4camera"
,
"phi"
).as<std::string>();
30
gcamera.
theta
= gopts->getOptionMapInNode(
"g4camera"
,
"theta"
).as<std::string>();
31
32
return
gcamera;
33
}
34
35
// Read the g4light option and return a G4Light struct.
36
G4Light
getG4Light
(
const
std::shared_ptr<GOptions>& gopts) {
37
G4Light
glight;
38
39
// Light angles are stored as strings (often with units), and can be parsed later.
40
glight.
phi
= gopts->getOptionMapInNode(
"g4light"
,
"phi"
).as<std::string>();
41
glight.
theta
= gopts->getOptionMapInNode(
"g4light"
,
"theta"
).as<std::string>();
42
43
return
glight;
44
}
45
46
// Read the dawn options and return a G4Dawn struct.
47
G4Dawn
getG4Dawn
(
const
std::shared_ptr<GOptions>& gopts) {
48
G4Dawn
gdawn;
49
50
auto
phi = gopts->getOptionMapInNode(
"dawn"
,
"phi"
).as<std::string>();
51
auto
theta = gopts->getOptionMapInNode(
"dawn"
,
"theta"
).as<std::string>();
52
53
// Normalize explicit "null" (string) to the “not defined” sentinel used by options.
54
if
(phi ==
"null"
) phi =
goptions::NODFLT
;
55
if
(theta ==
"null"
) theta =
goptions::NODFLT
;
56
57
gdawn.
phi
= phi;
58
gdawn.
theta
= theta;
59
60
return
gdawn;
61
}
62
63
// Define and return the option set for the g4display module.
64
GOptions
defineOptions
() {
65
GOptions
goptions
(
G4DISPLAY_LOGGER
);
66
67
// The module also defines options for g4scene helpers (same executable context).
68
goptions
+=
GOptions
(
G4SCENE_LOGGER
);
69
70
std::string help;
71
72
// g4view
73
std::vector<GVariable> g4view = {
74
{
"driver"
, std::string(
GDEFAULTVIEWERDRIVER
),
"Geant4 visualization driver. Use TOOLSSG_OFFSCREEN in batch mode. "
},
75
{
"dimension"
, std::string(
GDEFAULTVIEWERSIZE
),
"Geant4 viewer dimension"
},
76
{
"position"
, std::string(
GDEFAULTVIEWERPOS
),
"Geant4 viewer position"
},
77
{
"segsPerCircle"
,
GDEFAULTVSEGPERCIRCLE
,
"Number of segments per circle"
}
78
};
79
80
help =
"Defines the Geant4 viewer properties: \n "
;
81
help +=
" - screen dimensions \n "
;
82
help +=
" - screen position \n "
;
83
help +=
" - resolution in terms of segments per circle \n \n "
;
84
help +=
" Examples: \n \n "
;
85
help +=
" -g4view=\"[{dimension: 1200x1000}]\"\n"
;
86
help +=
" -g4view=\"[{driver: OGL, dimension: 1100x800, position: +200+100, segsPerCircle: 100}]\" \n"
;
87
help +=
" -g4view=\"[{driver: TOOLSSG_OFFSCREEN, segsPerCircle: 200}]\" takes a screenshot at the end of each run \n"
;
88
89
goptions
.defineOption(
"g4view"
,
"Defines the geant4 viewer properties"
, g4view, help);
90
91
// g4camera
92
std::vector<GVariable> g4camera = {
93
{
"phi"
,
"0*deg"
,
"Geant4 camera phi"
},
94
{
"theta"
,
"0*deg"
,
"Geant4 camera theta"
}
95
};
96
97
help =
"Defines the geant4 camera view point \n \n "
;
98
help +=
"Example: -g4camera=\"[{phi: 20*deg, theta: 15*deg}]\" \n "
;
99
100
goptions
.defineOption(
"g4camera"
,
"Defines the geant4 camera view point"
, g4camera, help);
101
102
// g4light
103
std::vector<GVariable> g4light = {
104
{
"phi"
,
"0*deg"
,
"Geant4 light source phi"
},
105
{
"theta"
,
"0*deg"
,
"Geant4 light source theta"
}
106
};
107
108
help =
"Defines the geant4 light source direction \n \n "
;
109
help +=
"Example: -g4light=\"[{phi: 20*deg, theta: 15*deg}]\" \n "
;
110
111
goptions
.defineOption(
"g4light"
,
"Defines the geant4 light source direction"
, g4light, help);
112
113
// dawn
114
help =
"Defines the dawn camera view point and take a dawn screenshot \n \n "
;
115
help +=
"Example: -dawn=\"[{phi: 20*deg, theta: 15*deg}]\" \n "
;
116
117
std::vector<GVariable> dawn = {
118
{
"phi"
, 30,
"dawn phi"
},
119
{
"theta"
, 30,
"dawn theta"
}
120
};
121
122
goptions
.defineOption(
"dawn"
,
"Defines the dawn view point"
, dawn, help);
123
goptions
.defineSwitch(
"useDawn"
,
"Take a dawn screenshot"
);
124
125
// scenetext
126
goptions
.addGOptions(
addSceneTextsOptions
());
127
128
return
goptions
;
129
}
130
}
// namespace g4display
GOptions
g4Text.h
Scene text option structures and helpers for the g4display module.
g4displayConventions.h
Conventions and constants used by the g4display module.
GDEFAULTVIEWERDRIVER
#define GDEFAULTVIEWERDRIVER
Definition
g4displayConventions.h:19
GDEFAULTVSEGPERCIRCLE
#define GDEFAULTVSEGPERCIRCLE
Definition
g4displayConventions.h:28
GDEFAULTVIEWERPOS
#define GDEFAULTVIEWERPOS
Definition
g4displayConventions.h:25
GDEFAULTVIEWERSIZE
#define GDEFAULTVIEWERSIZE
Definition
g4displayConventions.h:22
g4display_options.h
Option structures and helpers for g4display configuration.
G4SCENE_LOGGER
constexpr const char * G4SCENE_LOGGER
Definition
g4display_options.h:22
G4DISPLAY_LOGGER
constexpr const char * G4DISPLAY_LOGGER
Definition
g4display_options.h:21
g4display
Definition
g4display_options.cc:10
g4display::getG4Light
G4Light getG4Light(const std::shared_ptr< GOptions > &gopts)
Read the g4light option node and return a projected G4Light struct.
Definition
g4display_options.cc:36
g4display::getG4Dawn
G4Dawn getG4Dawn(const std::shared_ptr< GOptions > &gopts)
Read the dawn option node and return a projected G4Dawn struct.
Definition
g4display_options.cc:47
g4display::getG4View
G4View getG4View(const std::shared_ptr< GOptions > &gopts)
Read the g4view option node and return a projected G4View struct.
Definition
g4display_options.cc:12
g4display::addSceneTextsOptions
GOptions addSceneTextsOptions()
Define the g4text structured option schema.
Definition
g4Text.cc:36
g4display::defineOptions
GOptions defineOptions()
Define the full set of g4display options.
Definition
g4display_options.cc:64
g4display::getG4Camera
G4Camera getG4Camera(const std::shared_ptr< GOptions > &gopts)
Read the g4camera option node and return a projected G4Camera struct.
Definition
g4display_options.cc:25
goptions
goptions::NODFLT
const std::string NODFLT
g4display::G4Camera
Camera angle configuration derived from the g4camera option node.
Definition
g4display_options.h:59
g4display::G4Camera::theta
std::string theta
Definition
g4display_options.h:61
g4display::G4Camera::phi
std::string phi
Definition
g4display_options.h:60
g4display::G4Dawn
DAWN view configuration derived from the dawn option node.
Definition
g4display_options.h:100
g4display::G4Dawn::phi
std::string phi
Definition
g4display_options.h:101
g4display::G4Dawn::theta
std::string theta
Definition
g4display_options.h:102
g4display::G4Light
Light angle configuration derived from the g4light option node.
Definition
g4display_options.h:80
g4display::G4Light::phi
std::string phi
Definition
g4display_options.h:81
g4display::G4Light::theta
std::string theta
Definition
g4display_options.h:82
g4display::G4View
Viewer configuration derived from the g4view option node.
Definition
g4display_options.h:36
g4display::G4View::position
std::string position
Definition
g4display_options.h:39
g4display::G4View::driver
std::string driver
Definition
g4display_options.h:37
g4display::G4View::dimension
std::string dimension
Definition
g4display_options.h:38
g4display::G4View::segsPerCircle
int segsPerCircle
Definition
g4display_options.h:40
g4display_options.cc
Generated by
1.10.0