smyrnadefs.h 7.9 KB

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