g4display
Loading...
Searching...
No Matches
g4display_options.cc
Go to the documentation of this file.
1// g4display
2#include "g4display_options.h"
4#include "g4Text.h"
5
6
7// namespace to define options
8namespace g4display {
9
10// full list from /vis/list
11// TODO: lets get that programmatically
12// ASCIITree ATree DAWNFILE G4HepRepFile HepRepFile RayTracer VRML2FILE gMocrenFile OpenGLImmediateQt OGLIQt OGLI OpenGLStoredQt OGLSQt OGL OGLS
13// vector<string> AVAILABLEG4VIEWERS = {
14// "TOOLSSG_QT_GLES",
15// "OpenGLImmediateQt",
16// "OGLIQt",
17// "OGLI",
18// "OpenGLStoredQt",
19// "OGLSQt",
20// "OGL",
21// "OGLS"
22// };
23
24// read g4view option and return G4View struct
25G4View getG4View(const std::shared_ptr<GOptions>& gopts) {
26 // projecting it onto G4View structure
27 G4View g4view;
28 g4view.driver = gopts->getOptionMapInNode("g4view", "driver").as<std::string>();;
29 g4view.dimension = gopts->getOptionMapInNode("g4view", "dimension").as<std::string>();
30 g4view.position = gopts->getOptionMapInNode("g4view", "position").as<std::string>();
31 g4view.segsPerCircle = gopts->getOptionMapInNode("g4view", "segsPerCircle").as<int>();
32
33 return g4view;
34}
35
36// read the g4camera option and return a G4Camera struct
37G4Camera getG4Camera(const std::shared_ptr<GOptions>& gopts) {
38 G4Camera gcamera;
39 gcamera.phi = gopts->getOptionMapInNode("g4camera", "phi").as<std::string>();
40 gcamera.theta = gopts->getOptionMapInNode("g4camera", "theta").as<std::string>();
41
42 return gcamera;
43}
44
45// read the dawn options and return a G4Dawn struct
46G4Dawn getG4Dawn(const std::shared_ptr<GOptions>& gopts) {
47 G4Dawn gdawn;
48
49 auto phi = gopts->getOptionMapInNode("dawn", "phi").as<std::string>();
50 auto theta = gopts->getOptionMapInNode("dawn", "theta").as<std::string>();
51
52 if (phi == "null") phi = goptions::NODFLT;
53 if (theta == "null") theta = goptions::NODFLT;
54
55 gdawn.phi = phi;
56 gdawn.theta = theta;
57
58 return gdawn;
59}
60
61
62// returns array of options definitions
63GOptions defineOptions() {
64
65 GOptions goptions(G4DISPLAY_LOGGER);
66
67 goptions += GOptions(G4SCENE_LOGGER);
68
69 std::string help;
70
71
72 std::vector<GVariable> g4view = {
73 {"driver", std::string(GDEFAULTVIEWERDRIVER), "Geant4 vis driver"},
74 {"dimension", std::string(GDEFAULTVIEWERSIZE), "g4 viewer dimension"},
75 {"position", std::string(GDEFAULTVIEWERPOS), "g4 viewer position"},
76 {"segsPerCircle", GDEFAULTVSEGPERCIRCLE, "Number of segments per circle"}
77
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 ";
84 help +=
85 " Example: -g4view={viewer: \"OGL\", dimension: \"1100x800\", position: \"+200+100\", segsPerCircle: 100} \n \n";
86 help += "-g4view=\"[{dimensions: 1200x1000}]\"\n";
87 goptions.defineOption("g4view", "Defines the geant4 viewer properties", g4view, help);
88
89
90 // g4camera
91 std::vector<GVariable> g4camera = {
92 {"phi", "0*deg", "geant4 camera phi"},
93 {"theta", "0*deg", "geant4 camera theta"}
94 };
95
96 help = "Defines the geant4 camera view point \n \n ";
97 help += "Example: -g4camera=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
98 goptions.defineOption("g4camera", "Defines the geant4 camera view point", g4camera, help);
99
100
101 // dawn
102 help = "Defines the dawn camera view point and take a dawn screenshot \n \n ";
103 help += "Example: -dawn=\"[{phi: 20*deg, theta: 15*deg}]\" \n ";
104 std::vector<GVariable> dawn = {
105 {"phi", 30, "dawn phi"},
106 {"theta", 30, "dawn theta"}
107 };
108 goptions.defineOption("dawn", "Defines the dawn view point", dawn, help);
109 goptions.defineSwitch("useDawn", "Take a dawn screenshot");
110
111 // scenetext
112 goptions.addGOptions(addSceneTextsOptions());
113
114 return goptions;
115}
116}
#define GDEFAULTVIEWERDRIVER
#define GDEFAULTVSEGPERCIRCLE
#define GDEFAULTVIEWERPOS
#define GDEFAULTVIEWERSIZE
constexpr const char * G4SCENE_LOGGER
constexpr const char * G4DISPLAY_LOGGER
G4Dawn getG4Dawn(const std::shared_ptr< GOptions > &gopts)
G4View getG4View(const std::shared_ptr< GOptions > &gopts)
GOptions addSceneTextsOptions()
Definition g4Text.cc:34
GOptions defineOptions()
G4Camera getG4Camera(const std::shared_ptr< GOptions > &gopts)