g4display
Loading...
Searching...
No Matches
g4Text.cc
Go to the documentation of this file.
1// g4display
2#include "g4Text.h"
3
4// c++
5using namespace std;
6
7
8namespace g4display {
9
10 // method to return a vector of G4SceneText from a structured option
11 vector <G4SceneText> getSceneTexts(GOptions *gopts) {
12
13 vector <G4SceneText> st;
14
15 auto g4t_node = gopts->getOptionNode("g4text");
16
17 for (auto g4t_item: g4t_node) {
18 G4SceneText st_item;
19
20 st_item.text = gopts->get_variable_in_option<string>(g4t_item, "text", goptions::NODFLT);
21 st_item.color = gopts->get_variable_in_option<string>(g4t_item, "color", "black");
22 st_item.x = gopts->get_variable_in_option<double>(g4t_item, "x", 0);
23 st_item.y = gopts->get_variable_in_option<double>(g4t_item, "y", 0);
24 st_item.z = gopts->get_variable_in_option<double>(g4t_item, "z", GNOT_SPECIFIED_SCENE_TEXT_Z);
25 st_item.size = gopts->get_variable_in_option<double>(g4t_item, "size", 24.0);
26 st.push_back(st_item);
27 }
28
29 return st;
30 }
31
32
33 // returns array of options definitions
35
36 GOptions goptions;
37 string help;
38
39 // g4text
40 help = "If the z coordinate is specified, the text is considered 2D. \n \n";
41 help += "Example to add two texts: \n \n";
42 help += "-g4text=\"[{text: hello, x: -100}, {text: there, x: 100}]\"\n";
43 vector <GVariable> g4text = {
44 {"text", goptions::NODFLT, "string with the text to be displayed"},
45 {"color", "black", "color of the text"},
46 {"x", 0, "x position of the text"},
47 {"y", 0, "y position of the text"},
48 {"z", GNOT_SPECIFIED_SCENE_TEXT_Z, "z position of the text"},
49 {"size", 24.0, "size of the text"},
50 };
51 goptions.defineOption("g4text", "Insert texts in the current scene", g4text, help);
52
53 return goptions;
54 }
55
56}
#define GNOT_SPECIFIED_SCENE_TEXT_Z
GOptions addSceneTextsOptions()
Definition g4Text.cc:34
vector< G4SceneText > getSceneTexts(GOptions *gopts)
Definition g4Text.cc:11
std::string text
Definition g4Text.h:14