Commit 347e7067 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'rounded_radial_vis' into 'master'

Rounded edges in radial detector visualization

See merge request allpix-squared/allpix-squared!760
parents 0491ae54 b77f6de0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -422,8 +422,8 @@ An example configuration with some useful parameters is given below:
# Use the Qt gui
mode = "gui"

# Set transparency of the detector models (in percent)
transparency = 0.4
# Set opacity of the detector models (in percent)
opacity = 0.4
# Set viewing style (alternative is 'wireframe')
view_style = "surface"

+2 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ This module requires an installation of Geant4.
* `simple_view` : Determines if the visualization should be simplified, not displaying the pixel matrix and other parts which are replicated multiple times. Default value is true. This parameter should normally not be changed as it will cause a considerable slowdown of the visualization for a sensor with a typical number of channels.
* `background_color` : Color of the background of the viewer. Defaults to *white*.
* `view_style` : Style to use to display the elements in the geometry. Options are **wireframe** and **surface**. By default, all elements are displayed as solid surface.
* `transparency` : Default transparency percentage of all detector elements, only used if the *view_style* is set to display solid surfaces. The default value is 0.4, giving a moderate amount of transparency.
* `opacity` : Default opacity percentage of all detector elements, only used if the *view_style* is set to display solid surfaces. The default value is 0.4, giving a moderate amount of opacity.
* `display_trajectories` : Determines if the trajectories of the primary and secondary particles should be displayed. Defaults to *true*.
* `hidden_trajectories` : Determines if the trajectories should be hidden inside the detectors. Only used if the *display_trajectories* is enabled. Default value of the parameter is true.
* `trajectories_color_mode` : Configures the way, trajectories are colored. Options are either **generic** which colors all trajectories in the same way, **charge** which bases the color on the particle's charge, or **particle** which colors the trajectory based on the type of the particle. The default setting is *charge*.
@@ -45,6 +45,7 @@ This module requires an installation of Geant4.
* `draw_hits` : Determines if hits in the detector should be displayed. Defaults to false. Option is only useful if Geant4 hits are generated in a module.
* `macro_init` : Optional Geant4 macro to execute during initialization. Whenever possible, the configuration parameters above should be used instead of this option.
* `display_limit` : Sets the `displayListLimit` of the visualization GUI, in case the geometry which has to be loaded is too complex for the GUI to be displayed with the current size Display List. Defaults to 1000000.
* `line_segments` : Sets the number of line segments to approximate a circle with. This parameter can be used when simulating radial detectors to visualize their curved edges with more precision. Defaults to 250.

### Usage
An example configuration providing a wireframe viewing style with the same color for every particle and displaying the result after every event for 2s is provided below:
+12 −5
Original line number Diff line number Diff line
@@ -46,6 +46,9 @@ using namespace allpix;

VisualizationGeant4Module::VisualizationGeant4Module(Configuration& config, Messenger*, GeometryManager* geo_manager)
    : Module(config), geo_manager_(geo_manager), has_run_(false), session_param_ptr_(nullptr) {
    // Interpret transparency parameter as opacity for backwards-compatibility
    config_.setAlias("opacity", "transparency", true);

    // Set default mode and driver for display
    config_.setDefault("mode", "gui");
    config_.setDefault("driver", "OGL");
@@ -285,6 +288,10 @@ void VisualizationGeant4Module::set_visualization_settings() {
    if(!accumulate) {
        UI->ApplyCommand("/vis/viewer/set/autoRefresh true");
    }

    // Number of line segments to approximate a circle with; used to visualize radial detectors with more precision
    auto line_segments = config_.get<std::string>("line_segments", "250");
    UI->ApplyCommand("/vis/viewer/set/lineSegmentsPerCircle " + line_segments);
}

/**
@@ -296,11 +303,11 @@ void VisualizationGeant4Module::set_visualization_settings() {
 * - Sensor: Blackish
 */
void VisualizationGeant4Module::set_visualization_attributes() {
    // To add some transparency in the solids, set to 0.4. 0 means opaque.
    // Transparency can be switched off in the visualisation.
    auto alpha = config_.get<double>("transparency", 0.4);
    if(alpha < 0 || alpha > 1) {
        throw InvalidValueError(config_, "transparency", "transparency level should be between 0 and 1");
    // To add some opacity in the solids, set to 0.4. 1 means fully opaque.
    // Opacity can be switched off in the visualisation.
    auto alpha = config_.get<double>("opacity", 0.4);
    if(alpha <= 0 || alpha > 1) {
        throw InvalidValueError(config_, "opacity", "opacity level should be between 0 and 1");
    }

    // Wrapper