INSTINCT Code Coverage Report


Directory: src/
File: internal/gui/Shortcuts.cpp
Date: 2025-11-25 23:34:18
Exec Total Coverage
Lines: 0 42 0.0%
Functions: 0 1 0.0%
Branches: 0 78 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 "Shortcuts.hpp"
10
11 #include <imgui.h>
12 #include <imgui_node_editor.h>
13 namespace ed = ax::NodeEditor;
14
15 #include "internal/FlowManager.hpp"
16 #include "internal/FlowExecutor.hpp"
17
18 #include <iostream>
19
20 void NAV::gui::checkShortcuts(GlobalActions& globalAction)
21 {
22 auto& io = ImGui::GetIO();
23 // Available Flags for key modifiers
24 // io.KeyCtrl;
25 // io.KeyAlt;
26 // io.KeyShift;
27 // io.KeySuper;
28
29 if (!io.KeyCtrl && !io.KeyAlt && !io.KeyShift && !io.KeySuper)
30 {
31 if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_F)))
32 {
33 ed::NavigateToContent();
34 }
35 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_F7)))
36 {
37 if (!FlowExecutor::isRunning())
38 {
39 LOG_INFO("Starting Flow Execution");
40 FlowExecutor::start();
41 }
42 }
43 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
44 {
45 flow::DisableAllCallbacks();
46 flow::ClearAllNodeQueues();
47 if (FlowExecutor::isRunning())
48 {
49 LOG_INFO("Canceling Execution...");
50 FlowExecutor::stop();
51 LOG_INFO("Execution canceled");
52 }
53 }
54 }
55 else if (io.KeyCtrl && !io.KeyAlt && !io.KeyShift && !io.KeySuper)
56 {
57 if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_N)))
58 {
59 if (flow::HasUnsavedChanges())
60 {
61 globalAction = GlobalActions::Clear;
62 }
63 else
64 {
65 flow::DeleteAllNodes();
66 flow::DiscardChanges();
67 flow::SetCurrentFilename("");
68 }
69 }
70 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_S)))
71 {
72 flow::SaveFlow(globalAction);
73 }
74 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_O)))
75 {
76 globalAction = GlobalActions::Load;
77 }
78 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Q)))
79 {
80 globalAction = GlobalActions::Quit;
81 }
82 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_X)) // Cut
83 && canCutOrCopyFlowElements())
84 {
85 cutFlowElements();
86 }
87 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)) // Copy
88 && canCutOrCopyFlowElements())
89 {
90 copyFlowElements();
91 }
92 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_V)) // Paste
93 && canPasteFlowElements())
94 {
95 pasteFlowElements();
96 }
97 }
98 else if (io.KeyCtrl && !io.KeyAlt && io.KeyShift && !io.KeySuper)
99 {
100 if (io.KeyShift && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_S)))
101 {
102 globalAction = GlobalActions::SaveAs;
103 }
104 }
105 }
106