-
Notifications
You must be signed in to change notification settings - Fork 1
/
Nodes.h
106 lines (69 loc) · 1.79 KB
/
Nodes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#include "cinder/app/App.h"
#include "cinder/gl/gl.h"
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/visitors.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include "boost/signals2/signal.hpp"
using namespace boost;
struct PointNode
{
PointNode(const ci::Vec2f &position, const std::string &nodeName, ci::Color col = ci::Color::white()) {
pos = position;
color = col;
name = nodeName;
}
ci::Vec2f pos;
ci::Color color;
std::string name;
};
class n_Vertex
{
public:
PointNode *pNode;
int id;
};
class n_Edge
{
public:
};
class n_Graph
{
public:
};
typedef adjacency_list <vecS, vecS, directedS, n_Vertex, n_Edge, n_Graph > nodeGraph;
typedef graph_traits<nodeGraph>::vertex_descriptor nodeVertex;
typedef adjacency_list<>::vertex_iterator nodeIterator;
class Nodes
{
public:
Nodes();
void init();
void draw();
void generateNew(int number);
void addNode(const ci::Vec2f &position, std::string nodeName);
void addEdge(const int& input, const int& output);
void removeNode() {}
void removeEdge() {}
void printInfos();
private:
nodeGraph mNodeGraph;
std::vector<PointNode*> mNodes;
std::vector<nodeVertex> mVertices;
boost::signals2::scoped_connection mMouseBeganCallBack,
mMouseDragCallBack,
mMouseEndCallBack,
mMouseMovedCallBack;
void onMouseDown(ci::app::MouseEvent event);
void onMouseDragged(ci::app::MouseEvent event);
void onMouseUp(ci::app::MouseEvent event);
void onMouseMoved(ci::app::MouseEvent event);
void doubleClick(ci::app::MouseEvent event);
bool bDraggingConnection, bDraggingNode, bHitNode;
std::pair<ci::Vec2f, ci::Vec2f> draggingPos;
int selectedNode;
std::pair<int, int> connectNodes;
ci::Vec2i translateOffset;
double tDoubleClick;
int nodeCount;
};