| 1 |
/************************************************************************* |
| 2 |
* Copyright (c) 2011 AT&T Intellectual Property |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* https://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: Details at https://graphviz.org |
| 9 |
*************************************************************************/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#ifdef _WIN32 |
| 14 |
#include "windows.h" |
| 15 |
#endif |
| 16 |
|
| 17 |
#include <stdbool.h> |
| 18 |
#include <stddef.h> |
| 19 |
#include <xdot/xdot.h> |
| 20 |
#include <gtk/gtk.h> |
| 21 |
#include <glcomp/opengl.h> |
| 22 |
#include <gtk/gtkgl.h> |
| 23 |
#include <cgraph/cgraph.h> |
| 24 |
#include <glcomp/glcompset.h> |
| 25 |
#include "hier.h" |
| 26 |
#include <glcomp/glutils.h> |
| 27 |
#include <util/list.h> |
| 28 |
|
| 29 |
#ifdef _MSC_VER // this is needed on MSVC to get libglade see the callback |
| 30 |
#define _BB __declspec(dllexport) |
| 31 |
#else |
| 32 |
#define _BB |
| 33 |
#endif |
| 34 |
|
| 35 |
typedef struct _ArcBall_t ArcBall_t; |
| 36 |
|
| 37 |
#define GL_VIEWPORT_FACTOR 100 |
| 38 |
//mouse modes |
| 39 |
#define MM_PAN 0 |
| 40 |
#define MM_ZOOM 1 |
| 41 |
#define MM_ROTATE 2 |
| 42 |
#define MM_SINGLE_SELECT 3 |
| 43 |
#define MM_RECTANGULAR_SELECT 4 |
| 44 |
#define MM_RECTANGULAR_X_SELECT 5 |
| 45 |
#define MM_MOVE 10 |
| 46 |
#define MM_MAGNIFIER 20 |
| 47 |
#define MM_FISHEYE_MAGNIFIER 21 |
| 48 |
#define MM_FISHEYE_PICK 22 /*fisheye select foci point*/ |
| 49 |
#define MM_POLYGON_SELECT 30 |
| 50 |
|
| 51 |
#define MAX_ZOOM 500.0f |
| 52 |
#define MIN_ZOOM 0.005f |
| 53 |
|
| 54 |
#define DEG2RAD G_PI/180 |
| 55 |
|
| 56 |
#define MAX_FILTERED_ATTR_COUNT 50 |
| 57 |
|
| 58 |
typedef enum {attr_alpha,attr_float,attr_int,attr_bool} attr_data_type; |
| 59 |
typedef enum {smyrna_all,smyrna_2D,smyrna_3D,smyrna_fisheye,smyrna_all_but_fisheye} smyrna_view_mode; |
| 60 |
|
| 61 |
typedef struct { |
| 62 |
char* name; |
| 63 |
char* value; |
| 64 |
char* defValG; |
| 65 |
char* defValN; |
| 66 |
char* defValE; |
| 67 |
attr_data_type type; |
| 68 |
int objType[3]; |
| 69 |
int propagate; |
| 70 |
}attr_t; |
| 71 |
|
| 72 |
typedef LIST(attr_t *) attrs_t; |
| 73 |
|
| 74 |
typedef struct |
| 75 |
{ |
| 76 |
attrs_t attributes; |
| 77 |
void *fLabels[MAX_FILTERED_ATTR_COUNT]; |
| 78 |
}attr_list; |
| 79 |
|
| 80 |
typedef struct |
| 81 |
{ |
| 82 |
xdot_op op; |
| 83 |
void *obj; |
| 84 |
glCompFont font; |
| 85 |
int layer; |
| 86 |
glCompImage* img; |
| 87 |
} sdot_op; |
| 88 |
|
| 89 |
typedef struct { |
| 90 |
float perc; |
| 91 |
glCompColor c; |
| 92 |
|
| 93 |
} colorschema; |
| 94 |
|
| 95 |
enum {SCHEMACOUNT = 4}; // number of colors |
| 96 |
|
| 97 |
typedef struct { |
| 98 |
colorschema s[SCHEMACOUNT]; |
| 99 |
} colorschemaset; |
| 100 |
|
| 101 |
typedef enum { |
| 102 |
GVK_DOT, |
| 103 |
GVK_NEATO, |
| 104 |
GVK_TWOPI, |
| 105 |
GVK_CIRCO, |
| 106 |
GVK_FDP, |
| 107 |
} gvk_layout; |
| 108 |
|
| 109 |
typedef struct |
| 110 |
{ |
| 111 |
unsigned node_id; |
| 112 |
unsigned edge_id; |
| 113 |
unsigned selnode_id; |
| 114 |
unsigned seledge_id; |
| 115 |
unsigned nodelabel_id; |
| 116 |
unsigned edgelabel_id; |
| 117 |
}topviewcache; |
| 118 |
|
| 119 |
typedef struct |
| 120 |
{ |
| 121 |
int index; |
| 122 |
int action; |
| 123 |
int hotkey; |
| 124 |
glMouseButtonType type; |
| 125 |
int drag; |
| 126 |
smyrna_view_mode mode; |
| 127 |
}mouse_action_t; |
| 128 |
|
| 129 |
typedef struct { |
| 130 |
double targetx; |
| 131 |
double targety; |
| 132 |
|
| 133 |
double r; |
| 134 |
} viewport_camera; |
| 135 |
|
| 136 |
typedef struct { |
| 137 |
Agrec_t h; |
| 138 |
char *GraphFileName; |
| 139 |
} graph_data; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
typedef struct{ |
| 144 |
Agrec_t h; |
| 145 |
glCompPoint A; |
| 146 |
double size; |
| 147 |
int selected; |
| 148 |
int visible; |
| 149 |
int printLabel; |
| 150 |
int TVref; |
| 151 |
}nodeRec; |
| 152 |
#define NREC(n) ((nodeRec*)(aggetrec(n,"nodeRec",0))) |
| 153 |
#define ND_visible(n) (NREC(n)->visible) |
| 154 |
#define ND_selected(n) (NREC(n)->selected) |
| 155 |
#define ND_printLabel(n) (NREC(n)->printLabel) |
| 156 |
#define ND_A(n) (NREC(n)->A) |
| 157 |
#define ND_size(n) (NREC(n)->size) |
| 158 |
#define ND_TVref(n) (NREC(n)->TVref) |
| 159 |
|
| 160 |
typedef struct{ |
| 161 |
Agrec_t h; |
| 162 |
glCompPoint posTail; |
| 163 |
glCompPoint posHead; |
| 164 |
int selected; |
| 165 |
}edgeRec; |
| 166 |
#define EREC(e) ((edgeRec*)(aggetrec(e,"edgeRec",0))) |
| 167 |
#define ED_selected(e) (EREC(e)->selected) |
| 168 |
#define ED_posTail(e) (EREC(e)->posTail) |
| 169 |
#define ED_posHead(e) (EREC(e)->posHead) |
| 170 |
|
| 171 |
typedef struct{ |
| 172 |
Agrec_t h; |
| 173 |
Agsym_t* N_pos; |
| 174 |
Agsym_t* N_size; |
| 175 |
Agsym_t* N_visible; |
| 176 |
Agsym_t* N_selected; |
| 177 |
Agsym_t* G_nodelabelcolor; |
| 178 |
Agsym_t* GN_labelattribute; |
| 179 |
Agsym_t* N_labelattribute; |
| 180 |
Agsym_t* E_visible; |
| 181 |
Agsym_t* E_selected; |
| 182 |
Agsym_t* E_pos; |
| 183 |
Agsym_t* G_edgelabelcolor; |
| 184 |
Agsym_t* E_labelattribute; |
| 185 |
Agsym_t* GE_labelattribute; |
| 186 |
} graphRec; |
| 187 |
#define GREC(g) ((graphRec*)(AGDATA(g))) |
| 188 |
#define GN_pos(g) (GREC(g)->N_pos) |
| 189 |
#define GN_size(g) (GREC(g)->N_size) |
| 190 |
#define GN_visible(g) (GREC(g)->N_visible) |
| 191 |
#define GN_selected(g) (GREC(g)->N_selected) |
| 192 |
#define GG_nodelabelcolor(g) (GREC(g)->G_nodelabelcolor) |
| 193 |
#define GN_labelattribute(g) (GREC(g)->N_labelattribute) |
| 194 |
#define GG_labelattribute(g) (GREC(g)->GN_labelattribute) |
| 195 |
#define GE_pos(g) (GREC(g)->E_pos) |
| 196 |
#define GE_visible(g) (GREC(g)->E_visible) |
| 197 |
#define GE_selected(g) (GREC(g)->E_selected) |
| 198 |
#define GG_edgelabelcolor(g) (GREC(g)->G_edgelabelcolor) |
| 199 |
#define GE_labelattribute(g) (GREC(g)->E_labelattribute) |
| 200 |
#define GG_elabelattribute(g) (GREC(g)->GE_labelattribute) |
| 201 |
|
| 202 |
#define GUI_WINDOWED 0 |
| 203 |
#define GUI_FULLSCREEN 1 |
| 204 |
|
| 205 |
typedef struct _selection { |
| 206 |
glCompPoly_t selPoly; |
| 207 |
bool selectNodes; |
| 208 |
bool selectEdges; |
| 209 |
} selection; |
| 210 |
|
| 211 |
typedef struct { |
| 212 |
size_t Nodecount; |
| 213 |
struct { |
| 214 |
int active; //1 draw hierarchy 0 draw regular topview |
| 215 |
reposition_t repos; |
| 216 |
levelparms_t level; |
| 217 |
/// if dist2_limit true, don’t contract nodes of distance larger than 2 |
| 218 |
/// if false then also distance 3 is possible |
| 219 |
bool dist2_limit; |
| 220 |
Hierarchy *h; |
| 221 |
int animate; |
| 222 |
glCompColor srcColor; //fine node colors of topfisheye |
| 223 |
glCompColor tarColor; //supernode colors of fisheye |
| 224 |
focus_t *fs; |
| 225 |
} fisheyeParams; |
| 226 |
|
| 227 |
graph_data Graphdata; |
| 228 |
float maxedgelen; |
| 229 |
double fitin_zoom; |
| 230 |
xdot* xDot; |
| 231 |
double global_z; |
| 232 |
attr_list* attributes;/*attribute list*/ |
| 233 |
|
| 234 |
topviewcache cache; |
| 235 |
selection sel; |
| 236 |
|
| 237 |
} topview; |
| 238 |
|
| 239 |
typedef struct{ |
| 240 |
Agraph_t *def_attrs; |
| 241 |
Agraph_t *attrs_widgets; |
| 242 |
}systemgraphs; |
| 243 |
|
| 244 |
|
| 245 |
typedef struct _ViewInfo { |
| 246 |
systemgraphs systemGraphs; |
| 247 |
/*view variables */ |
| 248 |
double panx; |
| 249 |
double pany; |
| 250 |
double zoom; |
| 251 |
|
| 252 |
/*clipping coordinates, to avoid unnecesarry rendering */ |
| 253 |
float clipX1, clipX2, clipY1, clipY2; |
| 254 |
|
| 255 |
/*background color */ |
| 256 |
glCompColor bgColor; |
| 257 |
/*default pen color */ |
| 258 |
glCompColor penColor; |
| 259 |
/*default fill color */ |
| 260 |
glCompColor fillColor; |
| 261 |
/*grid color */ |
| 262 |
glCompColor gridColor; //grid color |
| 263 |
/*border color */ |
| 264 |
glCompColor borderColor; |
| 265 |
/*selected node color */ |
| 266 |
glCompColor selectedNodeColor; |
| 267 |
/*default node alpha */ |
| 268 |
double defaultnodealpha; |
| 269 |
|
| 270 |
/*default line width */ |
| 271 |
float LineWidth; |
| 272 |
|
| 273 |
/*grid is drawn if this variable is 1 */ |
| 274 |
int gridVisible; |
| 275 |
/*grid cell size in gl coords system */ |
| 276 |
float gridSize; //grid cell size |
| 277 |
|
| 278 |
/*draws a border in border colors if it is 1 */ |
| 279 |
int bdVisible; //if borders are visible (boundries of the drawing, |
| 280 |
/*border coordinates, needs to be calculated for each graph */ |
| 281 |
|
| 282 |
double bdxLeft, bdyTop; |
| 283 |
double bdxRight, bdyBottom; |
| 284 |
|
| 285 |
/*screen window size in 2d */ |
| 286 |
int w, h; |
| 287 |
/*graph pointer to hold loaded graphs */ |
| 288 |
Agraph_t **g; |
| 289 |
/*number of graphs loaded */ |
| 290 |
size_t graphCount; |
| 291 |
/*active graph */ |
| 292 |
int activeGraph; |
| 293 |
|
| 294 |
/*stores the info about status of mouse,pressed? what button ? where? */ |
| 295 |
glCompMouse mouse; |
| 296 |
|
| 297 |
viewport_camera **cameras; |
| 298 |
size_t camera_count; /// <number of cameras |
| 299 |
size_t active_camera; |
| 300 |
|
| 301 |
/// open gl canvas |
| 302 |
GtkWidget *drawing_area; |
| 303 |
|
| 304 |
/*Topview data structure, refer topview.h for more info */ |
| 305 |
topview *Topview; |
| 306 |
/*timer for animations */ |
| 307 |
GTimer *timer; |
| 308 |
/*this timer is session timer and always active */ |
| 309 |
GTimer *timer2; |
| 310 |
/*general purpose timer */ |
| 311 |
GTimer *timer3; |
| 312 |
int active_frame; |
| 313 |
int total_frames; |
| 314 |
/*lately added */ |
| 315 |
int drawnodes; |
| 316 |
int drawedges; |
| 317 |
int drawnodelabels; |
| 318 |
int drawedgelabels; |
| 319 |
|
| 320 |
/*labelling properties */ |
| 321 |
void *glutfont; |
| 322 |
int labelnumberofnodes; |
| 323 |
|
| 324 |
glCompSet *widgets; //for novice user open gl menu |
| 325 |
char *initFileName; //file name from command line |
| 326 |
int initFile; |
| 327 |
int drawSplines; |
| 328 |
colorschemaset colschms; |
| 329 |
char *template_file; |
| 330 |
GtkComboBox *graphComboBox; /*pointer to graph combo box at top right */ |
| 331 |
ArcBall_t *arcball; |
| 332 |
int keyVal; ///< depressed key or 0 if none |
| 333 |
mouse_action_t* mouse_actions; ///< customizable mouse interaction list |
| 334 |
size_t mouse_action_count; |
| 335 |
double nodeScale; |
| 336 |
int guiMode; |
| 337 |
char* optArg; |
| 338 |
|
| 339 |
} ViewInfo; |
| 340 |
|
| 341 |
extern ViewInfo *view; |
| 342 |
extern char *smyrnaPath(char *suffix); |
| 343 |
|
| 344 |
extern void glexpose(void); |