INSTINCT Code Coverage Report


Directory: src/
File: util/Plot/PlotTooltip.hpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 0 2 0.0%
Functions: 0 1 0.0%
Branches: 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 /// @file PlotTooltip.hpp
10 /// @brief Plot Tooltips on hover
11 /// @author T. Topp (topp@ins.uni-stuttgart.de)
12 /// @date 2024-08-16
13
14 #pragma once
15
16 #include <cstddef>
17 #include <optional>
18 #include <functional>
19
20 #include <imgui.h>
21 #include <implot.h>
22
23 #include "Navigation/Time/InsTime.hpp"
24 #include "util/Container/ScrollingBuffer.hpp"
25
26 namespace NAV
27 {
28
29 /// Plot Tooltip windows to show
30 struct PlotTooltip
31 {
32 /// @brief Constructor
33 /// @param[in] plotItemIdx The plot item index the tooltip belongs to
34 /// @param[in] dataIdx The data index the tooltip belongs to
35 /// @param[in] startPos Initial start position of the tooltip window
36 PlotTooltip(size_t plotItemIdx, size_t dataIdx, const ImVec2& startPos)
37 : plotItemIdx(plotItemIdx), dataIdx(dataIdx), startPos(startPos) {}
38
39 size_t plotItemIdx = 0; ///< The plot item index the tooltip belongs to
40 size_t dataIdx = 0; ///< The data index the tooltip belongs to
41 std::optional<ImVec2> startPos; ///< Initial start position of the tooltip window
42 };
43
44 /// @brief Shows a tooltip if the plot is hovered
45 /// @param[in, out] tooltips Tooltip vector to show
46 /// @param[in] plotItemIdx Plot item index
47 /// @param[in] plotName Name of the plot item
48 /// @param[in] axis Axis to check for
49 /// @param[in] xData X axis data
50 /// @param[in] yData Y axis data
51 /// @param[in] otherHoverTooltipsShown Whether other hover tooltips are already shown
52 /// @param[in] showTooltipCallback Called inside the tooltip. Argument is the data index for which the tooltip is shown
53 /// @return True if a tooltip is shown
54 bool ShowPlotTooltip(std::vector<PlotTooltip>& tooltips,
55 size_t plotItemIdx,
56 const std::string& plotName,
57 ImAxis axis,
58 const ScrollingBuffer<double>& xData,
59 const ScrollingBuffer<double>& yData,
60 bool otherHoverTooltipsShown,
61 const std::function<void(size_t)>& showTooltipCallback);
62
63 /// @brief Shows all tooltip windows in the vector
64 /// @param[in, out] tooltips Tooltip vector to show
65 /// @param[in] plotItemIdx Plot item index
66 /// @param[in] plotName Name of the plot item
67 /// @param[in] uid Unique id for the window
68 /// @param[in] parentWindows Parent windows to stay on top of
69 /// @param[in] getInsTime Callback to get the time associated with the tooltip
70 /// @param[in] showTooltipCallback Called inside the tooltip. Argument is the data index and the unique id for which the tooltip is shown
71 void ShowPlotTooltipWindows(std::vector<PlotTooltip>& tooltips,
72 size_t plotItemIdx,
73 const std::string& plotName,
74 const std::string& uid,
75 const std::vector<int*>& parentWindows,
76 const std::function<InsTime(size_t)>& getInsTime,
77 const std::function<void(size_t, const char*)>& showTooltipCallback);
78
79 } // namespace NAV
80