main.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. /*
  2. * Copyright 2021
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * These are the four essential freedoms with GNU GPL software:
  18. * 1: freedom to run the program, for any purpose
  19. * 2: freedom to study how the program works, and change it to make it do what you wish
  20. * 3: freedom to redistribute copies to help your Free Software friends
  21. * 4: freedom to distribute copies of your modified versions to your Free Software friends
  22. * , ,
  23. * / \
  24. * ((__-^^-,-^^-__))
  25. * `-_---' `---_-'
  26. * `--|o` 'o|--'
  27. * \ ` /
  28. * ): :(
  29. * :o_o:
  30. * "-"
  31. *
  32. * SPDX-License-Identifier: GPL-3.0+
  33. * License-Filename: LICENSE
  34. */
  35. #ifndef MAIN_H
  36. #define MAIN_H 1
  37. /* types of subgraphs */
  38. #define SG_ROOT 0 /* root */
  39. #define SG_COMPOUND 1 /* compound {} */
  40. #define SG_SUBG 2 /* subgraph {} */
  41. #define SG_CLUSTER 3 /* subgraph cluster {} */
  42. /* type of nodes */
  43. #define NODE_SUM 1 /* summary node */
  44. struct gml_graph;
  45. struct gml_node;
  46. struct gml_edge;
  47. struct gml_elist;
  48. struct gml_nlist;
  49. struct gml_glist;
  50. struct gml_el;
  51. struct gml_ellist;
  52. struct gml_rl;
  53. struct gml_p;
  54. struct gml_hl;
  55. /*
  56. * the flags in the structs can be bitflags or chars
  57. * but then compiler warnings may appear
  58. */
  59. struct gml_graph {
  60. int id; /* uniq number and 0 is rootgraph */
  61. char *graphname; /* name of subgraph */
  62. char *label; /* label of subgraph */
  63. int type; /* type of subgraph */
  64. int tnclusters; /* total number of clusters in whole graph at rootgraph */
  65. int tnnodes; /* total number of input nodes in whole graph */
  66. int tnedges; /* total number of input edges in whole graph */
  67. int tnedgelabels; /* total number of edge labels in whole graph */
  68. int maxlevel; /* max. level in graph */
  69. int bmaxlevel; /* max. level in graph at bary */
  70. int *nnodes_of_level; /* number of nodes at level */
  71. int nnodes; /* number of input nodes */
  72. int nedges; /* number of input edges */
  73. int nodenum; /* node uniq number starting at 1 */
  74. int edgenum; /* edge uniq number starting at 1 */
  75. int nedgelabels; /* number of edge labels */
  76. int nhedges; /* number of horizontal edges */
  77. int nselfedges; /* number of self edges in the graph */
  78. int nstartnodes; /* number of starting subgraphs */
  79. int nsinglenodes; /* number of single nodes in the graph */
  80. int startnodeslevel; /* where the actual drawing starts at y-level */
  81. int *startnodes; /* table with startnode numbers */
  82. int *nume; /* number of edges between level n and n+1 */
  83. int widestlevel; /* level with most nodes */
  84. int widestnnodes; /* number of nodes at widest level */
  85. int *wpos; /* width of positions */
  86. int *hpos; /* height of levels */
  87. struct gml_nlist **posnodes; /* lists per pos. */
  88. struct gml_nlist **levelnodes; /* lists per level */
  89. /* the raw parsed node/edge list */
  90. struct gml_nlist *rawnodelist;
  91. struct gml_nlist *rawnodelisttail;
  92. struct gml_elist *rawedgelist;
  93. struct gml_elist *rawedgelisttail;
  94. /* */
  95. /* the used and changed node/edge/single-node list */
  96. struct gml_nlist *nodelist;
  97. struct gml_nlist *nodelisttail;
  98. struct gml_elist *edgelist;
  99. struct gml_elist *edgelisttail;
  100. struct gml_ellist *ellist; /* edges with edge labels */
  101. struct gml_ellist *ellisttail; /* edges with edge labels */
  102. struct gml_nlist *singlenodelist; /* single nodes with no edges */
  103. struct gml_nlist *singlenodelisttail;
  104. struct gml_nlist *selfedgesnodelist; /* nodes with edges to itself */
  105. struct gml_nlist *selfedgesnodelisttail;
  106. struct gml_glist *subglist; /* subgraphs */
  107. struct gml_glist *subglistend;
  108. int sugi_icrossings; /* sugiyama initial crossings */
  109. int sugi_fcrossings; /* sugiyama final crossings */
  110. int sugi_changes; /* sugiyama changes made */
  111. int *numce; /* number of edge crossings per level */
  112. int elsizes; /* set if edge label size are determined */
  113. int nodesizes; /* set if node sizes are set */
  114. int nsamee; /* number of same edges */
  115. };
  116. /* list of subgraphs */
  117. struct gml_glist {
  118. struct gml_graph *sg;
  119. struct gml_glist *next;
  120. };
  121. struct gml_node {
  122. struct gml_graph *rootedon; /* graph where node is located */
  123. int nr; /* uniq node number starting at 1 */
  124. int type; /* type of node */
  125. int id; /* id number as in gml graph */
  126. char *name; /* name of node or label */
  127. int startnode; /* node belongs to part of graph with this startnode */
  128. int nstartnodes; /* node belongs to part of graph with this amount of startnodes */
  129. int objectnr; /* dia xml object number */
  130. int x; /* */
  131. int y; /* */
  132. int relx; /* relative x pos. */
  133. int rely; /* relative y pos. */
  134. int absx; /* absolute x pos. */
  135. int absy; /* absolute y pos. */
  136. int bbx; /* bounding box xsize */
  137. int bby; /* bounding box ysize */
  138. int fbbx; /* bounding box xsize full sized */
  139. int fbby; /* bounding box ysize full sized */
  140. int finx; /* final x pos */
  141. int finy; /* final y pos */
  142. int tx; /* text xsize */
  143. int ty; /* text ysize */
  144. int ftx; /* full text xsize */
  145. int fty; /* full text ysize */
  146. int lx0; /* start of level x pos where node is */
  147. int lx1; /* end of level x pos where node is */
  148. int ly0; /* start of level y pos where node is */
  149. int ly1; /* end of level y pos where node is */
  150. int lxsize; /* x size of level */
  151. int lysize; /* y size of level */
  152. int txsize; /* set if node text size is calculated */
  153. int incluster; /* set if node is in a cluster layout */
  154. int drawrh; /* if set draw r/h labels */
  155. int dummy; /* set to 1 if dummy node */
  156. int hashedge; /* set to 1 if node has hor. edges */
  157. int elabel; /* set if node is a edge label */
  158. int ishtml; /* set if label is html label <> */
  159. int nselfedges; /* number of self edges at this node */
  160. struct gml_elist *outgoing_e; /* source list, outgoing edges */
  161. struct gml_elist *outgoing_etail; /* source list, outgoing edges */
  162. struct gml_edge **oedges; /* array outgoing edges */
  163. int dx_oedges; /* x distance between outgoing edges */
  164. struct gml_elist *incoming_e; /* target list, incoming edges */
  165. struct gml_elist *incoming_etail; /* target list, incoming edges */
  166. struct gml_edge **iedges; /* array incoming edges */
  167. int dx_iedges; /* x distance between incoming edges */
  168. char *nlabel; /* optional label or the id */
  169. struct gml_rl *rlabel; /* optional record label data */
  170. int rlabeldone; /* set if textsizes rlabel are set */
  171. struct gml_hl *hlabel; /* optional html label data */
  172. int hlabeldone; /* set if textsizes hlabel are set */
  173. int ncolor; /* r/g/b fill color of node */
  174. int nbcolor; /* r/g/b border color of node */
  175. int fontcolor; /* r/g/b color of label text */
  176. int secolor; /* r/g/b fill color of self-edge at node if any */
  177. int indegree; /* incoming edges to node */
  178. int outdegree; /* outgoing edges from node */
  179. struct gml_node *el_fnode; /* in edge-label the from-node */
  180. struct gml_node *el_tnode; /* in edge-label the to-node */
  181. int done; /* dfs black/white */
  182. int grey; /* dfs grey */
  183. int same; /* set if node is part of same edge */
  184. struct gml_el *eldata; /* extra original edge data if edge label node or dummy node */
  185. };
  186. struct gml_nlist {
  187. struct gml_node *node;
  188. struct gml_nlist *next;
  189. };
  190. struct gml_edge {
  191. int nr; /* uniq number staring at 1 */
  192. int done; /* edge is done */
  193. struct gml_graph *rootedon; /* graph where edge is located */
  194. struct gml_node *from_node; /* from node */
  195. struct gml_node *to_node; /* to node */
  196. int same; /* set if edge is multiple times defined */
  197. int incluster; /* set if edge is in cluster layout */
  198. int reversed; /* set if edge is reversed */
  199. int hedge; /* set if edge is horizontal line */
  200. int vedge; /* set if edge is vertical */
  201. int inner; /* set if edge is a inner edge */
  202. char *elabel; /* optional edge label */
  203. int ishtml; /* set if elabel is <> html label */
  204. int ecolor; /* r/g/b edge line color */
  205. int style; /* edge line style, solid dotted dashed */
  206. char *fcompass; /* optional from-compass point */
  207. char *tcompass; /* optional to-compass point */
  208. int constraint; /* dot edge constraint */
  209. struct gml_el *eldata; /* extra data if edge has edge label */
  210. int split; /* set if edge is part of a split edge */
  211. int headsplit; /* set if edge is head of a split edge */
  212. int tailsplit; /* set if edge is tail of a split edge */
  213. struct gml_edge *rawedge; /* edge in rawedgelist */
  214. };
  215. /* edges */
  216. struct gml_elist {
  217. struct gml_edge *edge;
  218. struct gml_elist *next;
  219. };
  220. /* extra edge info for edges with label
  221. * and for dummy nodes
  222. * full data of edge is in struct gml_edge
  223. */
  224. struct gml_el {
  225. struct gml_edge *rawedge; /* edge in rawedgelist */
  226. struct gml_node *ofrom; /* original from node */
  227. struct gml_node *oto; /* original to node */
  228. char *elabel; /* original edge label text */
  229. int ishtml; /* set if elabel is <> html label but not yet implementef */
  230. int tx; /* x size of label */
  231. int ty; /* y size of label */
  232. };
  233. /* list of edges with edge label */
  234. struct gml_ellist {
  235. struct gml_el *eledge;
  236. struct gml_ellist *next;
  237. };
  238. /* record label */
  239. struct gml_rl {
  240. int hd; /* has-data */
  241. int dir; /* x or y direction */
  242. int nparts; /* how many parts */
  243. struct gml_rl **parts; /* subparts */
  244. char *port; /* port name */
  245. char *label; /* original label */
  246. char *ulabel; /* updated label */
  247. int txsize; /* text x size */
  248. int tysize; /* text y size */
  249. int bbx; /* total x size */
  250. int bby; /* total y size */
  251. int xoff; /* x offset */
  252. int yoff; /* y offset */
  253. int xstep; /* x stepsize */
  254. int ystep; /* y stepsize */
  255. };
  256. /* (x,y) point */
  257. struct gml_p {
  258. int x;
  259. int y;
  260. };
  261. /* one item of text:
  262. * bgcolor is default white 0x00ffffff
  263. * then set by optional node fillcolor
  264. * then set by optional <table> bgcolor
  265. * then set by optional <td> bgcolor
  266. */
  267. struct gml_hitem {
  268. char *text; /* text to display modified */
  269. char *otext; /* text to display original */
  270. char *fontstr; /* pango font format string */
  271. char *fontdesc; /* pango font description */
  272. char *fontname; /* optional font name */
  273. char *fontslant; /* font slant */
  274. char *fontweight; /* fontweight */
  275. int fontsize; /* optional pointsize */
  276. int fontcolor; /* optional color of text */
  277. int ncolor; /* optional background color from <td> or <table> */
  278. int txsizemin; /* min. text x size of all lines */
  279. int tysizemin; /* min. text y size of all lines */
  280. int txsize; /* text x size of all lines */
  281. int tysize; /* text y size of all lines */
  282. int txoff; /* text x offset in 1 line */
  283. int tyoff; /* text y offset in 1 line */
  284. int lysize; /* y size of this text line */
  285. int yoff; /* y offset of line */
  286. struct {
  287. unsigned int at:1; /* set if str has a '&' */
  288. unsigned int br:1; /* set if str is a <br/> token */
  289. unsigned int img:1; /* set if str is a <img> */
  290. unsigned int i:1; /* set if str is <i> italic */
  291. unsigned int u:1; /* set if str is <u> underline */
  292. unsigned int o:1; /* set if str is <o> overline */
  293. unsigned int s:1; /* set if str is <s> strike-through */
  294. unsigned int sub:1; /* set if str is <sub> subscript */
  295. unsigned int sup:1; /* set if str is <sup> superscript */
  296. unsigned int hr:1; /* set if str is a <hr> token */
  297. unsigned int vr:1; /* set if str is a <vr> token */
  298. unsigned int b:1; /* set if str is <b> bold */
  299. unsigned int table:1; /* set if a <table> not string */
  300. unsigned int bit13:1;
  301. unsigned int bit14:1;
  302. unsigned int bit15:1;
  303. unsigned int bit16:1;
  304. unsigned int bit17:1;
  305. unsigned int bit18:1;
  306. unsigned int bit19:1;
  307. unsigned int bit20:1;
  308. unsigned int bit21:1;
  309. unsigned int bit22:1;
  310. unsigned int bit23:1;
  311. unsigned int bit24:1;
  312. unsigned int bit25:1;
  313. unsigned int bit26:1;
  314. unsigned int bit27:1;
  315. unsigned int bit28:1;
  316. unsigned int bit29:1;
  317. unsigned int bit30:1;
  318. unsigned int bit31:1;
  319. } bitflags;
  320. struct gml_titem *rootedon; /* item is part of <table> */
  321. struct gml_titem *table; /* item is a <table> */
  322. };
  323. /* list with text items in html string */
  324. struct gml_hilist {
  325. struct gml_hitem *items;
  326. struct gml_hilist *next;
  327. };
  328. /* one <td> */
  329. struct gml_tditem {
  330. struct gml_hilist *il; /* list of text items */
  331. struct gml_hilist *ilend;
  332. struct gml_titem *rootedon; /* <td> is part of <table> */
  333. /* data from input */
  334. int bgcolor; /* ="colorname" */
  335. int border; /* ="int-value" */
  336. int cellpadding; /* ="int-value" */
  337. int cellspacing; /* ="int-value" */
  338. int color; /* ="colorname" */
  339. int colspan; /* ="int-value" */
  340. int height; /* ="int-value" */
  341. int rowspan; /* ="int-value" */
  342. int width; /* ="int-value" */
  343. /* */
  344. int xsize; /* x size of <td> at col <tr> */
  345. int ysize; /* y size of <td> at col <tr> */
  346. int xsizemin; /* min. x size of <td> at col <tr> */
  347. int ysizemin; /* min. y size of <td> at col <tr> */
  348. int xstep; /* x step size for this <td> */
  349. int ystep; /* y step size for this <td> */
  350. /* */
  351. int istab; /* set if <td> is a <table> */
  352. int dummy; /* set if <td> is dummy to fill the table */
  353. struct gml_tditem *next;
  354. };
  355. /* one <tr> item */
  356. struct gml_tritem {
  357. struct gml_tditem *tdi;
  358. struct gml_tditem *tdiend;
  359. struct gml_titem *rootedon; /* <tr> is part of <table> */
  360. /* data of <tr> */
  361. int numtd; /* number of <td> statements in this <tr> */
  362. /* placement data */
  363. int ysize; /* y size of this <tr> for the <td> elements */
  364. int hastab; /* set if <tr> has a <td> with <table> data */
  365. };
  366. /* list with <tr> items */
  367. struct gml_tritemlist {
  368. struct gml_tritem *tritem;
  369. struct gml_tritemlist *next;
  370. };
  371. /* table data */
  372. struct gml_titem {
  373. struct gml_htlist *tl; /* list of sub table items */
  374. struct gml_htlist *tlend;
  375. struct gml_tritemlist *tr; /* list of <tr> items in this table */
  376. struct gml_tritemlist *trend;
  377. /* data of table */
  378. int xoff; /* x offset */
  379. int yoff; /* y offset */
  380. int txsize; /* x size of table */
  381. int tysize; /* y size of table */
  382. int txsizemin; /* min. x size of table */
  383. int tysizemin; /* min. y size of table */
  384. int numtr; /* number of <tr> statements */
  385. int numtd; /* number of <td> needed in table */
  386. int ncols; /* number of columns x */
  387. int nrows; /* number of rows y */
  388. int sizeset; /* set if min. size is known */
  389. /* input table data */
  390. int bgcolor; /* background color */
  391. int color; /* fontcolor */
  392. int cellborder; /* ="int-value" */
  393. int cellpadding; /* ="int-value" */
  394. int cellspacing; /* ="int-value" */
  395. int height; /* ="int-value" */
  396. int width; /* ="int-value" */
  397. };
  398. /* list with table elements in html string */
  399. struct gml_htlist {
  400. struct gml_titem *titem;
  401. struct gml_htlist *next;
  402. };
  403. /* html label with items or tables */
  404. struct gml_hl {
  405. int mode; /* 0=items, 1=tables */
  406. struct gml_hilist *il; /* list of text items */
  407. struct gml_hilist *ilend;
  408. struct gml_htlist *tl; /* list of <table> items */
  409. struct gml_htlist *tlend;
  410. };
  411. /* in gui code, update status text crossings */
  412. extern void update_status_text_cross(char *text);
  413. /* needed for gcc -fanalyzer */
  414. #if (GTK_HAVE_API_VERSION_2 == 1 || GTK_HAVE_API_VERSION_3 == 1)
  415. extern int maingtk23(void);
  416. #endif
  417. #endif
  418. /* end */