|
8 | 8 | #include "g4Text.h" |
9 | 9 |
|
10 | 10 | namespace g4display { |
| 11 | +namespace { |
| 12 | +YAML::Node getG4ViewValue(const std::shared_ptr<GOptions>& gopts, const std::string& key) { |
| 13 | + auto node = gopts->getOptionNode("g4view"); |
| 14 | + if (node.IsMap() && node[key]) { |
| 15 | + return node[key]; |
| 16 | + } |
| 17 | + return gopts->getOptionMapInNode("g4view", key); |
| 18 | +} |
| 19 | +} |
| 20 | + |
11 | 21 | // Read g4view option and return a projected G4View struct. |
12 | 22 | G4View getG4View(const std::shared_ptr<GOptions>& gopts) { |
13 | 23 | G4View g4view; |
14 | 24 |
|
15 | 25 | // 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>(); |
| 26 | + g4view.driver = getG4ViewValue(gopts, "driver").as<std::string>(); |
| 27 | + g4view.dimension = getG4ViewValue(gopts, "dimension").as<std::string>(); |
| 28 | + g4view.position = getG4ViewValue(gopts, "position").as<std::string>(); |
| 29 | + g4view.segsPerCircle = getG4ViewValue(gopts, "segsPerCircle").as<int>(); |
| 30 | + g4view.background = getG4ViewValue(gopts, "background").as<std::string>(); |
| 31 | + g4view.cloudPoints = getG4ViewValue(gopts, "cloudPoints").as<int>(); |
20 | 32 |
|
21 | 33 | return g4view; |
22 | 34 | } |
@@ -74,17 +86,21 @@ GOptions defineOptions() { |
74 | 86 | {"driver", std::string(GDEFAULTVIEWERDRIVER), "Geant4 visualization driver. Use TOOLSSG_OFFSCREEN in batch mode. "}, |
75 | 87 | {"dimension", std::string(GDEFAULTVIEWERSIZE), "Geant4 viewer dimension"}, |
76 | 88 | {"position", std::string(GDEFAULTVIEWERPOS), "Geant4 viewer position"}, |
77 | | - {"segsPerCircle", GDEFAULTVSEGPERCIRCLE, "Number of segments per circle"} |
| 89 | + {"segsPerCircle", GDEFAULTVSEGPERCIRCLE, "Number of segments per circle"}, |
| 90 | + {"background", "0.05 0.05 0.26", "Geant4 viewer background color as '<red> <green> <blue>'"}, |
| 91 | + {"cloudPoints", 1000, "Number of points used for cloud volume rendering"} |
78 | 92 | }; |
79 | 93 |
|
80 | 94 | help = "Defines the Geant4 viewer properties: \n "; |
81 | 95 | help += " - screen dimensions \n "; |
82 | 96 | help += " - screen position \n "; |
83 | 97 | help += " - resolution in terms of segments per circle \n \n "; |
| 98 | + help += " - viewer background color as '<red> <green> <blue>' \n "; |
| 99 | + help += " - number of cloud points for cloud volume rendering \n \n "; |
84 | 100 | help += " Examples: \n \n "; |
85 | 101 | 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"; |
| 102 | + help += " -g4view=\"[{driver: OGL, dimension: 1100x800, position: +200+100, segsPerCircle: 100, background: 0.05 0.05 0.26}]\" \n"; |
| 103 | + help += " -g4view=\"[{driver: TOOLSSG_OFFSCREEN, segsPerCircle: 200, cloudPoints: 3000}]\" takes a screenshot at the end of each run \n"; |
88 | 104 |
|
89 | 105 | goptions.defineOption("g4view", "Defines the geant4 viewer properties", g4view, help); |
90 | 106 |
|
|
0 commit comments