INSTINCT Code Coverage Report


Directory: src/
File: Navigation/Gravity/Gravity.cpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 0 27 0.0%
Functions: 0 2 0.0%
Branches: 0 17 0.0%

Line Branch Exec Source
1 // This file is part of INSTINCT, the INS Toolkit for Integrated
2 // Navigation Concepts and Training by the Institute of Navigation of
3 // the University of Stuttgart, Germany.
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 #include "Gravity.hpp"
10
11 #include <cmath>
12 #include <optional>
13 #include <string>
14 #include <fstream>
15 #include <streambuf>
16
17 #include <imgui.h>
18
19 namespace NAV
20 {
21
22 const char* to_string(GravitationModel gravitationModel)
23 {
24 switch (gravitationModel)
25 {
26 case GravitationModel::None:
27 return "None";
28 case GravitationModel::WGS84:
29 return "WGS84";
30 case GravitationModel::WGS84_Skydel:
31 return "WGS84 (Skydel Constants)";
32 case GravitationModel::Somigliana:
33 return "Somigliana";
34 case GravitationModel::EGM96:
35 return "EGM96";
36 case GravitationModel::COUNT:
37 return "";
38 }
39 return "";
40 }
41
42 bool ComboGravitationModel(const char* label, GravitationModel& gravitationModel)
43 {
44 bool clicked = false;
45 if (ImGui::BeginCombo(label, NAV::to_string(gravitationModel)))
46 {
47 for (size_t i = 0; i < static_cast<size_t>(GravitationModel::COUNT); i++)
48 {
49 const bool is_selected = (static_cast<size_t>(gravitationModel) == i);
50 if (ImGui::Selectable(NAV::to_string(static_cast<GravitationModel>(i)), is_selected))
51 {
52 gravitationModel = static_cast<GravitationModel>(i);
53 clicked = true;
54 }
55
56 // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
57 if (is_selected)
58 {
59 ImGui::SetItemDefaultFocus();
60 }
61 }
62
63 ImGui::EndCombo();
64 }
65 return clicked;
66 }
67
68 } // namespace NAV
69