0.4.1
Loading...
Searching...
No Matches
FlowManager.hpp
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/// @file FlowManager.hpp
10/// @brief Save/Load the Nodes
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2020-12-16
13
14#pragma once
15
16#include <string>
17#include <filesystem>
19
20#include <nlohmann/json.hpp>
21using json = nlohmann::json; ///< json namespace
22
23namespace NAV::flow
24{
25/// @brief Saves the current flow into a file
26/// @param[out] globalAction If currentfilename is empty this will be returned as GlobalActions::SaveAs
27void SaveFlow(GlobalActions& globalAction);
28
29/// @brief Saves the current flow into the specified file
30/// @param[in] filepath Path where to save the flow
31void SaveFlowAs(const std::string& filepath);
32
33/// @brief Loads the flow from the specified file
34/// @param[in] filepath Path where to load the flow
35/// @return Whether the load was successfull
36bool LoadFlow(const std::string& filepath);
37
38/// @brief Loads the nodes and links from the specified json object
39/// @param[in] j Json object containing nodes and links to load
40/// @param[in] requestNewIds Set this true if the loaded nodes should receive new Ids (copy). False if the Ids should stay (cut/load)
41/// @return Whether the load was successfull
42bool LoadJson(const json& j, bool requestNewIds = false);
43
44/// @brief Checks if the currently open flow has unsaved changes
45/// @return True if there are changes
47
48/// @brief Signals that there have been changes to the flow
49void ApplyChanges();
50
51/// @brief Discards the unsaved changes flag. Does not really discard the changes.
52void DiscardChanges();
53
54/// @brief Get the current filename of the open flow
55/// @return Current filename of the open flow
56std::string GetCurrentFilename();
57
58/// @brief Set the current filename of the open flow
59/// @param[in] newFilename New filename of the flow
60void SetCurrentFilename(const std::string& newFilename);
61
62/// @brief Get the program root path
63/// @return The path to the program root
64std::filesystem::path GetProgramRootPath();
65
66/// @brief Set the program root path
67/// @param[in] newRootPath The new program root path
68void SetProgramRootPath(const std::filesystem::path& newRootPath);
69
70/// @brief Get the path where logs and outputs are stored
71std::filesystem::path GetOutputPath();
72
73/// @brief Set the path where logs and outputs are stored
74void SetOutputPath();
75
76/// @brief Get the path where data files are searched
77std::filesystem::path GetInputPath();
78
79/// @brief Get the path where flow files are searched
80std::filesystem::path GetFlowPath();
81
82/// @brief Get the path where config files are searched
83std::filesystem::path GetConfigPath();
84
85/// @brief Whether actions should be saved to the last actions list
86extern bool saveLastActions;
87
88/// @brief Frame Count when changes were loaded to prevent nodes moving from triggering unsaved changes
89extern int loadingFrameCount;
90
91} // namespace NAV::flow
nlohmann::json json
json namespace
Global Gui Actions.
GlobalActions
Possible Global Actions to perform in the GUI.
bool saveLastActions
Whether actions should be saved to the last actions list.
void SetProgramRootPath(const std::filesystem::path &newRootPath)
Set the program root path.
bool LoadJson(const json &j, bool requestNewIds=false)
Loads the nodes and links from the specified json object.
void SetCurrentFilename(const std::string &newFilename)
Set the current filename of the open flow.
bool LoadFlow(const std::string &filepath)
Loads the flow from the specified file.
int loadingFrameCount
Frame Count when changes were loaded to prevent nodes moving from triggering unsaved changes.
std::filesystem::path GetConfigPath()
Get the path where config files are searched.
std::filesystem::path GetOutputPath()
Get the path where logs and outputs are stored.
void SaveFlowAs(const std::string &filepath)
Saves the current flow into the specified file.
std::filesystem::path GetInputPath()
Get the path where data files are searched.
void DiscardChanges()
Discards the unsaved changes flag. Does not really discard the changes.
std::string GetCurrentFilename()
Get the current filename of the open flow.
void ApplyChanges()
Signals that there have been changes to the flow.
std::filesystem::path GetFlowPath()
Get the path where flow files are searched.
std::filesystem::path GetProgramRootPath()
Get the program root path.
bool HasUnsavedChanges()
Checks if the currently open flow has unsaved changes.
void SaveFlow(GlobalActions &globalAction)
Saves the current flow into a file.
void SetOutputPath()
Set the path where logs and outputs are stored.