Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Svg.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Svg.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 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 http://mozilla.org/MPL/2.0/.
8 
21 
22 #include <memory>
23 
24 #include <pybind11/pybind11.h>
25 #include <pybind11/stl.h>
26 
27 namespace py = pybind11;
28 using namespace pybind11::literals;
29 
30 using namespace Acts;
31 using namespace ActsExamples;
32 
33 namespace Acts::Python {
34 void addSvg(Context& ctx) {
35  auto [m, mex] = ctx.get("main", "examples");
36 
37  {
38  auto c = py::class_<Svg::Style>(m, "SvgStyle").def(py::init<>());
40  ACTS_PYTHON_MEMBER(fillColor);
41  ACTS_PYTHON_MEMBER(fillOpacity);
42  ACTS_PYTHON_MEMBER(highlightColor);
43  ACTS_PYTHON_MEMBER(highlights);
44  ACTS_PYTHON_MEMBER(strokeWidth);
45  ACTS_PYTHON_MEMBER(strokeColor);
46  ACTS_PYTHON_MEMBER(nSegments);
48  }
49 
50  {
51  auto c = py::class_<Svg::SurfaceConverter::Options>(m, "SvgSurfaceOptions")
52  .def(py::init<>());
54  ACTS_PYTHON_MEMBER(style);
55  ACTS_PYTHON_MEMBER(templateSurface);
57  }
58 
59  {
60  using DefinedStyle = std::pair<GeometryIdentifier, Svg::Style>;
61  using DefinedStyleSet = std::vector<DefinedStyle>;
62 
63  auto sm = py::class_<GeometryHierarchyMap<Svg::Style>>(m, "SvgStyleMap")
64  .def(py::init<DefinedStyleSet>(), py::arg("elements"));
65 
66  auto c = py::class_<Svg::LayerConverter::Options>(m, "SvgLayerOptions")
67  .def(py::init<>());
70  ACTS_PYTHON_MEMBER(surfaceStyles);
71  ACTS_PYTHON_MEMBER(zRange);
72  ACTS_PYTHON_MEMBER(phiRange);
73  ACTS_PYTHON_MEMBER(gridInfo);
74  ACTS_PYTHON_MEMBER(moduleInfo);
75  ACTS_PYTHON_MEMBER(projectionInfo);
76  ACTS_PYTHON_MEMBER(labelProjection);
77  ACTS_PYTHON_MEMBER(labelGauge);
79  }
80 
81  {
82  using DefinedLayerOptions =
83  std::pair<GeometryIdentifier, Svg::LayerConverter::Options>;
84  using DefinedLayerOptionsSet = std::vector<DefinedLayerOptions>;
85 
86  auto lom =
87  py::class_<GeometryHierarchyMap<Svg::LayerConverter::Options>>(
88  m, "SvgLayerOptionMap")
89  .def(py::init<DefinedLayerOptionsSet>(), py::arg("elements"));
90 
91  auto c = py::class_<Svg::TrackingGeometryConverter::Options>(
92  m, "SvgTrackingGeometryOptions")
93  .def(py::init<>());
96  ACTS_PYTHON_MEMBER(layerOptions);
98  }
99 
100  {
102  auto w = py::class_<Writer, std::shared_ptr<Writer>>(
103  mex, "SvgTrackingGeometryWriter")
104  .def(py::init<const Writer::Config&, Acts::Logging::Level>(),
105  py::arg("config"), py::arg("level"))
106  .def("write", py::overload_cast<const AlgorithmContext&,
107  const Acts::TrackingGeometry&>(
108  &Writer::write));
109 
110  auto c = py::class_<Writer::Config>(w, "Config").def(py::init<>());
113  ACTS_PYTHON_MEMBER(converterOptions);
115  }
116  {
118  auto w =
119  py::class_<Writer, ActsExamples::IWriter, std::shared_ptr<Writer>>(
120  mex, "SvgSimSpacePointWriter")
121  .def(py::init<const Writer::Config&, Acts::Logging::Level>(),
122  py::arg("config"), py::arg("level"))
123  .def("write",
124  py::overload_cast<const AlgorithmContext&>(&Writer::write));
125 
126  auto c = py::class_<Writer::Config>(w, "Config").def(py::init<>());
128  ACTS_PYTHON_MEMBER(writerName);
130  ACTS_PYTHON_MEMBER(inputCollection);
131  ACTS_PYTHON_MEMBER(infoBoxTitle);
134  }
135  {
136  using Writer =
139  auto w =
140  py::class_<Writer, ActsExamples::IWriter, std::shared_ptr<Writer>>(
141  mex, "SvgSimHitWriter")
142  .def(py::init<const Writer::Config&, Acts::Logging::Level>(),
143  py::arg("config"), py::arg("level"))
144  .def("write",
145  py::overload_cast<const AlgorithmContext&>(&Writer::write));
146 
147  auto c = py::class_<Writer::Config>(w, "Config").def(py::init<>());
149  ACTS_PYTHON_MEMBER(writerName);
151  ACTS_PYTHON_MEMBER(inputCollection);
152  ACTS_PYTHON_MEMBER(infoBoxTitle);
155  }
156 }
157 } // namespace Acts::Python