-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparametersview.cpp
73 lines (61 loc) · 2.56 KB
/
parametersview.cpp
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
/*
Copyright 2019 Balázs Ludmány
This file is part of contours-viewer.
contours-viewer is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
contours-viewer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with contours-viewer. If not, see <https://www.gnu.org/licenses/>.
*/
#include "parametersview.hpp"
#include <boost/range/adaptor/indexed.hpp>
static constexpr const char *labels[] = {
"Sphere volume (%)", "Number of centers", "Number of lines",
"Minimum area (%)", "Aggregation method"};
static constexpr const char *types[] = {"double", "long", "long", "double",
"string"};
static constexpr std::size_t label_count =
sizeof(labels) / sizeof(const char *);
static constexpr const char *aggr_types[] = {"first", "average", "Smin",
"Smax", "Umin", "Umax"};
void ParametersView::Initialize() {
CreateGrid(0, label_count);
EnableEditing(false);
for (int col = 0; col < label_count; ++col) {
SetColLabelValue(col, labels[col]);
SetColFormatCustom(col, types[col]);
}
AutoSize();
}
void ParametersView::Update(const Parameters ¶meters) {
wxCriticalSectionLocker lock(m_critical_section);
for (const auto ¢er_sphere : parameters) {
for (const auto &level_count : center_sphere.next) {
for (const auto &area_ratio : level_count.next) {
for (const auto &aggregation : area_ratio.next) {
m_table.push_back(
{wxString::Format("%f", center_sphere.value.ratio * 100.0),
wxString::Format("%d", center_sphere.value.count),
wxString::Format("%d", level_count.value),
wxString::Format("%f", area_ratio.value * 100.0),
wxString(aggr_types[aggregation])});
}
}
}
}
}
void ParametersView::Swap() {
using boost::adaptors::indexed;
wxGridUpdateLocker lock(this);
wxCriticalSectionLocker lock2(m_critical_section);
AppendRows(m_table.size());
for (const auto &row : m_table | indexed())
for (const auto &cell : row.value() | indexed())
SetCellValue(row.index(), cell.index(), cell.value());
AutoSize();
}