0.4.1
Loading...
Searching...
No Matches
NodeEditorApplication.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 NodeEditorApplication.hpp
10/// @brief GUI callbacks
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2020-12-14
13
14#pragma once
15
16#include <array>
17#include <cstdint>
18#include <vector>
19
20#include <application.h>
21#include <imgui.h>
22#include <implot.h>
23
26
27namespace NAV
28{
29class Node;
30class Pin;
31
32namespace gui
33{
34/// @brief Application class providing all relevant GUI callbacks
35class NodeEditorApplication : public Application
36{
37 private:
38 constexpr static float BOTTOM_VIEW_COLLAPSED_MIN_HEIGHT = 23.0F; ///< Minimal height of the bottom view if it is collapsed
39 constexpr static float BOTTOM_VIEW_UNCOLLAPSED_MIN_HEIGHT = 200.0F; ///< Minimal height of the bottom view if it is not collapsed
40
41 public:
42 /// @brief Default constructor
44 /// @brief Destructor
45 ~NodeEditorApplication() override = default;
46 /// @brief Copy constructor
48 /// @brief Move constructor
50 /// @brief Copy assignment operator
52 /// @brief Move assignment operator
54
55 /// Bring the Application Constructors into this class (NOLINTNEXTLINE)
56 using Application::Application;
57
58 // static Node* SpawnInputActionNode();
59
60 // static Node* SpawnLessNode();
61
62 // static Node* SpawnGroupBox();
63
64 /// @brief Called when the application is started
65 void OnStart() override;
66
67 /// @brief Called when the application is stopped
68 void OnStop() override;
69
70 /// @brief Called when the user request the application to close
71 ///
72 /// Checks whether there are unsaved changes and then prompts the user to save them before quit
73 /// @return True if no unsaved changes
74 bool OnQuitRequest() override;
75
76 /// @brief Called on every frame
77 /// @param[in] deltaTime Time since last frame
78 void OnFrame(float deltaTime) override;
79
80 /// @brief Shows a PopupModal asking the user if he wants to quit with unsaved changes
81 void ShowQuitRequested();
82 /// @brief Shows a PopupModel where the user can select a path to save his flow to
84 /// @brief Shows a PopupModel to clear the current flow
86 /// @brief Shows a PopupModel loading a new flow
87 void ShowLoadRequested();
88 /// @brief Shows a PopupModal where the user can rename the node
89 /// @param[in, out] renameNode Pointer to the node to rename. Pointer gets nulled when finished.
90 static void ShowRenameNodeRequest(Node*& renameNode);
91 /// @brief Shows a PopupModal where the user can rename the pin
92 /// @param[in, out] renamePin Pointer to the pin to rename. Pointer gets nulled when finished.
93 static void ShowRenamePinRequest(Pin*& renamePin);
94
95 /// @brief Frame counter to block the navigate to content function till nodes are correctly loaded
97
98 /// Shows the queue size on the pins (every frame the queue mutex will be locked)
99 static inline bool _showQueueSizeOnPins = false;
100
101 /// @brief Pointer to the texture for the instinct logo
102 static inline std::array<ImTextureID, 2> m_InstinctLogo{ nullptr, nullptr };
103
104 /// @brief Pointer to the texture for the INS logo
105 static inline std::array<ImTextureID, 2> m_InsLogo{ nullptr, nullptr };
106
107 /// @brief Pointer to the texture for the save button
108 static inline ImTextureID m_SaveButtonImage = nullptr;
109
110 /// @brief Pointer to the texture for the rose figure (ImuSimulator node)
111 static inline ImTextureID m_RoseFigure = nullptr;
112
113 /// @brief Default style of the ImPlot library to compare changes against
114 static inline ImPlotStyle imPlotReferenceStyle;
115
116 static inline bool hideLeftPane = false; ///< Hide left pane
117 static inline bool hideFPS = false; ///< Hide FPS counter
118 inline static float leftPaneWidth = 350.0F; ///< Width of the left pane
119 inline static float rightPaneWidth = 850.0F; ///< Width of the right pane
120 inline static float menuBarHeight = 20; ///< Height of the menu bar on top
121 constexpr static float SPLITTER_THICKNESS = 4.0F; ///< Thickness of the splitter between left and right pane
122 inline static float bottomViewHeight = BOTTOM_VIEW_COLLAPSED_MIN_HEIGHT; ///< Height of the log viewer
123
124 /// Ratio to multiply for default GUI elements
125 static float defaultFontRatio();
126 /// Ratio to multiply for GUI window elements
127 static float windowFontRatio();
128 /// Ratio to multiply for GUI editor elements
129 static float panelFontRatio();
130 /// Ratio to multiply for log output GUI elements
131 static float monoFontRatio();
132 /// Ratio to multiply for node header elements
133 static float headerFontRatio();
134
135 /// Available color settings
136 enum Colors : uint8_t
137 {
138 COLOR_GROUP_HEADER_TEXT, ///< Color of the group header text
139 COLOR_GROUP_HEADER_BG, ///< Color of the group header background
140 COLOR_GROUP_OUTER_BORDER, ///< Color of the group outer border
141 };
142
143 /// Color settings
144 static inline std::vector<ImVec4> m_colors = {
145 { 1.0, 1.0, 1.0, 1.0 }, // GROUP_HEADER_TEXT
146 { 1.0, 1.0, 1.0, 0.25 }, // GROUP_HEADER_BG
147 { 1.0, 1.0, 1.0, 0.25 }, // GROUP_OUTER_BORDER
148 };
149 /// Color names
150 static inline std::vector<const char*> m_colorsNames = {
151 "GroupHeaderText", // GROUP_HEADER_TEXT
152 "GroupHeaderBg", // GROUP_HEADER_BG
153 "GroupOuterBorder", // GROUP_OUTER_BORDER
154 };
155
156 private:
157 /// @brief Tabs displayed in the bottom view
158 enum class BottomViewTabItem : uint8_t
159 {
160 None, ///< The cross item is selected
161 LogOutput, ///< The log output item is selected
162 };
163
164 BottomViewTabItem bottomViewSelectedTab = BottomViewTabItem::None; ///< Selected Tab item in the bottom view
165
166 /// @brief Pointer to the texture for the node headers
167 ImTextureID m_HeaderBackground = nullptr;
168
169 /// @brief Global action to execute
170 GlobalActions globalAction = GlobalActions::None; // TODO: Move to the GlobalAction.cpp as a global variable
171
172 /// @brief Shows a window for choosing the font size
173 /// @param[in, out] show Flag which indicates whether the window is shown
174 friend void windows::ShowFontSizeEditor(bool* show);
175};
176
177} // namespace gui
178} // namespace NAV
Font size chooser window.
Global Gui Actions.
GlobalActions
Possible Global Actions to perform in the GUI.
@ None
None.
Abstract parent class for all nodes.
Definition Node.hpp:92
Pins in the GUI for information exchange.
Definition Pin.hpp:43
static ImPlotStyle imPlotReferenceStyle
Default style of the ImPlot library to compare changes against.
static float bottomViewHeight
Height of the log viewer.
static float windowFontRatio()
Ratio to multiply for GUI window elements.
static std::array< ImTextureID, 2 > m_InstinctLogo
Pointer to the texture for the instinct logo.
static float leftPaneWidth
Width of the left pane.
static constexpr float SPLITTER_THICKNESS
Thickness of the splitter between left and right pane.
NodeEditorApplication & operator=(const NodeEditorApplication &)=delete
Copy assignment operator.
GlobalActions globalAction
Global action to execute.
bool OnQuitRequest() override
Called when the user request the application to close.
static void ShowRenameNodeRequest(Node *&renameNode)
Shows a PopupModal where the user can rename the node.
static std::vector< ImVec4 > m_colors
Color settings.
static float defaultFontRatio()
Ratio to multiply for default GUI elements.
static bool hideLeftPane
Hide left pane.
static float monoFontRatio()
Ratio to multiply for log output GUI elements.
BottomViewTabItem
Tabs displayed in the bottom view.
static ImTextureID m_RoseFigure
Pointer to the texture for the rose figure (ImuSimulator node)
static std::array< ImTextureID, 2 > m_InsLogo
Pointer to the texture for the INS logo.
void OnStart() override
Called when the application is started.
NodeEditorApplication(NodeEditorApplication &&)=delete
Move constructor.
void ShowSaveAsRequested()
Shows a PopupModel where the user can select a path to save his flow to.
NodeEditorApplication(const NodeEditorApplication &)=delete
Copy constructor.
static bool _showQueueSizeOnPins
Shows the queue size on the pins (every frame the queue mutex will be locked)
void ShowLoadRequested()
Shows a PopupModel loading a new flow.
void ShowQuitRequested()
Shows a PopupModal asking the user if he wants to quit with unsaved changes.
void OnStop() override
Called when the application is stopped.
ImTextureID m_HeaderBackground
Pointer to the texture for the node headers.
static void ShowRenamePinRequest(Pin *&renamePin)
Shows a PopupModal where the user can rename the pin.
NodeEditorApplication()=delete
Default constructor.
void ShowClearNodesRequested()
Shows a PopupModel to clear the current flow.
static std::vector< const char * > m_colorsNames
Color names.
void OnFrame(float deltaTime) override
Called on every frame.
static float rightPaneWidth
Width of the right pane.
static constexpr float BOTTOM_VIEW_COLLAPSED_MIN_HEIGHT
Minimal height of the bottom view if it is collapsed.
static float panelFontRatio()
Ratio to multiply for GUI editor elements.
~NodeEditorApplication() override=default
Destructor.
NodeEditorApplication & operator=(NodeEditorApplication &&)=delete
Move assignment operator.
static constexpr float BOTTOM_VIEW_UNCOLLAPSED_MIN_HEIGHT
Minimal height of the bottom view if it is not collapsed.
static ImTextureID m_SaveButtonImage
Pointer to the texture for the save button.
static bool hideFPS
Hide FPS counter.
int frameCountNavigate
Frame counter to block the navigate to content function till nodes are correctly loaded.
BottomViewTabItem bottomViewSelectedTab
Selected Tab item in the bottom view.
static float headerFontRatio()
Ratio to multiply for node header elements.
@ COLOR_GROUP_OUTER_BORDER
Color of the group outer border.
@ COLOR_GROUP_HEADER_BG
Color of the group header background.
@ COLOR_GROUP_HEADER_TEXT
Color of the group header text.
static float menuBarHeight
Height of the menu bar on top.
void ShowFontSizeEditor(bool *show=nullptr)
Shows a window for choosing the font size.