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 |
|
|
/// @file DynamicData.cpp |
10 |
|
|
/// @brief Dynamic Data container |
11 |
|
|
/// @author T. Topp (topp@ins.uni-stuttgart.de) |
12 |
|
|
/// @date 2024-07-19 |
13 |
|
|
|
14 |
|
|
#include "DynamicData.hpp" |
15 |
|
|
|
16 |
|
|
#include <algorithm> |
17 |
|
|
#include <cstddef> |
18 |
|
|
#include <ctime> |
19 |
|
|
#include <imgui.h> |
20 |
|
|
#include "Navigation/Time/InsTime.hpp" |
21 |
|
|
#include <fmt/core.h> |
22 |
|
|
|
23 |
|
✗ |
void NAV::DynamicData::guiTooltip(bool detailView, bool firstOpen, const char* displayName, const char* id, int* rootWindow) const |
24 |
|
|
{ |
25 |
|
✗ |
ImGui::SetNextItemOpen(detailView, firstOpen ? ImGuiCond_Always : ImGuiCond_Once); |
26 |
|
|
|
27 |
|
✗ |
auto d = std::ranges::find_if(data, [&](const auto& dat) { |
28 |
|
✗ |
return dat.description == displayName; |
29 |
|
|
}); |
30 |
|
✗ |
if (d == data.end()) { return; } |
31 |
|
|
|
32 |
|
✗ |
if (std::ranges::any_of(d->rawData, [&](const auto& raw) { |
33 |
|
✗ |
return raw.second->insTime != insTime; |
34 |
|
|
})) |
35 |
|
|
{ |
36 |
|
✗ |
bool sameLine = false; |
37 |
|
✗ |
for (const auto& raw : d->rawData) |
38 |
|
|
{ |
39 |
|
✗ |
auto timeString = fmt::format("{}", raw.second->insTime.toYMDHMS(GPST)); |
40 |
|
✗ |
auto len = static_cast<int>(raw.first.length()) - static_cast<int>(timeString.length()); |
41 |
|
|
|
42 |
|
✗ |
if (raw.second->hasTooltip()) |
43 |
|
|
{ |
44 |
|
✗ |
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetStyle().ItemInnerSpacing.x); |
45 |
|
✗ |
if (sameLine) |
46 |
|
|
{ |
47 |
|
✗ |
ImGui::SameLine(); |
48 |
|
✗ |
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetStyle().ItemInnerSpacing.x); |
49 |
|
|
} |
50 |
|
|
|
51 |
|
✗ |
if (len > 0) |
52 |
|
|
{ |
53 |
|
✗ |
ImGui::TextUnformatted(fmt::format("{}{:{w}}", timeString, " ", fmt::arg("w", len)).c_str()); |
54 |
|
|
} |
55 |
|
✗ |
else { ImGui::TextUnformatted(timeString.c_str()); } |
56 |
|
✗ |
sameLine = true; |
57 |
|
|
} |
58 |
|
✗ |
} |
59 |
|
|
} |
60 |
|
|
|
61 |
|
✗ |
if (std::none_of(d->rawData.begin(), d->rawData.end(), [](const auto& raw) { return raw.second->hasTooltip(); })) { return; } |
62 |
|
|
|
63 |
|
✗ |
if (ImGui::BeginTabBar(fmt::format("##dyndata {}", id).c_str(), ImGuiTabBarFlags_None)) |
64 |
|
|
{ |
65 |
|
✗ |
for (const auto& raw : d->rawData) |
66 |
|
|
{ |
67 |
|
✗ |
if (!raw.second->hasTooltip()) { continue; } |
68 |
|
✗ |
auto timeString = fmt::format("{}", raw.second->insTime.toYMDHMS(GPST)); |
69 |
|
✗ |
if (ImGui::BeginTabItem(fmt::format("{}##{} {}", raw.first, timeString, id).c_str())) |
70 |
|
|
{ |
71 |
|
✗ |
raw.second->guiTooltip(detailView, firstOpen, displayName, fmt::format("{} {} {}", raw.first, timeString, id).c_str(), rootWindow); |
72 |
|
✗ |
ImGui::EndTabItem(); |
73 |
|
|
} |
74 |
|
✗ |
} |
75 |
|
|
|
76 |
|
|
// if (ImGui::BeginTabItem(fmt::format("##{}", id).c_str())) |
77 |
|
|
// { |
78 |
|
|
// ImGui::EndTabItem(); |
79 |
|
|
// } |
80 |
|
|
|
81 |
|
✗ |
ImGui::EndTabBar(); |
82 |
|
|
} |
83 |
|
|
} |
84 |
|
|
|