0.5.1
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
17
18#include <iostream>
19
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 {
38 {
39 LOG_INFO("Starting Flow Execution");
41 }
42 }
43 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
44 {
48 {
49 LOG_INFO("Canceling Execution...");
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 {
60 {
61 globalAction = GlobalActions::Clear;
62 }
63 else
64 {
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
84 {
86 }
87 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)) // Copy
89 {
91 }
92 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_V)) // Paste
94 {
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}
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
Defines all available shortcuts.
bool isRunning() noexcept
Checks if the thread is running.
void start()
Starts the Thread.
void stop()
Stops the Thread.
void SetCurrentFilename(const std::string &newFilename)
Set the current filename of the open flow.
void DisableAllCallbacks()
Disables all Node callbacks.
void DeleteAllNodes()
Delete all nodes.
void DiscardChanges()
Discards the unsaved changes flag. Does not really discard the changes.
void ClearAllNodeQueues()
Clears all nodes queues.
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 canCutOrCopyFlowElements()
Checks if elements can be cutted/copied.
void pasteFlowElements()
Pastes the copied/cutted elements.
void checkShortcuts(GlobalActions &globalAction)
Checks if a shortcut was pressed.
Definition Shortcuts.cpp:20
void cutFlowElements()
Cuts the currently selected elements.