Files
viseq/src/node.h
T

68 lines
1.8 KiB
C++
Raw Normal View History

2024-10-09 02:01:23 +02:00
#pragma once
#include <memory>
#include <raylib.h>
2024-10-09 02:01:23 +02:00
#include "connector.h"
2024-10-09 02:01:23 +02:00
#include "datatypes.h"
#include "draggable.h"
2024-10-30 14:55:24 +01:00
#include "graph-item.h"
#include "vmath.h"
2024-10-20 01:17:18 +02:00
2024-11-03 03:48:49 +01:00
namespace VISEQ::GRAPH::EDGES{
class Edge;
}
2024-10-09 02:01:23 +02:00
2024-11-03 03:48:49 +01:00
namespace VISEQ::GRAPH::NODES {
class Node : public BASE::Draggable, public GraphItem, public std::enable_shared_from_this<Node> {
2024-11-03 03:48:49 +01:00
public:
2026-01-12 00:16:36 +01:00
Node() {}
Node(float x, float y) : Draggable(Vec2Df(x, y)) {}
Node(Vec2Df p) : Draggable(p) {}
2024-11-03 03:48:49 +01:00
NodeType nodeType;
2024-11-06 02:28:37 +01:00
std::vector<std::shared_ptr<Node>> neighbors;
2024-11-03 03:48:49 +01:00
std::vector<std::shared_ptr<VISEQ::GRAPH::EDGES::Edge>> connections;
std::vector<std::shared_ptr<Connector>> connectors;
2024-11-03 03:48:49 +01:00
Distribution distributionMode = Distribution::GEOMETRIC;
2024-11-03 03:48:49 +01:00
float radius = 15.0f;
2024-12-10 00:00:53 +01:00
float node_radius = 15.0f;
float hover_radius = 32.0f;
2024-11-03 03:48:49 +01:00
bool config = false;
bool triggered = false;
int mode = 0;
virtual void trigger() {}
2026-01-06 02:44:18 +01:00
virtual void setMode(int _mode);
std::shared_ptr<Node> getPtr();
virtual bool hovering() override;
void addConnector();
void removeConnector(std::weak_ptr<Connector> connector);
virtual NodeType getNodeType() const;
void deselect() override;
GraphItemType getType() override;
void clearConnectors();
void update() override;
void draw(Vec2Df mp, Camera2D cam) override;
void draw() override;
2024-11-12 01:42:05 +01:00
2026-01-12 00:16:36 +01:00
friend void to_json(json& j, const Node& N);
friend void from_json(const json& j, Node& N);
friend void to_json(json& j, const std::shared_ptr<Node>& N);
friend void from_json(const json& j, std::shared_ptr<Node>& N);
2024-11-03 03:48:49 +01:00
};
2024-11-03 03:48:49 +01:00
typedef std::shared_ptr<VISEQ::GRAPH::NODES::Node> SPTR_Node;
2024-12-03 01:25:49 +01:00
typedef std::weak_ptr<VISEQ::GRAPH::NODES::Node> WPTR_Node;
2024-11-03 03:48:49 +01:00
typedef std::vector<SPTR_Node> VEC_SPTR_Node;
2024-12-03 01:25:49 +01:00
typedef std::vector<WPTR_Node> VEC_WPTR_Node;
2024-11-03 03:48:49 +01:00
}