0.4.1
Loading...
Searching...
No Matches
PlotTooltip.hpp
Go to the documentation of this file.
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
25
26namespace NAV
27{
28
29/// Plot Tooltip windows to show
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
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
54bool 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
71void 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
The class is responsible for all time-related tasks.
A buffer which is overwriting itself from the start when full.
The class is responsible for all time-related tasks.
Definition InsTime.hpp:710
A buffer which is overwriting itself from the start when full.
void ShowPlotTooltipWindows(std::vector< PlotTooltip > &tooltips, size_t plotItemIdx, const std::string &plotName, const std::string &uid, const std::vector< int * > &parentWindows, const std::function< InsTime(size_t)> &getInsTime, const std::function< void(size_t, const char *)> &showTooltipCallback)
Shows all tooltip windows in the vector.
bool ShowPlotTooltip(std::vector< PlotTooltip > &tooltips, size_t plotItemIdx, const std::string &plotName, ImAxis axis, const ScrollingBuffer< double > &xData, const ScrollingBuffer< double > &yData, bool otherHoverTooltipsShown, const std::function< void(size_t)> &showTooltipCallback)
Shows a tooltip if the plot is hovered.
std::optional< ImVec2 > startPos
Initial start position of the tooltip window.
PlotTooltip(size_t plotItemIdx, size_t dataIdx, const ImVec2 &startPos)
Constructor.
size_t plotItemIdx
The plot item index the tooltip belongs to.
size_t dataIdx
The data index the tooltip belongs to.