-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathSegmentationSVGWriter.cxx
More file actions
117 lines (104 loc) · 2.85 KB
/
SegmentationSVGWriter.cxx
File metadata and controls
117 lines (104 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// @author Laurent Aphecetche
#include "MCHMappingSegContour/CathodeSegmentationSVGWriter.h"
#include "MCHMappingInterface/CathodeSegmentation.h"
#include "MCHMappingSegContour/CathodeSegmentationContours.h"
#include "MCHContour/SVGWriter.h"
#include <ostream>
using namespace o2::mch::contour;
namespace o2
{
namespace mch
{
namespace mapping
{
std::string svgCathodeSegmentationDefaultStyle()
{
return R"(
.pads {
fill: #EEEEEE;
stroke-width: 0.025px;
stroke: #AAAAAA;
}
.padchannels {
font-size: 0.4px;
font-family: arial;
fill: blue;
text-anchor: middle;
}
.dualsampas {
fill:none;
stroke-width: 0.025px;
stroke: #333333;
}
.detectionelements {
fill:none;
stroke-width:0.025px;
stroke: #000000;
}
.testpoints {
fill:red;
stroke-width:0.025px;
stroke: black;
opacity: 0.5;
}
)";
}
void svgCathodeSegmentation(const CathodeSegmentation& seg, SVGWriter& w, bool showdes, bool showdualsampas, bool showpads,
bool showpadchannels)
{
std::vector<Contour<double>> dualSampaContours = getDualSampaContours(seg);
std::vector<std::vector<Polygon<double>>> dualSampaPads = getPadPolygons(seg);
std::vector<std::vector<int>> dualSampaPadChannels = getPadChannels(seg);
if (dualSampaPadChannels.size() != dualSampaPads.size()) {
throw std::runtime_error("gouze");
}
auto deContour = getEnvelop(seg);
auto box = getBBox(seg);
if (showpads) {
w.svgGroupStart("pads");
for (auto& dsp : dualSampaPads) {
for (auto& p : dsp) {
w.polygon(p);
}
}
w.svgGroupEnd();
}
if (showpadchannels) {
w.svgGroupStart("padchannels");
for (auto i = 0; i < dualSampaPads.size(); ++i) {
auto& dsp = dualSampaPads[i];
auto& dspch = dualSampaPadChannels[i];
for (auto j = 0; j < dsp.size(); j++) {
auto bbox = getBBox(dsp[j]);
w.text(std::to_string(dspch[j]), bbox.xcenter(),
bbox.ymax() - 0.05 * bbox.height()); // SVG text y position is the bottom of the text
}
}
w.svgGroupEnd();
}
if (showdualsampas) {
w.svgGroupStart("dualsampas");
for (auto& dsp : dualSampaContours) {
w.contour(dsp);
}
w.svgGroupEnd();
}
if (showdes) {
w.svgGroupStart("detectionelements");
w.contour(deContour);
}
}
} // namespace mapping
} // namespace mch
} // namespace o2