0.3.0
Loading...
Searching...
No Matches
Shortcuts.cpp
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#include "Shortcuts.hpp"
10
11#include <imgui.h>
12#include <imgui_node_editor.h>
13namespace ed = ax::NodeEditor;
14
16namespace nm = NAV::NodeManager;
17
20
21#include <iostream>
22
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 {
41 {
42 LOG_INFO("Starting Flow Execution");
44 }
45 }
46 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
47 {
51 {
52 LOG_INFO("Canceling Execution...");
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 {
63 {
64 globalAction = GlobalActions::Clear;
65 }
66 else
67 {
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
87 {
89 }
90 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)) // Copy
92 {
94 }
95 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_V)) // Paste
97 {
99 }
100 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Z)) // Undo
102 {
104 }
105 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Y)) // Redo
107 {
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}
Flow Executor Thread.
Save/Load the Nodes.
GlobalActions
Possible Global Actions to perform in the GUI.
@ Clear
Clear the flow.
@ Quit
Quit the program.
@ Load
Load a flow.
@ SaveAs
Save the flow as filename.
#define LOG_INFO
Info to the user on the state of the program.
Definition Logger.hpp:69
Manages all Nodes.
Defines all available shortcuts.
bool isRunning() noexcept
Checks if the thread is running.
void start()
Starts the Thread.
void stop()
Stops the Thread.
void ClearAllNodeQueues()
Clears all nodes queues.
void DisableAllCallbacks()
Disables all Node callbacks.
void DeleteAllNodes()
Delete all nodes.
void SetCurrentFilename(const std::string &newFilename)
Set the current filename of the open flow.
void DiscardChanges()
Discards the unsaved changes flag. Does not really discard the changes.
bool HasUnsavedChanges()
Checks if the currently open flow has unsaved changes.
void SaveFlow(GlobalActions &globalAction)
Saves the current flow into a file.
bool canPasteFlowElements()
Checks if elements can be pasted.
void copyFlowElements()
Copies the currently selected elements.
bool canUndoLastAction()
Checks if an action can be undone.
bool canCutOrCopyFlowElements()
Checks if elements can be cutted/copied.
bool canRedoLastAction()
Checks if an action can be redone.
void pasteFlowElements()
Pastes the copied/cutted elements.
void checkShortcuts(GlobalActions &globalAction)
Checks if a shortcut was pressed.
Definition Shortcuts.cpp:23
void cutFlowElements()
Cuts the currently selected elements.
void redoLastAction()
Redo the last action.
void undoLastAction()
Undo the last action.