g4display
g4display_options.cc
Go to the documentation of this file.
1 // g4display
2 #include "g4display_options.h"
3 #include "g4displayConventions.h"
4 #include "g4Text.h"
5 
6 using namespace std;
7 
8 // namespace to define options
9 namespace g4display {
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
25 G4View getG4View(GOptions* gopts) {
26  // projecting it onto G4View structure
27  G4View g4view;
28  g4view.driver = gopts->getOptionMapInNode("g4view", "driver").as<string>();;
29  g4view.dimension = gopts->getOptionMapInNode("g4view", "dimension").as<string>();
30  g4view.position = gopts->getOptionMapInNode("g4view", "position").as<string>();
31  g4view.segsPerCircle = gopts->getOptionMapInNode("g4view", "segsPerCircle").as<int>();
32 
33  return g4view;
34 }
35 
36 // read g4camera option and return G4Camera struct
37 G4Camera getG4Camera(GOptions* gopts) {
38  G4Camera gcamera;
39  gcamera.phi = gopts->getOptionMapInNode("g4camera", "phi").as<string>();
40  gcamera.theta = gopts->getOptionMapInNode("g4camera", "theta").as<string>();
41 
42  return gcamera;
43 }
44 
45 // read dawn option and return G4Dawn struct
46 G4Dawn getG4Dawn(GOptions* gopts) {
47  G4Dawn gdawn;
48 
49  auto phi = gopts->getOptionMapInNode("dawn", "phi").as<string>();
50  auto theta = gopts->getOptionMapInNode("dawn", "theta").as<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
63 GOptions defineOptions() {
64 
65  GOptions goptions(G4DISPLAY_LOGGER);
66  string help;
67 
68  // g4display
69  // string VIEWERCHOICES = "g4 viewer. Available choices:\n\n";
70  // for (const auto& c : AVAILABLEG4VIEWERS) { VIEWERCHOICES += "\t\t\t\t- " + c + "\n"; }
71 
72  vector<GVariable> g4view = {
73  {"driver", string(GDEFAULTVIEWERDRIVER), "Geant4 vis driver"},
74  {"dimension", string(GDEFAULTVIEWERSIZE), "g4 viewer dimension"},
75  {"position", 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  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  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 * G4DISPLAY_LOGGER
GOptions addSceneTextsOptions()
Definition: g4Text.cc:34
GOptions defineOptions()
G4Dawn getG4Dawn(GOptions *gopts)
G4Camera getG4Camera(GOptions *gopts)
G4View getG4View(GOptions *gopts)