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/NodeManager.hpp" |
16 |
|
|
namespace nm = NAV::NodeManager; |
17 |
|
|
|
18 |
|
|
#include "internal/FlowManager.hpp" |
19 |
|
|
#include "internal/FlowExecutor.hpp" |
20 |
|
|
|
21 |
|
|
#include <iostream> |
22 |
|
|
|
23 |
|
✗ |
void NAV::gui::checkShortcuts(GlobalActions& globalAction) |
24 |
|
|
{ |
25 |
|
✗ |
auto& io = ImGui::GetIO(); |
26 |
|
|
// Available Flags for key modifiers |
27 |
|
|
// io.KeyCtrl; |
28 |
|
|
// io.KeyAlt; |
29 |
|
|
// io.KeyShift; |
30 |
|
|
// io.KeySuper; |
31 |
|
|
|
32 |
|
✗ |
if (!io.KeyCtrl && !io.KeyAlt && !io.KeyShift && !io.KeySuper) |
33 |
|
|
{ |
34 |
|
✗ |
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_F))) |
35 |
|
|
{ |
36 |
|
✗ |
ed::NavigateToContent(); |
37 |
|
|
} |
38 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_F7))) |
39 |
|
|
{ |
40 |
|
✗ |
if (!FlowExecutor::isRunning()) |
41 |
|
|
{ |
42 |
|
✗ |
LOG_INFO("Starting Flow Execution"); |
43 |
|
✗ |
FlowExecutor::start(); |
44 |
|
|
} |
45 |
|
|
} |
46 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))) |
47 |
|
|
{ |
48 |
|
✗ |
nm::DisableAllCallbacks(); |
49 |
|
✗ |
nm::ClearAllNodeQueues(); |
50 |
|
✗ |
if (FlowExecutor::isRunning()) |
51 |
|
|
{ |
52 |
|
✗ |
LOG_INFO("Canceling Execution..."); |
53 |
|
✗ |
FlowExecutor::stop(); |
54 |
|
✗ |
LOG_INFO("Execution canceled"); |
55 |
|
|
} |
56 |
|
|
} |
57 |
|
|
} |
58 |
|
✗ |
else if (io.KeyCtrl && !io.KeyAlt && !io.KeyShift && !io.KeySuper) |
59 |
|
|
{ |
60 |
|
✗ |
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_N))) |
61 |
|
|
{ |
62 |
|
✗ |
if (flow::HasUnsavedChanges()) |
63 |
|
|
{ |
64 |
|
✗ |
globalAction = GlobalActions::Clear; |
65 |
|
|
} |
66 |
|
|
else |
67 |
|
|
{ |
68 |
|
✗ |
nm::DeleteAllNodes(); |
69 |
|
✗ |
flow::DiscardChanges(); |
70 |
|
✗ |
flow::SetCurrentFilename(""); |
71 |
|
|
} |
72 |
|
|
} |
73 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_S))) |
74 |
|
|
{ |
75 |
|
✗ |
flow::SaveFlow(globalAction); |
76 |
|
|
} |
77 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_O))) |
78 |
|
|
{ |
79 |
|
✗ |
globalAction = GlobalActions::Load; |
80 |
|
|
} |
81 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Q))) |
82 |
|
|
{ |
83 |
|
✗ |
globalAction = GlobalActions::Quit; |
84 |
|
|
} |
85 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_X)) // Cut |
86 |
|
✗ |
&& canCutOrCopyFlowElements()) |
87 |
|
|
{ |
88 |
|
✗ |
cutFlowElements(); |
89 |
|
|
} |
90 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)) // Copy |
91 |
|
✗ |
&& canCutOrCopyFlowElements()) |
92 |
|
|
{ |
93 |
|
✗ |
copyFlowElements(); |
94 |
|
|
} |
95 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_V)) // Paste |
96 |
|
✗ |
&& canPasteFlowElements()) |
97 |
|
|
{ |
98 |
|
✗ |
pasteFlowElements(); |
99 |
|
|
} |
100 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Z)) // Undo |
101 |
|
✗ |
&& canUndoLastAction()) |
102 |
|
|
{ |
103 |
|
✗ |
undoLastAction(); |
104 |
|
|
} |
105 |
|
✗ |
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Y)) // Redo |
106 |
|
✗ |
&& canRedoLastAction()) |
107 |
|
|
{ |
108 |
|
✗ |
redoLastAction(); |
109 |
|
|
} |
110 |
|
|
} |
111 |
|
✗ |
else if (io.KeyCtrl && !io.KeyAlt && io.KeyShift && !io.KeySuper) |
112 |
|
|
{ |
113 |
|
✗ |
if (io.KeyShift && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_S))) |
114 |
|
|
{ |
115 |
|
✗ |
globalAction = GlobalActions::SaveAs; |
116 |
|
|
} |
117 |
|
|
} |
118 |
|
✗ |
} |
119 |
|
|
|