22#include <imgui_node_editor.h> 
   31    bool dataTypesMatch = 
true;
 
   36        dataTypesMatch = 
false;
 
   43        dataTypesMatch = 
false;
 
   49        dataTypesMatch = 
false;
 
   52    return startPin.
id != endPin.
id                     
 
   61    return !a.empty() && !b.empty()
 
   62           && std::ranges::find_if(a, [&b](
const std::string& 
str) { 
return std::ranges::find(b, 
str) != b.end(); }) != a.end();
 
 
   72        if (ax::NodeEditor::GetStyle().Colors[ax::NodeEditor::StyleColor_NodeBg].x
 
   73                + ax::NodeEditor::GetStyle().Colors[ax::NodeEditor::StyleColor_NodeBg].y
 
   74                + ax::NodeEditor::GetStyle().Colors[ax::NodeEditor::StyleColor_NodeBg].z
 
   79        return { 255, 255, 255 };
 
   81        return { 220, 48, 48 };
 
   83        return { 68, 201, 156 };
 
   85        return { 147, 226, 74 };
 
   87        return { 124, 21, 153 };
 
   89        return { 51, 150, 215 };
 
   91        return { 255, 165, 0 };
 
   93        return { 255, 48, 48 };
 
 
  102    PinIcon::Type iconType = PinIcon::Type::Flow;
 
  104    color.Value.w = 
static_cast<float>(alpha) / 255.0F;
 
  108        iconType = PinIcon::Type::Grid;
 
  111        iconType = PinIcon::Type::Flow;
 
  120        iconType = PinIcon::Type::Circle;
 
  123        iconType = PinIcon::Type::RoundSquare;
 
  129        iconType = PinIcon::Type::Diamond;
 
  132        iconType = PinIcon::Type::Square;
 
  140                                iconType, connected, color, ImColor(32, 32, 32, alpha));
 
 
  154        LOG_ERROR(
"The new Link between node '{}' and '{}' was refused by its start node.",
 
  160        LOG_ERROR(
"The new Link between node '{}' and '{}' was refused by its end node.",
 
  165    LOG_DEBUG(
"Creating link from pin {} of [{}] ==> {} of [{}]",
 
  169    startPin.
connect(endPin, linkId);
 
  170    endPin.
connect(startPin, linkId);
 
 
  212        LOG_ERROR(
"Cannot delete the link, because the nodes '{}' and '{}' are not linked over pins '{}' => '{}'.",
 
  214                  size_t(startPin.
id), 
size_t(endPin.
id));
 
  218    LOG_DEBUG(
"Deleting link {} from pin {} of [{}] ==> pin {} of [{}]", 
size_t(endPin.
link.
linkId),
 
 
  246    return !
links.empty();
 
 
  254    return iter != 
links.cend();
 
 
  274    while (!
links.empty())
 
  276        if (
auto* endPin = 
links.back().getConnectedPin())
 
 
  292    if (iter == 
links.end()) 
 
 
  324    if (iter != 
links.end())
 
 
  357    return link.linkId && 
link.connectedNode && 
link.connectedPinId;
 
 
  372    if (
auto* startPin = 
link.getConnectedPin())
 
 
  383        link.connectedPinId = startPin.
id;
 
  386            return link.connectedNode == parentNode && link.connectedPinId == id;
 
  392            link.linkId = linkId;
 
  393            if (iter != startPin.
links.end() && iter->linkId != linkId)
 
  396                startPin.
connect(*
this, linkId);
 
  399        else if (iter != startPin.
links.end())
 
  402            link.linkId = iter->linkId;
 
 
  416    if (
link.connectedNode || 
link.connectedPinId || 
link.linkId)
 
  418        auto* startPin = 
link.getConnectedPin();
 
  421        link.connectedNode = 
nullptr;
 
  422        link.connectedPinId = 0;
 
  427                return link.connectedNode == parentNode && link.connectedPinId == id;
 
  430            if (iter != startPin->links.end())
 
  432                startPin->disconnect(*
this);
 
 
  455        { 
"id", size_t(pin.
id) },
 
  456        { 
"name", pin.
name },
 
 
  461    pin.
id = j.at(
"id").get<
size_t>();
 
  462    if (j.contains(
"name")) { j.at(
"name").get_to(pin.
name); }
 
 
  468        { 
"id", size_t(pin.
id) },
 
  469        { 
"name", pin.
name },
 
 
  474    pin.
id = j.at(
"id").get<
size_t>();
 
  475    if (j.contains(
"name")) { j.at(
"name").get_to(pin.
name); }
 
 
nlohmann::json json
json namespace
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_ERROR
Error occurred, which stops part of the program to work, but not everything.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Utility class which specifies available nodes.
bool isInitialized() const
Checks if the node is initialized.
bool doDeinitialize(bool wait=false)
Asks the node worker to deinitialize the node.
std::string nameId() const
Node name and id.
virtual void afterCreateLink(OutputPin &startPin, InputPin &endPin)
Called when a new link was established.
virtual void onDeleteLink(OutputPin &startPin, InputPin &endPin)
Called when a link is to be deleted.
virtual void afterDeleteLink(OutputPin &startPin, InputPin &endPin)
Called when a link was deleted.
virtual bool onCreateLink(OutputPin &startPin, InputPin &endPin)
Called when a new link is to be established.
virtual std::string type() const =0
String representation of the Class Type.
bool recreateLink(InputPin &endPin)
Destroys and recreates a link from this pin to another.
bool createLink(InputPin &endPin, ax::NodeEditor::LinkId linkId=0)
Creates a link from this pin to another, calling all node specific callbacks.
void deleteLink(InputPin &endPin)
Disconnects the link.
void deleteLinks()
Disconnects all links.
void connect(InputPin &endPin, ax::NodeEditor::LinkId linkId=0)
Connects this pin to another.
void disconnect(InputPin &endPin)
Disconnects the link.
bool isPinLinked() const
Checks if the pin is linked.
std::vector< OutgoingLink > links
Info to identify the linked pins.
bool canCreateLink(const InputPin &other) const
Checks if this pin can connect to the provided pin.
Node * parentNode
Reference to the parent node.
static void deleteLink(OutputPin &startPin, InputPin &endPin)
Disconnects the link.
static bool recreateLink(OutputPin &startPin, InputPin &endPin)
Destroys and recreates a link from this pin to another.
std::string name
Name of the Pin.
static constexpr int m_PinIconSize
Size of the Pin Icons in [px].
void drawPinIcon(bool connected, int alpha) const
Draw the Pin Icon.
ax::NodeEditor::PinId id
Unique Id of the Pin.
std::vector< std::string > dataIdentifier
One or multiple Data Identifiers (Unique name which is used for data flows)
Type type
Type of the Pin.
static bool dataIdentifierHaveCommon(const std::vector< std::string > &a, const std::vector< std::string > &b)
Checks if the first list of data identifiers has a common entry with the second.
static bool createLink(OutputPin &startPin, InputPin &endPin, ax::NodeEditor::LinkId linkId=0)
Create a Link between the two given pins.
Kind kind
Kind of the Pin (Input/Output)
ImColor getIconColor() const
Get the Icon Color object.
static bool canCreateLink(const OutputPin &startPin, const InputPin &endPin)
Checks if pins can connect.
static float defaultFontRatio()
Ratio to multiply for default GUI elements.
ax::NodeEditor::LinkId GetNextLinkId()
Generates a new link id.
void AddLink(ax::NodeEditor::LinkId linkId)
Adds the link.
bool NodeDataTypeAnyIsChildOf(const std::vector< std::string > &childTypes, const std::vector< std::string > &parentTypes)
Checks if any of the provided child types is a child of any of the provided parent types.
void ApplyChanges()
Signals that there have been changes to the flow.
void to_json(json &j, const Node &node)
Converts the provided node into a json object.
void from_json(const json &j, Node &node)
Converts the provided json object into a node object.
Collection of information about the connected node and pin.
InputPin * getConnectedPin() const
Returns a pointer to the pin which is connected to this one.
ax::NodeEditor::LinkId linkId
Unique id of the link.
Node * connectedNode
Pointer to the node, which is connected to this pin.
ax::NodeEditor::PinId connectedPinId
Id of the pin, which is connected to this pin.
Value
Type of the data on the Pin.
@ Delegate
Reference to the Node object.
@ Float
Floating Point Number.