Skip to content

Commit feafac7

Browse files
committed
Add yaml and display control for cloud point count and background color
1 parent 81728ea commit feafac7

10 files changed

Lines changed: 226 additions & 126 deletions

File tree

.github/workflows/binary_tarballs.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ on:
1616
workflow_run:
1717
workflows: [ "Deploy and Test" ]
1818
types: [ completed ]
19-
schedule:
20-
# nightly, after the GEMC dev release window
21-
- cron: '44 5 * * *'
2219
workflow_dispatch:
2320

2421
jobs:

examples/optical/cherenkov/cherenkov.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ experiment: examples
22
runno: 1
33
nthreads: 1
44

5+
g4view:
6+
background: "0.92 0.92 0.98"
7+
cloudPoints: 4000
8+
59
verbosity:
610
- g4system: 1
711
- gemc: 1
@@ -25,4 +29,3 @@ gparticle:
2529

2630
# Required for optical-photon flux hits because optical photons deposit zero energy.
2731
recordZeroEdep: true
28-

g4display/g4SceneProperties.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ std::vector<std::string> G4SceneProperties::scene_commands(const std::shared_ptr
5757
cmds.emplace_back("/vis/viewer/set/viewpointThetaPhi " + std::to_string(thetaValue) + " " + std::to_string(phiValue));
5858
cmds.emplace_back("/vis/viewer/set/lightsThetaPhi " + std::to_string(lightThetaValue) + " " + std::to_string(lightPhiValue));
5959
cmds.emplace_back("/vis/viewer/set/lineSegmentsPerCircle " + std::to_string(g4view.segsPerCircle));
60+
cmds.emplace_back("/vis/viewer/set/background " + g4view.background);
61+
cmds.emplace_back("/vis/viewer/set/numberOfCloudPoints " + std::to_string(g4view.cloudPoints));
6062

6163
cmds.emplace_back("/vis/viewer/set/autoRefresh true");
6264
}

g4display/g4display_options.cc

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,27 @@
88
#include "g4Text.h"
99

1010
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+
1121
// Read g4view option and return a projected G4View struct.
1222
G4View getG4View(const std::shared_ptr<GOptions>& gopts) {
1323
G4View g4view;
1424

1525
// 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>();
2032

2133
return g4view;
2234
}
@@ -74,17 +86,21 @@ GOptions defineOptions() {
7486
{"driver", std::string(GDEFAULTVIEWERDRIVER), "Geant4 visualization driver. Use TOOLSSG_OFFSCREEN in batch mode. "},
7587
{"dimension", std::string(GDEFAULTVIEWERSIZE), "Geant4 viewer dimension"},
7688
{"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"}
7892
};
7993

8094
help = "Defines the Geant4 viewer properties: \n ";
8195
help += " - screen dimensions \n ";
8296
help += " - screen position \n ";
8397
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 ";
84100
help += " Examples: \n \n ";
85101
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";
88104

89105
goptions.defineOption("g4view", "Defines the geant4 viewer properties", g4view, help);
90106

g4display/g4display_options.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ namespace g4display {
3131
* - \c dimension : window size string (e.g. \c "800x800")
3232
* - \c position : window position string (e.g. \c "+200+100")
3333
* - \c segsPerCircle : circle segmentation precision for curved primitives
34+
* - \c background : viewer background color as three RGB values
35+
* - \c cloudPoints : number of points used by cloud volume rendering
3436
*/
3537
struct G4View
3638
{
3739
std::string driver;
3840
std::string dimension;
3941
std::string position;
4042
int segsPerCircle;
43+
std::string background;
44+
int cloudPoints;
4145
};
4246

4347
/**

0 commit comments

Comments
 (0)