Files
viseq/src/node.h
T

65 lines
1.4 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{
2024-11-03 03:48:49 +01:00
public:
Node() {}
Node(float x, float y) : Draggable(Vec2Df(x, y)) {}
Node(Vec2Df p) : Draggable(p) {}
2024-10-27 00:40:57 +02:00
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;
bool config = false;
2024-11-03 03:48:49 +01:00
virtual NodeType getNodeType() const {return nodeType;}
2024-11-03 03:48:49 +01:00
virtual void SMode(int mode) {};
virtual int GGate() {return 0;};
virtual int GActive() {return 0;};
virtual void trigger() {};
virtual bool hovering() override {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
return CheckCollisionPointCircle(mp, position, radius);
}
void update() override{
if(pickedUp()) drag();
if(released()) putDown();
for(auto c : connectors){
c->update(position);
}
}
2024-11-03 03:48:49 +01:00
void draw(Vec2Df mouse_pos, Camera2D cam) override {}
};
2024-11-03 03:48:49 +01:00
typedef std::shared_ptr<VISEQ::GRAPH::NODES::Node> SPTR_Node;
typedef std::vector<SPTR_Node> VEC_SPTR_Node;
2024-11-03 03:48:49 +01:00
}