ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
styling.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
12#include "detray/plugins/svgtools/meta/proto/eta_lines.hpp"
13#include "detray/plugins/svgtools/meta/proto/intersection.hpp"
14#include "detray/plugins/svgtools/meta/proto/landmark.hpp"
15#include "detray/plugins/svgtools/meta/proto/trajectory.hpp"
16#include "detray/plugins/svgtools/styling/colors.hpp"
17
18// Actsvg include(s)
19#include "actsvg/core.hpp"
20#include "actsvg/core/style.hpp"
21#include "actsvg/proto/detector.hpp"
22#include "actsvg/proto/grid.hpp"
23#include "actsvg/proto/material.hpp"
24#include "actsvg/proto/portal.hpp"
25#include "actsvg/proto/surface.hpp"
26#include "actsvg/proto/volume.hpp"
27#include "actsvg/styles/defaults.hpp"
28
29// System include(s)
30#include <array>
31#include <cstdlib>
32#include <vector>
33
34namespace detray::svgtools::styling {
35
37struct grid_style {
39 actsvg::style::color _stroke_color{};
41 actsvg::scalar _stroke_width{};
42};
43
47 actsvg::point2 _info_pos{};
48
50 actsvg::point2 _gradient_pos{};
52 std::array<actsvg::scalar, 2u> _gradient_box{};
54 actsvg::style::font _gradient_font{};
56 actsvg::style::label _gradient_label{};
58 actsvg::style::color _gradient_stroke_color{};
60 actsvg::scalar _gradient_stroke_width{0.f};
62 std::vector<actsvg::style::color> _gradient_color_scale{};
64 unsigned int _gradient_n_stops{0u};
65
68};
69
76 explicit surface_style(
77 const actsvg::style::color& fill_color =
79 actsvg::scalar stroke_width = 0.4f, surface_material_style mat_style = {})
80 : _fill_color{fill_color},
81 _stroke_width{stroke_width},
82 _material_style{std::move(mat_style)} {
83 _stroke_color = fill_color;
85 _highlight_stroke_width = stroke_width;
87 _material_style._gradient_label._font._size = 26u;
88 }
89
90 actsvg::style::color _fill_color{};
91
93 actsvg::scalar _stroke_width{10.f};
95 actsvg::style::color _stroke_color{};
96
98 std::array<int, 3> _highlight_rgb{colors::macaroni_and_cheese};
100 std::vector<std::string> _highlights{};
102 std::array<int, 3> _highlight_stroke_rgb{};
104 actsvg::scalar _highlight_stroke_width{};
105
107 unsigned int _font_size{22u};
109 unsigned int _n_segments{72u};
110
113};
114
118 actsvg::scalar _marker_size{1.f};
119};
120
128
140
148
152 actsvg::style::color _fill_color_main{};
154 actsvg::style::color _fill_color_half{};
156 actsvg::scalar _stroke_width_main{10.f};
158 actsvg::scalar _stroke_width_half{10.f};
160 unsigned int _font_size{11u};
161};
162
166 actsvg::style::color _fill_color{};
168 actsvg::scalar _stroke_width{10.f};
170 actsvg::scalar _marker_size{10.f};
172 std::string _marker_type{};
173};
174
178 actsvg::style::color _fill_color{};
180 actsvg::scalar _stroke_width{10.f};
181};
182
196
198namespace svg_default {
199
200// Material style
203 {-1000.f, 1000.f},
204 {1000.f, -200.f},
205 {20.f, 400.f},
206 actsvg::style::font{},
207 actsvg::style::label{"t/X0", actsvg::style::label::horizontal::right,
208 actsvg::style::label::vertical::top},
209 {colors::black, 1.f},
210 1.f,
211 colors::gradient::rainbow_scale,
212 4u,
213 {{colors::black, 1.f}, 0.4f}};
214
215// Surface styles
218 colors::blue_theme(0.5f).front(), 3.f, material_style};
219
221 {colors::dark_grey, 0.8f}, 3.f, material_style};
222
224 colors::red_theme(0.5f).front(), 3.f, material_style};
225
226// Portal style
231
232// Volume style
234const styling::grid_style grid_style{colors::red_theme(1.f).front(), 1.f};
238
239// Detector style
242
243// Eta lines style
246 {colors::black, 1.f}, {colors::black, 1.f}, 1.f, 1.f, 30u};
247
248// Intersection points and track state style
251 colors::black_theme(1.f).front(), 0.8f, 5.f, "x"};
252
253const styling::landmark_style landmark_style{colors::green_theme(1.f).front(),
254 0.8f, 3.f, "o"};
255
256// Trajectory style
259 colors::green_theme(1.f).front(), 1.f};
260
261// Full style
265} // namespace svg_default
266
269
270// Surface material style
273 {-1000.f, 1000.f},
274 {1000.f, -200.f},
275 {20.f, 400.f},
276 actsvg::style::font{},
277 actsvg::style::label{"t/X0", actsvg::style::label::horizontal::right,
278 actsvg::style::label::vertical::top},
279 {colors::black, 1.f},
280 1.f,
281 colors::gradient::viridis_scale,
282 8u,
283 {{colors::black, 1.f}, 0.4f}};
284
285// Surface styles
290
294
297
298// Portal style
302
303// Volume style
305const styling::grid_style grid_style{{colors::red, 1.f}, 0.6f};
309
310// Detector style
313
314// Full style
319} // namespace tableau_colorblind
320
322template <typename point3_container_t>
323inline void apply_style(actsvg::proto::surface<point3_container_t>& p_surface,
324 const surface_style& styling) {
325 // Fill color
326 p_surface._fill = actsvg::style::fill(styling._fill_color);
327 p_surface._fill._fc._hl_rgb = styling._highlight_rgb;
328 p_surface._fill._fc._highlight = styling._highlights;
329
330 // Stroke
331 p_surface._stroke =
332 actsvg::style::stroke(styling._stroke_color, styling._stroke_width);
333 p_surface._stroke._sc._hl_rgb = styling._highlight_stroke_rgb;
334 p_surface._stroke._hl_width = styling._highlight_stroke_width;
335}
336
338template <typename point3_container_t>
339inline void apply_style(
340 typename actsvg::proto::portal<point3_container_t>::link& p_link,
341 const link_style& styling) {
342 p_link._end_marker._size = styling._marker_size;
343}
344
346template <typename point3_container_t>
347inline void apply_style(actsvg::proto::portal<point3_container_t>& p_portal,
348 const portal_style& styling) {
349 apply_style(p_portal._surface, styling._surface_style);
350
351 for (auto& volume_link : p_portal._volume_links) {
352 apply_style<point3_container_t>(volume_link, styling._link_style);
353 }
354}
355
357inline void apply_style(actsvg::proto::grid& p_grid,
358 const grid_style& styling) {
359 p_grid._stroke._sc = styling._stroke_color;
360 p_grid._stroke._width = styling._stroke_width;
361 // Use dashed lines for the grid
362 // p_grid._stroke._dasharray = {4};
363}
364
366inline void apply_style(actsvg::proto::surface_material& p_material,
367 const surface_material_style& styling) {
368 p_material._info_pos = styling._info_pos;
369
370 p_material._gradient_pos = styling._gradient_pos;
371 p_material._gradient_box = styling._gradient_box;
372 p_material._gradient_font = styling._gradient_font;
373 p_material._gradient_label = styling._gradient_label;
374 p_material._gradient_stroke._sc = styling._gradient_stroke_color;
375 p_material._gradient_stroke._width = styling._gradient_stroke_width;
376 p_material._gradient._stops = colors::gradient::generate_stops(
377 styling._gradient_color_scale, styling._gradient_n_stops);
378
379 apply_style(p_material._grid, styling._grid_style);
380}
381
383template <typename point3_container_t>
384inline void apply_style(actsvg::proto::volume<point3_container_t>& p_volume,
385 const volume_style& styling) {
386 using proto_sf_t = actsvg::proto::surface<point3_container_t>;
387
388 for (auto& p_surface : p_volume._v_surfaces) {
389 const auto& sf_style =
390 (p_surface._sf_type == proto_sf_t::sf_type::e_sensitive)
391 ? styling._sensitive_surface_style
392 : styling._passive_surface_style;
393 apply_style(p_surface, sf_style);
394 }
395 for (auto& p_portals : p_volume._portals) {
396 apply_style(p_portals, styling._portal_style);
397 }
398 apply_style(p_volume._surface_grid, styling._grid_style);
399}
400
402template <typename point3_container_t>
403inline void apply_style(actsvg::proto::detector<point3_container_t>& p_detector,
404 const detector_style& styling) {
405 for (auto& p_volume : p_detector._volumes) {
406 apply_style(p_volume, styling._volume_style);
407 }
408}
409
411inline void apply_style(meta::proto::eta_lines& p_eta_lines,
412 const eta_lines_style& styling) {
413 p_eta_lines._stroke_main = actsvg::style::stroke(styling._fill_color_main,
414 styling._stroke_width_main);
415
416 p_eta_lines._stroke_half = actsvg::style::stroke(styling._fill_color_half,
417 styling._stroke_width_half);
418 p_eta_lines._stroke_half._dasharray = {2, 2};
419 p_eta_lines._label_font._size = styling._font_size;
420}
421
423template <concepts::point3D point3_t>
424inline void apply_style(meta::proto::landmark<point3_t>& p_landmark,
425 const landmark_style& styling) {
426 const auto fill = actsvg::style::fill(styling._fill_color);
427 const auto stroke =
428 actsvg::style::stroke(styling._fill_color, styling._stroke_width);
429
430 const auto marker = actsvg::style::marker{styling._marker_type,
431 styling._marker_size, fill, stroke};
432 p_landmark._marker = marker;
433}
434
436template <concepts::point3D point3_t>
437inline void apply_style(meta::proto::intersection<point3_t>& p_intersection,
438 const landmark_style& styling) {
439 const auto stroke =
440 actsvg::style::stroke(styling._fill_color, styling._stroke_width);
441
442 auto fill_color = styling._fill_color;
443 fill_color._opacity *= 0.5f;
444 const auto fill = actsvg::style::fill(fill_color);
445
446 const auto marker = actsvg::style::marker{styling._marker_type,
447 styling._marker_size, fill, stroke};
448
449 for (auto& p_landmark : p_intersection._landmarks) {
450 p_landmark._marker = marker;
451 }
452}
453
455template <concepts::point3D point3_t>
456inline void apply_style(meta::proto::trajectory<point3_t>& p_trajectory,
457 const trajectory_style& styling) {
458 p_trajectory._stroke =
459 actsvg::style::stroke(styling._fill_color, styling._stroke_width);
460}
461
462} // namespace detray::svgtools::styling
The default styling.
Definition styling.hpp:198
const styling::style style
Complete default SVG style configuration.
Definition styling.hpp:263
const styling::surface_style surface_style_portal
Default style for portal surfaces.
Definition styling.hpp:223
const styling::link_style link_style
Default style for links attached to portals.
Definition styling.hpp:228
const styling::landmark_style intersection_style
Default style for trajectory intersections.
Definition styling.hpp:250
const styling::surface_style surface_style_passive
Default style for passive detector surfaces.
Definition styling.hpp:220
const styling::volume_style volume_style
Default volume style.
Definition styling.hpp:236
const styling::detector_style detector_style
Default detector style.
Definition styling.hpp:241
const styling::eta_lines_style eta_lines_style
Default eta guide line style.
Definition styling.hpp:245
const styling::surface_material_style material_style
Default material annotation and gradient style.
Definition styling.hpp:202
const styling::surface_style surface_style_sensitive
Default style for sensitive detector surfaces.
Definition styling.hpp:217
const styling::portal_style portal_style
Default portal style combining portal surfaces and links.
Definition styling.hpp:230
const styling::trajectory_style trajectory_style
Default trajectory style.
Definition styling.hpp:258
const styling::landmark_style landmark_style
Default style for trajectory landmarks.
Definition styling.hpp:253
const styling::grid_style grid_style
Default style for detector and volume grids.
Definition styling.hpp:234
Styling that matches data plotting.
Definition styling.hpp:268
const styling::grid_style grid_style
Grid style used by the Tableau detector and volumes.
Definition styling.hpp:305
const styling::surface_style surface_style_portal
Portal surface style in the Tableau colorblind palette.
Definition styling.hpp:291
const styling::detector_style detector_style
Detector style using the Tableau colorblind palette.
Definition styling.hpp:312
const styling::surface_style surface_style_passive
Passive surface style in the Tableau colorblind palette.
Definition styling.hpp:287
const styling::surface_material_style material_style
Material annotation and gradient style using the viridis scale.
Definition styling.hpp:272
const styling::portal_style portal_style
Portal style using the Tableau portal surface and default link style.
Definition styling.hpp:300
const styling::style style
Complete style configuration using the Tableau colorblind palette.
Definition styling.hpp:316
const styling::surface_style surface_style_sensitive
Sensitive surface style in the Tableau colorblind palette.
Definition styling.hpp:295
const styling::volume_style volume_style
Volume style using the Tableau colorblind palette.
Definition styling.hpp:307
static std::vector< actsvg::style::color > red_tones(const actsvg::scalar opacity)
Return the palette's red tones.
Definition colors.hpp:228
static std::vector< actsvg::style::color > blue_tones(const actsvg::scalar opacity)
Return the palette's blue tones.
Definition colors.hpp:221
static std::vector< actsvg::style::color > grey_tones(const actsvg::scalar opacity)
Return the palette's neutral grey tones.
Definition colors.hpp:211
Style applied to an actsvg proto detector.
Definition styling.hpp:142
volume_style _volume_style
Style applied to volumes in the detector.
Definition styling.hpp:144
grid_style _grid_style
Style applied to the detector grid.
Definition styling.hpp:146
Style applied to proto eta lines.
Definition styling.hpp:150
actsvg::style::color _fill_color_main
Color of the main eta lines.
Definition styling.hpp:152
actsvg::scalar _stroke_width_main
Width of the main eta lines.
Definition styling.hpp:156
unsigned int _font_size
Font size of eta line labels.
Definition styling.hpp:160
actsvg::scalar _stroke_width_half
Width of the half eta lines.
Definition styling.hpp:158
actsvg::style::color _fill_color_half
Color of the half eta lines.
Definition styling.hpp:154
Style applied to an actsvg proto grid.
Definition styling.hpp:37
actsvg::style::color _stroke_color
Color used to draw grid lines.
Definition styling.hpp:39
actsvg::scalar _stroke_width
Width of grid lines.
Definition styling.hpp:41
Style applied to a proto landmark.
Definition styling.hpp:164
actsvg::scalar _stroke_width
Outline width for landmark markers.
Definition styling.hpp:168
std::string _marker_type
Marker glyph used to draw landmarks.
Definition styling.hpp:172
actsvg::scalar _marker_size
Size of landmark markers.
Definition styling.hpp:170
actsvg::style::color _fill_color
Fill color for landmark markers.
Definition styling.hpp:166
Style applied to an actsvg proto portal.
Definition styling.hpp:122
link_style _link_style
Style applied to links attached to the portal.
Definition styling.hpp:126
surface_style _surface_style
Style applied to the portal surface.
Definition styling.hpp:124
Global styling options.
Definition styling.hpp:184
landmark_style _intersection_style
Styling for intersections.
Definition styling.hpp:194
eta_lines_style _eta_lines_style
Styling for eta guide lines.
Definition styling.hpp:188
landmark_style _landmark_style
Styling for track landmarks.
Definition styling.hpp:192
detector_style _detector_style
Styling for detector geometry.
Definition styling.hpp:186
trajectory_style _trajectory_style
Styling for trajectories.
Definition styling.hpp:190
Style applied to an actsvg proto surface_material.
Definition styling.hpp:45
actsvg::point2 _info_pos
Position of the material information annotation.
Definition styling.hpp:47
grid_style _grid_style
Style of the grid overlaid on material surfaces.
Definition styling.hpp:67
actsvg::scalar _gradient_stroke_width
Width of the material gradient outline.
Definition styling.hpp:60
std::array< actsvg::scalar, 2u > _gradient_box
Dimensions of the material gradient box.
Definition styling.hpp:52
std::vector< actsvg::style::color > _gradient_color_scale
Colors sampled to construct the material gradient.
Definition styling.hpp:62
actsvg::style::color _gradient_stroke_color
Color of the material gradient outline.
Definition styling.hpp:58
unsigned int _gradient_n_stops
Number of stops generated for the material gradient.
Definition styling.hpp:64
actsvg::style::font _gradient_font
Font used for the material gradient.
Definition styling.hpp:54
actsvg::style::label _gradient_label
Label shown with the material gradient.
Definition styling.hpp:56
actsvg::point2 _gradient_pos
Position of the material gradient.
Definition styling.hpp:50
Style applied to an actsvg proto surface.
Definition styling.hpp:71
surface_style(const actsvg::style::color &fill_color=colors::tableau_colorblind10::red_tones(0.4f).front(), actsvg::scalar stroke_width=0.4f, surface_material_style mat_style={})
Construct a surface style with fill, stroke width, and material settings.
Definition styling.hpp:76
unsigned int _n_segments
Granularity of vertex approximation of arcs.
Definition styling.hpp:109
actsvg::style::color _fill_color
Fill color.
Definition styling.hpp:90
unsigned int _font_size
Font size used for surface labels.
Definition styling.hpp:107
std::vector< std::string > _highlights
Names of surface features that should be highlighted.
Definition styling.hpp:100
surface_material_style _material_style
Material annotation and gradient style for the surface.
Definition styling.hpp:112
std::array< int, 3 > _highlight_stroke_rgb
RGB color used to highlight the surface outline.
Definition styling.hpp:102
actsvg::scalar _stroke_width
Width of the surface outline.
Definition styling.hpp:93
actsvg::scalar _highlight_stroke_width
Width of the highlighted surface outline.
Definition styling.hpp:104
actsvg::style::color _stroke_color
Color of the surface outline.
Definition styling.hpp:95
std::array< int, 3 > _highlight_rgb
Highlights.
Definition styling.hpp:98
Style applied to a proto trajectory.
Definition styling.hpp:176
actsvg::style::color _fill_color
Give different tracks different colors.
Definition styling.hpp:178
actsvg::scalar _stroke_width
Width of trajectory lines.
Definition styling.hpp:180
Style applied to an actsvg proto volume.
Definition styling.hpp:130
grid_style _grid_style
Style for the volume surface grid.
Definition styling.hpp:138
portal_style _portal_style
Style for portals in the volume.
Definition styling.hpp:136
surface_style _sensitive_surface_style
Style for sensitive surfaces in the volume.
Definition styling.hpp:132
surface_style _passive_surface_style
Style for passive surfaces in the volume.
Definition styling.hpp:134