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 dawn options and return a G4Dawn struct.
36
G4Dawn
getG4Dawn
(
const
std::shared_ptr<GOptions>& gopts) {
37
G4Dawn
gdawn;
38
39
auto
phi = gopts->getOptionMapInNode(
"dawn"
,
"phi"
).as<std::string>();
40
auto
theta = gopts->getOptionMapInNode(
"dawn"
,
"theta"
).as<std::string>();
41
42
// Normalize explicit "null" (string) to the “not defined” sentinel used by options.
43
if
(phi ==
"null"
) phi =
goptions::NODFLT
;
44
if
(theta ==
"null"
) theta =
goptions::NODFLT
;
45
46
gdawn.
phi
= phi;
47
gdawn.
theta
= theta;
48
49
return
gdawn;
50
}
51
52
// Define and return the option set for the g4display module.
53
GOptions
defineOptions
() {
54
GOptions
goptions
(
G4DISPLAY_LOGGER
);
55
56
// The module also defines options for g4scene helpers (same executable context).
57
goptions
+=
GOptions
(
G4SCENE_LOGGER
);
58
59
std::string help;
60
61
// g4view
62
std::vector<GVariable> g4view = {
63
{
"driver"
, std::string(
GDEFAULTVIEWERDRIVER
),
"Geant4 vis driver"
},
64
{
"dimension"
, std::string(
GDEFAULTVIEWERSIZE
),
"g4 viewer dimension"
},
65
{
"position"
, std::string(
GDEFAULTVIEWERPOS
),
"g4 viewer position"
},
66
{
"segsPerCircle"
,
GDEFAULTVSEGPERCIRCLE
,
"Number of segments per circle"
}
67
};
68
69
help =
"Defines the geant4 viewer properties: \n "
;
70
help +=
" - screen dimensions \n "
;
71
help +=
" - screen position \n "
;
72
help +=
" - resolution in terms of segments per circle \n "
;
73
help +=
74
" Example: -g4view={viewer: \"OGL\", dimension: \"1100x800\", position: \"+200+100\", segsPerCircle: 100} \n \n"
;
75
help +=
"-g4view=\"[{dimensions: 1200x1000}]\"\n"
;
76
77
goptions
.defineOption(
"g4view"
,
"Defines the geant4 viewer properties"
, g4view, help);
78
79
// g4camera
80
std::vector<GVariable> g4camera = {
81
{
"phi"
,
"0*deg"
,
"geant4 camera phi"
},
82
{
"theta"
,
"0*deg"
,
"geant4 camera theta"
}
83
};
84
85
help =
"Defines the geant4 camera view point \n \n "
;
86
help +=
"Example: -g4camera=\"[{phi: 20*deg, theta: 15*deg}]\" \n "
;
87
88
goptions
.defineOption(
"g4camera"
,
"Defines the geant4 camera view point"
, g4camera, help);
89
90
// dawn
91
help =
"Defines the dawn camera view point and take a dawn screenshot \n \n "
;
92
help +=
"Example: -dawn=\"[{phi: 20*deg, theta: 15*deg}]\" \n "
;
93
94
std::vector<GVariable> dawn = {
95
{
"phi"
, 30,
"dawn phi"
},
96
{
"theta"
, 30,
"dawn theta"
}
97
};
98
99
goptions
.defineOption(
"dawn"
,
"Defines the dawn view point"
, dawn, help);
100
goptions
.defineSwitch(
"useDawn"
,
"Take a dawn screenshot"
);
101
102
// scenetext
103
goptions
.addGOptions(
addSceneTextsOptions
());
104
105
return
goptions
;
106
}
107
}
// 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:21
G4DISPLAY_LOGGER
constexpr const char * G4DISPLAY_LOGGER
Definition
g4display_options.h:20
g4display
Definition
g4display_options.cc:10
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:36
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:53
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:58
g4display::G4Camera::theta
std::string theta
Definition
g4display_options.h:60
g4display::G4Camera::phi
std::string phi
Definition
g4display_options.h:59
g4display::G4Dawn
DAWN view configuration derived from the dawn option node.
Definition
g4display_options.h:78
g4display::G4Dawn::phi
std::string phi
Definition
g4display_options.h:79
g4display::G4Dawn::theta
std::string theta
Definition
g4display_options.h:80
g4display::G4View
Viewer configuration derived from the g4view option node.
Definition
g4display_options.h:35
g4display::G4View::position
std::string position
Definition
g4display_options.h:38
g4display::G4View::driver
std::string driver
Definition
g4display_options.h:36
g4display::G4View::dimension
std::string dimension
Definition
g4display_options.h:37
g4display::G4View::segsPerCircle
int segsPerCircle
Definition
g4display_options.h:39
g4display_options.cc
Generated by
1.10.0