0.2.0
Loading...
Searching...
No Matches
DynamicInputPins.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
13
14#pragma once
15
16#include <vector>
17#include <string>
18#include <functional>
19
21#include "internal/Node/Pin.hpp"
22
23#include "util/Json.hpp"
24
25namespace NAV::gui::widgets
26{
29{
32 {
34 std::string header;
36 std::function<bool(size_t)> content;
37 };
38
45 DynamicInputPins(size_t firstDynamicPinIndex,
46 Node* node,
47 std::function<void(Node*)> pinAddCallback,
48 std::function<void(Node*, size_t)> pinDeleteCallback,
49 size_t defaultInputPins = 0);
50
57 bool ShowGuiWidgets(size_t id, std::vector<InputPin>& inputPins, Node* node, const std::vector<ExtraColumn>& extraColumns = {});
58
60 [[nodiscard]] size_t getNumberOfDynamicPins() const;
61
64 void addPin(Node* node);
65
66 private:
68 int _dragAndDropPinIndex = -1;
70 const size_t FIRST_DYNAMIC_PIN = 0;
72 size_t _nDynamicInputPins = 0;
74 std::function<void(Node*)> _pinAddCallback;
76 std::function<void(Node*, size_t)> _pinDeleteCallback;
77
78 friend void to_json(json& j, const DynamicInputPins& obj);
79 friend void from_json(const json& j, DynamicInputPins& obj, Node* node);
80};
81
85void to_json(json& j, const DynamicInputPins& obj);
90void from_json(const json& j, DynamicInputPins& obj, Node* node);
91
92} // namespace NAV::gui::widgets
void from_json(const json &j, DynamicInputPins &obj, Node *node)
Converts the provided json object into a node object.
void to_json(json &j, const DynamicInputPins &obj)
Converts the provided object into json.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
Defines how to save certain datatypes to json.
Node Class.
Pin class.
Abstract parent class for all nodes.
Definition Node.hpp:86
Information to create extra columns.
Definition DynamicInputPins.hpp:32
std::string header
Column header text.
Definition DynamicInputPins.hpp:34
std::function< bool(size_t)> content
Function to create the column content. Argument is the pin index. Returns true if changes occurred.
Definition DynamicInputPins.hpp:36
Inputs pins which can be added dynamically.
Definition DynamicInputPins.hpp:29
size_t getNumberOfDynamicPins() const
Get the number Of dynamic pins.
friend void from_json(const json &j, DynamicInputPins &obj, Node *node)
Converts the provided json object into a node object.
bool ShowGuiWidgets(size_t id, std::vector< InputPin > &inputPins, Node *node, const std::vector< ExtraColumn > &extraColumns={})
Shows the GUI input to select the options.
friend void to_json(json &j, const DynamicInputPins &obj)
Converts the provided object into json.
DynamicInputPins(size_t firstDynamicPinIndex, Node *node, std::function< void(Node *)> pinAddCallback, std::function< void(Node *, size_t)> pinDeleteCallback, size_t defaultInputPins=0)
Constructor.
void addPin(Node *node)
Adds a pin and call the pinAddCallback.