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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
#include <Eina.h>
#include <Evas.h>
#include <Ecore.h>
#include <igraph/igraph.h>
#define EGRAPH_VERTICES_MAX 16384 /* cannot be more that u_int32_t */
#define EGRAPH_VERTICE_NAME_MAXLEN 60
typedef struct Egraph Egraph;
typedef struct Egraph_Edge Egraph_Edge;
typedef struct Egraph_Vertice Egraph_Vertice;
typedef enum {
EGRAPH_LAYOUT_GRAPHOPT = 0,
EGRAPH_LAYOUT_KAMADAKAWAI = 1,
EGRAPH_LAYOUT_FRUCHTERMANREINGOLD = 2,
} Egraph_Layout;
#define EGRAPH_LAYOUT_DEFAULT EGRAPH_LAYOUT_GRAPHOPT
#define EGRAPH_LAYOUTING_IMPROVEMENTS 5
struct Egraph {
Evas_Object_Smart_Clipped_Data __clipped_data;
Evas_Object *obj;
Evas_Object *split_vertice_edge;
Evas *evas;
int graph_directed;
int display_vertices;
int display_names;
int display_edges;
int use_animations;
int do_improvements;
char *theme_path;
int theme_edges;
Egraph_Layout layout;
struct {
Ecore_Thread *thread;
int running;
int todo;
int changes_diff;
int improvement; /* special pass to improve the graph layout */
} layouting;
Eina_Hash *vertices;
int vertices_count;
u_int32_t vertices_freeids[EGRAPH_VERTICES_MAX];
int vertice_max_w;
int vertice_max_h;
Eina_List *edges;
igraph_t graph;
int graph_vcount;
igraph_matrix_t coords;
igraph_t graph2; // XXX remove use of graph here, see _repos()
int graph2_vcount;
igraph_vector_t graph2_wmin, graph2_wmax, graph2_hmin, graph2_hmax;
int graph_wmin, graph_wmax, graph_hmin, graph_hmax;
igraph_matrix_t coords2;
};
struct Egraph_Vertice {
u_int32_t id;
char *name;
char *type;
u_int status : 1;
Evas_Object *o;
Eina_List *edges;
Eina_List *blobs_incoming;
void *data;
u_int is_group : 1;
Eina_List *group_vertices; /* used if the vertice is a group */
u_int new : 1;
u_int v2_new : 1;
u_int v2_del : 1;
u_int v3_new : 1;
u_int v3_del : 1;
};
struct Egraph_Edge {
Egraph_Vertice *a;
Egraph_Vertice *b;
char *type;
Evas_Object *o;
u_int o_usetheme : 1;
void *data;
u_int new : 1;
u_int v2_new : 1;
u_int v2_del : 1;
u_int v3_new : 1;
u_int v3_del : 1;
};
/**
* Creates Egraph Evas_Object
*/
Evas_Object *egraph_new(Evas *evas, int directed);
/**
* Remove all nodes and edges
*/
void egraph_clear(Evas_Object *obj);
/**
* Configure egraph to use an edje theme
*/
void egraph_theme_file_set(Evas_Object *obj, char *path);
/**
* Sets if egraph should theme the edges
*/
void egraph_theme_edges_set(Evas_Object *obj, int set);
/**
* Sets the layout of Egraph
*/
void egraph_layout_set(Evas_Object *obj, Egraph_Layout layout);
/**
* Configure if Egraph should display vertices
*/
void egraph_display_vertices_set(Evas_Object *obj, int set);
/**
* Configure if Egraph should display vertices names
*/
void egraph_display_names_set(Evas_Object *obj, int set);
/**
* Configure if Egraph should display edges
*/
void egraph_display_edges_set(Evas_Object *obj, int set);
/**
* Configure if Egraph should use animations
*/
void egraph_use_animations_set(Evas_Object *obj, int set);
/**
* Configure if Egraph should do improvements after a graph change
*/
void egraph_do_improvements_set(Evas_Object *obj, int set);
/**
* Adds an edge between existing vertices
*
* @param obj The Egraph object
* @param a First vertice
* @param b Second vertice
* @param data The pointer to attach
* @return The new Egraph_Egde object
*/
Egraph_Edge *egraph_edge_add(Evas_Object *obj,
Egraph_Vertice *a, Egraph_Vertice *b, void *data);
/**
* Delete an edge
*
* Hint: This does not delete vertices
*/
void egraph_edge_del(Evas_Object *obj, Egraph_Edge *e);
/**
* Sets the type of an edge, to make it appear differently in the graph,
* depending on theme
*/
void egraph_edge_type_set(Evas_Object *obj,
Egraph_Edge *e, const char *type);
/**
* Finds if an edge exists between 2 vertices
*/
Egraph_Edge *egraph_edge_find(Evas_Object *obj,
Egraph_Vertice *a, Egraph_Vertice *b);
/**
* Add a vertice to the graph
*
* @param obj The Egraph object
* @param name The name of the vertice to be displayed. If NULL, no name is
* displayed
* @param data The pointer to attach
*/
Egraph_Vertice *egraph_vertice_add(Evas_Object *obj,
const char *name, void *data);
/**
* Delete a vertice
*
* Hint: Also deletes all the edges attached to it
*
* @param obj The Egraph object
* @todo add user callback where edges are deleted
*/
void egraph_vertice_del(Evas_Object *obj, Egraph_Vertice *v);
/**
* Update the name of a vertice
*/
void egraph_vertice_rename(Evas_Object *obj, Egraph_Vertice *v,
const char *name);
/**
* Sets the type of a vertice, to make it appear differently in the graph,
* depending on theme
*/
void
egraph_vertice_type_set(Evas_Object *obj, Egraph_Vertice *v, const char *type);
/**
* Send a blob from vertice to vertice
*
* A blob is a visual object that will move quickly from the first node to the
* second node.
*/
void egraph_vertice_send_blob(Evas_Object *obj,
Egraph_Vertice *a, Egraph_Vertice *b,
int size, u_int32_t color);
/**
* Add a group of vertices, for later attaching nodes to it.
*
* The group is represented by an Egraph_Vertice with special properties.
*/
Egraph_Vertice *egraph_group_add(Evas_Object *obj,
const char *name, void *data);
/**
* Attach a vertice to a group
*/
int egraph_group_vertice_attach(Evas_Object *obj,
Egraph_Vertice *group, Egraph_Vertice *v);
/**
* Detach a vertice from a group
*/
void egraph_group_vertice_detach(Evas_Object *obj,
Egraph_Vertice *group, Egraph_Vertice *v);
|