| 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 "RunMenu.hpp" | ||
| 10 | |||
| 11 | #include <imgui.h> | ||
| 12 | |||
| 13 | #include "internal/FlowExecutor.hpp" | ||
| 14 | #include "internal/FlowManager.hpp" | ||
| 15 | |||
| 16 | #include "util/Logger.hpp" | ||
| 17 | |||
| 18 | ✗ | void NAV::gui::menus::ShowRunMenu() | |
| 19 | { | ||
| 20 | ✗ | bool hasInitializedNodes = false; | |
| 21 | ✗ | bool hasDeInitializedNodes = false; | |
| 22 | ✗ | for (const auto* node : flow::m_Nodes()) | |
| 23 | { | ||
| 24 | ✗ | if (node->getState() == Node::State::Initialized) | |
| 25 | { | ||
| 26 | ✗ | hasInitializedNodes = true; | |
| 27 | } | ||
| 28 | ✗ | else if (node->getState() == Node::State::Deinitialized) | |
| 29 | { | ||
| 30 | ✗ | hasDeInitializedNodes = true; | |
| 31 | } | ||
| 32 | } | ||
| 33 | ✗ | if (ImGui::MenuItem("Initialize all Nodes", nullptr, false, hasDeInitializedNodes)) | |
| 34 | { | ||
| 35 | ✗ | for (auto* node : flow::m_Nodes()) | |
| 36 | { | ||
| 37 | ✗ | if (node->getState() == Node::State::Deinitialized) | |
| 38 | { | ||
| 39 | ✗ | node->doInitialize(); | |
| 40 | } | ||
| 41 | } | ||
| 42 | } | ||
| 43 | ✗ | if (ImGui::MenuItem("Reinitialize all Nodes", nullptr, false, hasInitializedNodes)) | |
| 44 | { | ||
| 45 | ✗ | for (auto* node : flow::m_Nodes()) | |
| 46 | { | ||
| 47 | ✗ | if (node->isInitialized()) | |
| 48 | { | ||
| 49 | ✗ | node->doReinitialize(); | |
| 50 | } | ||
| 51 | ✗ | else if (node->getState() == Node::State::Deinitialized) | |
| 52 | { | ||
| 53 | ✗ | node->doInitialize(); | |
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
| 57 | ✗ | if (ImGui::MenuItem("Deinitialize all Nodes", nullptr, false, hasInitializedNodes)) | |
| 58 | { | ||
| 59 | ✗ | for (auto* node : flow::m_Nodes()) | |
| 60 | { | ||
| 61 | ✗ | if (node->isInitialized()) | |
| 62 | { | ||
| 63 | ✗ | node->doDeinitialize(); | |
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | ✗ | ImGui::Separator(); | |
| 69 | |||
| 70 | ✗ | if (ImGui::MenuItem("Run Flow", "F7", false, !FlowExecutor::isRunning())) | |
| 71 | { | ||
| 72 | ✗ | if (!FlowExecutor::isRunning()) | |
| 73 | { | ||
| 74 | ✗ | LOG_INFO("Starting Flow Execution"); | |
| 75 | ✗ | FlowExecutor::start(); | |
| 76 | } | ||
| 77 | } | ||
| 78 | ✗ | if (ImGui::MenuItem("Stop Execution", "Esc", false, FlowExecutor::isRunning())) | |
| 79 | { | ||
| 80 | ✗ | if (FlowExecutor::isRunning()) | |
| 81 | { | ||
| 82 | ✗ | LOG_INFO("Canceling Execution..."); | |
| 83 | ✗ | FlowExecutor::stop(); | |
| 84 | ✗ | LOG_INFO("Execution canceled"); | |
| 85 | } | ||
| 86 | } | ||
| 87 | ✗ | } | |
| 88 |