90 lines
2.6 KiB
C++
90 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include "state.h"
|
|
#include "vmath.h"
|
|
#include "raylib.h"
|
|
|
|
#include "nlohmann/json.hpp"
|
|
|
|
#include "midi-node.h"
|
|
#include "edge.h"
|
|
#include "node.h"
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
using json = nlohmann::json;
|
|
|
|
using namespace VISEQ::GRAPH::NODES;
|
|
using namespace VISEQ::GRAPH::EDGES;
|
|
|
|
namespace VISEQ::GRAPH {
|
|
|
|
class GraphManager : public std::enable_shared_from_this<GraphManager>{
|
|
private:
|
|
NODES::VEC_SPTR_Node nodes;
|
|
EDGES::VEC_SPTR_Edge edges;
|
|
|
|
EDGES::VEC_WPTR_Edge remove_edges;
|
|
EDGES::VEC_WPTR_Edge split_edges;
|
|
|
|
VEC_SPTR_Node selected_nodes;
|
|
|
|
std::map<NODES::SPTR_Node, int> counter;
|
|
|
|
std::shared_ptr<APP::State> state = APP::State::get();
|
|
|
|
public:
|
|
|
|
GraphManager() {}
|
|
|
|
std::shared_ptr<GraphManager> getPtr();
|
|
int getNodesSize();
|
|
void createMidiNode(Vec2Df position);
|
|
void createConfigNode(Vec2Df position);
|
|
void setMidiPortForAll(int number, bool _state);
|
|
void addNode(SPTR_Node node);
|
|
void addConnection(WPTR_Node from, WPTR_Node to);
|
|
void addToSelection();
|
|
void select();
|
|
void deselect();
|
|
VEC_SPTR_Node getSelection();
|
|
void copyNodes(VEC_SPTR_Node _nodes, Vec2Df position);
|
|
void copyNodes(std::vector<std::shared_ptr<MidiNode>> _nodes, Vec2Df position);
|
|
VEC_SPTR_Node getCopiesOfSelectedNodes();
|
|
SPTR_Node copyNode(SPTR_Node n, Vec2Df position);
|
|
SPTR_Node copyNode(std::shared_ptr<MidiNode> n, Vec2Df position);
|
|
void setNodeMode(int mode);
|
|
void cycleModeOfSelectedNodes(bool direction);
|
|
void reset();
|
|
WPTR_Node getNode(int i);
|
|
WPTR_Node getFirstNode();
|
|
WPTR_Node getLastNode();
|
|
VEC_WPTR_Node getMidiNodes();
|
|
NODES::SPTR_Node getRandomNode();
|
|
EDGES::SPTR_Edge getRandomEdge();
|
|
SPTR_Node getClosestNode(Vec2Df position);
|
|
VEC_WPTR_Node getNodesByID(int _id);
|
|
WPTR_Edge lastEdge();
|
|
WPTR_Node next(WPTR_Node current, WPTR_Node last);
|
|
void splitEdge(SPTR_Edge edge);
|
|
void splitEdges();
|
|
void removeEdge(SPTR_Edge edge);
|
|
void removeEdges();
|
|
VEC_WPTR_Node getAdjacentNodes(VEC_SPTR_Node selected_nodes);
|
|
void removeNodesAndEdges(VEC_SPTR_Node selected_nodes);
|
|
void pasteNodesAndEdges(VEC_SPTR_Node nodes, Vec2Df position);
|
|
void update();
|
|
void drawEdges(Vec2Df mouse_pos, Camera2D cam);
|
|
void drawNeighborLines(SPTR_Node node, Vec2Df mouse_pos, Camera2D camera);
|
|
void drawNodes(Vec2Df mouse_pos, Camera2D camera);
|
|
|
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(GraphManager, nodes, edges, selected_nodes)
|
|
|
|
friend void from_json(const json& j, std::shared_ptr<GraphManager>& G);
|
|
friend void to_json(json& j, const std::shared_ptr<GraphManager>& G);
|
|
};
|
|
|
|
}
|