]>
Commit | Line | Data |
---|---|---|
ce4d5ce0 | 1 | /* VCG description handler for Bison. |
4344c500 | 2 | Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
ce4d5ce0 AD |
3 | |
4 | This file is part of Bison, the GNU Compiler Compiler. | |
5 | ||
6 | Bison is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | Bison is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with Bison; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #include "system.h" | |
22 | #include "vcg.h" | |
23 | #include "vcg_defaults.h" | |
08a946e0 AD |
24 | #include "quotearg.h" |
25 | ||
e5fb6710 AD |
26 | /* Return an unambiguous printable representated, for NAME, suitable |
27 | for C strings. Use slot 2 since the user may use slots 0 and 1. | |
28 | */ | |
29 | ||
08a946e0 AD |
30 | static char const * |
31 | quote (char const *name) | |
32 | { | |
e5fb6710 | 33 | return quotearg_n_style (2, c_quoting_style, name); |
08a946e0 AD |
34 | } |
35 | ||
ce4d5ce0 AD |
36 | |
37 | /* Initialize a graph with the default values. */ | |
38 | void | |
39 | new_graph (graph_t *g) | |
40 | { | |
41 | g->title = G_TITLE; | |
42 | g->label = G_LABEL; | |
3e3da797 | 43 | |
ce4d5ce0 AD |
44 | g->infos[0] = G_INFOS1; |
45 | g->infos[1] = G_INFOS2; | |
46 | g->infos[2] = G_INFOS3; | |
3e3da797 | 47 | |
ce4d5ce0 AD |
48 | g->color = G_COLOR; |
49 | g->textcolor = G_TEXTCOLOR; | |
50 | g->bordercolor = G_BORDERCOLOR; | |
3e3da797 | 51 | |
ce4d5ce0 AD |
52 | g->width = G_WIDTH; |
53 | g->height = G_HEIGHT; | |
54 | g->borderwidth = G_BORDERWIDTH; | |
55 | g->x = G_X; | |
56 | g->y = G_Y; | |
57 | g->folding = G_FOLDING; | |
58 | g->shrink = G_SHRINK; | |
59 | g->stretch = G_STRETCH; | |
60 | ||
61 | g->textmode = G_TEXTMODE; | |
62 | g->shape = G_SHAPE; | |
3e3da797 | 63 | |
342b8b6e AD |
64 | g->vertical_order = G_VERTICAL_ORDER; |
65 | g->horizontal_order = G_HORIZONTAL_ORDER; | |
66 | ||
ce4d5ce0 AD |
67 | g->xmax = G_XMAX; /* Not output. */ |
68 | g->ymax = G_YMAX; /* Not output. */ | |
3e3da797 | 69 | |
ce4d5ce0 AD |
70 | g->xbase = G_XBASE; |
71 | g->ybase = G_YBASE; | |
72 | ||
73 | g->xspace = G_XSPACE; | |
74 | g->yspace = G_YSPACE; | |
75 | g->xlspace = G_XLSPACE; /* Not output. */ | |
3e3da797 | 76 | |
ce4d5ce0 AD |
77 | g->xraster = G_XRASTER; |
78 | g->yraster = G_YRASTER; | |
79 | g->xlraster = G_XLRASTER; | |
80 | ||
81 | g->hidden = G_HIDDEN; /* No default value. */ | |
82 | ||
83 | g->classname = G_CLASSNAME; /* No class name association. */ | |
3e3da797 | 84 | |
ce4d5ce0 AD |
85 | g->layoutalgorithm = G_LAYOUTALGORITHM; |
86 | g->layout_downfactor = G_LAYOUT_DOWNFACTOR; | |
87 | g->layout_upfactor = G_LAYOUT_UPFACTOR; | |
88 | g->layout_nearfactor = G_LAYOUT_NEARFACTOR; | |
89 | g->layout_splinefactor = G_LAYOUT_SPLINEFACTOR; | |
3e3da797 | 90 | |
ce4d5ce0 AD |
91 | g->late_edge_labels = G_LATE_EDGE_LABELS; |
92 | g->display_edge_labels = G_DISPLAY_EDGE_LABELS; | |
93 | g->dirty_edge_labels = G_DIRTY_EDGE_LABELS; | |
94 | g->finetuning = G_FINETUNING; | |
95 | g->ignore_singles = G_IGNORE_SINGLES; | |
96 | g->straight_phase = G_STRAIGHT_PHASE; | |
97 | g->priority_phase = G_PRIORITY_PHASE; | |
98 | g->manhattan_edges = G_MANHATTAN_EDGES; | |
99 | g->smanhattan_edges = G_SMANHATTAN_EDGES; | |
100 | g->near_edges = G_NEAR_EDGES; | |
3e3da797 | 101 | |
ce4d5ce0 AD |
102 | g->orientation = G_ORIENTATION; |
103 | g->node_alignement = G_NODE_ALIGNEMENT; | |
104 | g->port_sharing = G_PORT_SHARING; | |
105 | g->arrow_mode = G_ARROW_MODE; | |
106 | g->treefactor = G_TREEFACTOR; | |
107 | g->spreadlevel = G_SPREADLEVEL; | |
108 | g->crossing_weight = G_CROSSING_WEIGHT; | |
109 | g->crossing_phase2 = G_CROSSING_PHASE2; | |
110 | g->crossing_optimization = G_CROSSING_OPTIMIZATION; | |
111 | g->view = G_VIEW; | |
112 | ||
113 | g->edges = G_EDGES; | |
114 | g->nodes = G_NODES; | |
115 | g->splines = G_SPLINES; | |
116 | ||
117 | g->bmax = G_BMAX; | |
118 | g->cmin = G_CMIN; | |
119 | g->cmax = G_CMAX; | |
120 | g->pmin = G_PMIN; | |
121 | g->pmax = G_PMAX; | |
122 | g->rmin = G_RMIN; | |
123 | g->rmax = G_RMAX; | |
124 | g->smax = G_SMAX; | |
3e3da797 | 125 | |
ce4d5ce0 AD |
126 | g->node_list = G_NODE_LIST; |
127 | g->edge_list = G_EDGE_LIST; | |
3e3da797 | 128 | |
ce4d5ce0 AD |
129 | new_edge(&g->edge); |
130 | new_node(&g->node); | |
131 | } | |
132 | ||
133 | /* Initialize a node with the defalut values. */ | |
134 | void | |
135 | new_node (node_t *node) | |
136 | { | |
137 | node->title = N_TITLE; | |
138 | node->label = N_LABEL; | |
3e3da797 | 139 | |
ce4d5ce0 AD |
140 | node->locx = N_LOCX; /* Default unspcified. */ |
141 | node->locy = N_LOCY; /* Default unspcified. */ | |
3e3da797 | 142 | |
ce4d5ce0 AD |
143 | node->vertical_order = N_VERTICAL_ORDER; /* Default unspcified. */ |
144 | node->horizontal_order = N_HORIZONTAL_ORDER; /* Default unspcified. */ | |
3e3da797 | 145 | |
ce4d5ce0 AD |
146 | node->width = N_WIDTH; /* We assume that we can't define it now. */ |
147 | node->height = N_HEIGHT; /* Also. */ | |
3e3da797 | 148 | |
ce4d5ce0 AD |
149 | node->shrink = N_SHRINK; |
150 | node->stretch = N_STRETCH; | |
3e3da797 | 151 | |
ce4d5ce0 | 152 | node->folding = N_FOLDING; /* No explicit default value. */ |
3e3da797 | 153 | |
ce4d5ce0 AD |
154 | node->shape = N_SHAPE; |
155 | node->textmode = N_TEXTMODE; | |
156 | node->borderwidth = N_BORDERWIDTH; | |
3e3da797 | 157 | |
ce4d5ce0 AD |
158 | node->color = N_COLOR; |
159 | node->textcolor = N_TEXTCOLOR; | |
160 | node->bordercolor = N_BORDERCOLOR; | |
3e3da797 | 161 | |
ce4d5ce0 AD |
162 | node->infos[0] = N_INFOS1; |
163 | node->infos[1] = N_INFOS2; | |
164 | node->infos[2] = N_INFOS3; | |
3e3da797 | 165 | |
ce4d5ce0 AD |
166 | node->next = N_NEXT; |
167 | } | |
168 | ||
169 | /* Initialize a edge with the defalut values. */ | |
170 | void | |
171 | new_edge (edge_t *edge) | |
172 | { | |
173 | edge->type = E_EDGE_TYPE; | |
174 | ||
175 | edge->sourcename = E_SOURCENAME; | |
176 | edge->targetname = E_TARGETNAME; | |
177 | edge->label = E_LABEL; | |
178 | ||
179 | edge->linestyle = E_LINESTYLE; | |
180 | edge->thickness = E_THICKNESS; | |
181 | ||
182 | edge->class = E_CLASS; | |
183 | ||
184 | edge->color = E_COLOR; | |
185 | edge->textcolor = E_TEXTCOLOR; | |
186 | edge->arrowcolor = E_ARROWCOLOR; | |
187 | edge->backarrowcolor = E_BACKARROWCOLOR; | |
188 | ||
189 | edge->arrowsize = E_ARROWSIZE; | |
190 | edge->backarrowsize = E_BACKARROWSIZE; | |
191 | edge->arrowstyle = E_ARROWSTYLE; | |
192 | ||
193 | edge->backarrowstyle = E_BACKARROWSTYLE; | |
194 | ||
195 | edge->priority = E_PRIORITY; | |
196 | ||
197 | edge->anchor = E_ANCHOR; | |
198 | ||
199 | edge->horizontal_order = E_HORIZONTAL_ORDER; | |
200 | ||
201 | edge->next = E_NEXT; | |
202 | } | |
203 | ||
204 | /*----------------------------------------------. | |
205 | | Get functions. | | |
206 | | Return string corresponding to an enum value. | | |
207 | `----------------------------------------------*/ | |
208 | ||
209 | static const char * | |
210 | get_color_str (enum color_e c) | |
211 | { | |
212 | switch (c) | |
213 | { | |
3e3da797 AD |
214 | case white: return "white"; |
215 | case blue: return "blue"; | |
216 | case red: return "red"; | |
217 | case green: return "green"; | |
218 | case yellow: return "yellow"; | |
219 | case magenta: return "magenta"; | |
220 | case cyan: return "cyan"; | |
221 | case darkgrey: return "darkgrey"; | |
222 | case darkblue: return "darkblue"; | |
223 | case darkred: return "darkred"; | |
224 | case darkgreen: return "darkgreen"; | |
225 | case darkyellow: return "darkyellow"; | |
226 | case darkmagenta: return "darkmagenta"; | |
227 | case darkcyan: return "darkcyan"; | |
228 | case gold: return "gold"; | |
229 | case lightgrey: return "lightgrey"; | |
230 | case lightblue: return "lightblue"; | |
231 | case lightred: return "lightred"; | |
232 | case lightgreen: return "lightgreen"; | |
233 | case lightyellow: return "lightyellow"; | |
234 | case lightmagenta: return "lightmagenta"; | |
235 | case lightcyan: return "lightcyan"; | |
236 | case lilac: return "lilac"; | |
237 | case turquoise: return "turquoise"; | |
238 | case aquamarine: return "aquamarine"; | |
239 | case khaki: return "khaki"; | |
240 | case purple: return "purple"; | |
241 | case yellowgreen: return "yellowgreen"; | |
242 | case pink: return "pink"; | |
243 | case orange: return "orange"; | |
244 | case orchid: return "orchid"; | |
245 | case black: return "black"; | |
4344c500 | 246 | default: abort (); return NULL; |
ce4d5ce0 | 247 | } |
ce4d5ce0 AD |
248 | } |
249 | ||
250 | static const char * | |
251 | get_textmode_str (enum textmode_e t) | |
252 | { | |
253 | switch (t) | |
254 | { | |
3e3da797 AD |
255 | case centered: return "center"; |
256 | case left_justify: return "left_justify"; | |
257 | case right_justify: return "right_justify"; | |
4344c500 | 258 | default: abort (); return NULL; |
ce4d5ce0 | 259 | } |
ce4d5ce0 AD |
260 | } |
261 | ||
262 | static const char * | |
263 | get_shape_str (enum shape_e s) | |
264 | { | |
265 | switch (s) | |
266 | { | |
3e3da797 AD |
267 | case box: return "box"; |
268 | case rhomb: return "rhomb"; | |
269 | case ellipse: return "ellipse"; | |
270 | case triangle: return "triangle"; | |
4344c500 | 271 | default: abort (); return NULL; |
ce4d5ce0 | 272 | } |
ce4d5ce0 AD |
273 | } |
274 | ||
275 | static const char * | |
276 | get_layoutalgorithm_str (enum layoutalgorithm_e l) | |
277 | { | |
278 | switch (l) | |
279 | { | |
3e3da797 AD |
280 | case normal: return "normal"; |
281 | case maxdepth: return "maxdepth"; | |
282 | case mindepth: return "mindepth"; | |
283 | case maxdepthslow: return "maxdepthslow"; | |
284 | case mindepthslow: return "mindepthslow"; | |
285 | case maxdegree: return "maxdegree"; | |
286 | case mindegree: return "mindegree"; | |
287 | case maxindegree: return "maxindegree"; | |
288 | case minindegree: return "minindegree"; | |
289 | case maxoutdegree: return "maxoutdegree"; | |
290 | case minoutdegree: return "minoutdegree"; | |
291 | case minbackward: return "minbackward"; | |
292 | case dfs: return "dfs"; | |
293 | case tree: return "tree"; | |
4344c500 | 294 | default: abort (); return NULL; |
ce4d5ce0 | 295 | } |
ce4d5ce0 AD |
296 | } |
297 | ||
298 | static const char * | |
342b8b6e | 299 | get_decision_str (enum decision_e d) |
ce4d5ce0 AD |
300 | { |
301 | switch (d) | |
302 | { | |
3e3da797 AD |
303 | case no: return "no"; |
304 | case yes: return "yes"; | |
4344c500 | 305 | default: abort (); return NULL; |
ce4d5ce0 | 306 | } |
ce4d5ce0 AD |
307 | } |
308 | ||
309 | static const char * | |
310 | get_orientation_str (enum orientation_e o) | |
311 | { | |
312 | switch (o) | |
313 | { | |
3e3da797 AD |
314 | case top_to_bottom: return "top_to_bottom"; |
315 | case bottom_to_top: return "bottom_to_top"; | |
316 | case left_to_right: return "left_to_right"; | |
317 | case right_to_left: return "right_to_left"; | |
4344c500 | 318 | default: abort (); return NULL; |
ce4d5ce0 | 319 | } |
ce4d5ce0 AD |
320 | } |
321 | ||
322 | static const char * | |
323 | get_node_alignement_str (enum alignement_e a) | |
324 | { | |
325 | switch (a) | |
326 | { | |
3e3da797 AD |
327 | case center: return "center"; |
328 | case top: return "top"; | |
329 | case bottom: return "bottom"; | |
4344c500 | 330 | default: abort (); return NULL; |
ce4d5ce0 | 331 | } |
ce4d5ce0 AD |
332 | } |
333 | ||
334 | static const char * | |
335 | get_arrow_mode_str (enum arrow_mode_e a) | |
336 | { | |
337 | switch (a) | |
338 | { | |
3e3da797 AD |
339 | case fixed: return "fixed"; |
340 | case free_a: return "free"; | |
4344c500 | 341 | default: abort (); return NULL; |
ce4d5ce0 | 342 | } |
ce4d5ce0 AD |
343 | } |
344 | ||
345 | static const char * | |
346 | get_crossing_type_str (enum crossing_type_e c) | |
347 | { | |
348 | switch (c) | |
349 | { | |
3e3da797 AD |
350 | case bary: return "bary"; |
351 | case median: return "median"; | |
352 | case barymedian: return "barymedian"; | |
353 | case medianbary: return "medianbary"; | |
4344c500 | 354 | default: abort (); return NULL; |
3e3da797 | 355 | } |
ce4d5ce0 AD |
356 | } |
357 | ||
358 | static const char * | |
359 | get_view_str (enum view_e v) | |
360 | { | |
361 | switch (v) | |
362 | { | |
3e3da797 AD |
363 | case normal_view: return "normal_view"; |
364 | case cfish: return "cfish"; | |
365 | case pfish: return "pfish"; | |
366 | case fcfish: return "fcfish"; | |
367 | case fpfish: return "fpfish"; | |
4344c500 | 368 | default: abort (); return NULL; |
ce4d5ce0 | 369 | } |
ce4d5ce0 AD |
370 | } |
371 | ||
372 | static const char * | |
373 | get_linestyle_str (enum linestyle_e l) | |
374 | { | |
375 | switch (l) | |
376 | { | |
3e3da797 AD |
377 | case continuous: return "continuous"; |
378 | case dashed: return "dashed"; | |
379 | case dotted: return "dotted"; | |
380 | case invisible: return "invisible"; | |
4344c500 | 381 | default: abort (); return NULL; |
3e3da797 | 382 | } |
ce4d5ce0 AD |
383 | } |
384 | ||
385 | static const char * | |
386 | get_arrowstyle_str (enum arrowstyle_e a) | |
387 | { | |
388 | switch (a) | |
389 | { | |
3e3da797 AD |
390 | case solid: return "solid"; |
391 | case line: return "line"; | |
392 | case none: return "none"; | |
4344c500 | 393 | default: abort (); return NULL; |
ce4d5ce0 | 394 | } |
ce4d5ce0 AD |
395 | } |
396 | ||
397 | /*----------------------------. | |
398 | | Add functions. | | |
399 | | Edge and Nodes int a graph. | | |
400 | `----------------------------*/ | |
401 | ||
402 | void | |
403 | add_node (graph_t *graph, node_t *node) | |
404 | { | |
405 | node->next = graph->node_list; | |
406 | graph->node_list = node; | |
407 | } | |
408 | ||
409 | void | |
410 | add_edge (graph_t *graph, edge_t *edge) | |
411 | { | |
412 | edge->next = graph->edge_list; | |
413 | graph->edge_list = edge; | |
414 | } | |
415 | ||
342b8b6e AD |
416 | void |
417 | add_classname (graph_t *g, int val, const char *name) | |
418 | { | |
419 | struct classname_s *classname; | |
08a946e0 | 420 | |
342b8b6e AD |
421 | classname = XMALLOC (struct classname_s, 1); |
422 | classname->no = val; | |
423 | classname->name = name; | |
424 | classname->next = g->classname; | |
425 | g->classname = classname; | |
426 | } | |
427 | ||
428 | void | |
429 | add_infoname (graph_t *g, int integer, const char *string) | |
430 | { | |
431 | struct infoname_s *infoname; | |
08a946e0 | 432 | |
342b8b6e AD |
433 | infoname = XMALLOC (struct infoname_s, 1); |
434 | infoname->integer = integer; | |
435 | infoname->string = string; | |
436 | infoname->next = g->infoname; | |
437 | g->infoname = infoname; | |
438 | } | |
439 | ||
440 | /* Build a colorentry struct and add it to the list. */ | |
441 | void | |
08a946e0 | 442 | add_colorentry (graph_t *g, int color_idx, int red_cp, |
342b8b6e AD |
443 | int green_cp, int blue_cp) |
444 | { | |
445 | struct colorentry_s *ce; | |
08a946e0 | 446 | |
342b8b6e AD |
447 | ce = XMALLOC (struct colorentry_s, 1); |
448 | ce->color_index = color_idx; | |
449 | ce->red_cp = red_cp; | |
450 | ce->green_cp = green_cp; | |
451 | ce->blue_cp = blue_cp; | |
452 | ce->next = g->colorentry; | |
453 | g->colorentry = ce; | |
454 | } | |
455 | ||
ce4d5ce0 AD |
456 | /*-------------------------------------. |
457 | | Open and close functions (formatted) | | |
458 | `-------------------------------------*/ | |
459 | ||
460 | void | |
342b8b6e | 461 | open_edge(edge_t *edge, FILE *fout) |
ce4d5ce0 AD |
462 | { |
463 | switch (edge->type) | |
464 | { | |
465 | case normal_edge: | |
342b8b6e | 466 | fputs ("\tedge: {\n", fout); |
ce4d5ce0 AD |
467 | break; |
468 | case back_edge: | |
342b8b6e | 469 | fputs ("\tbackedge: {\n", fout); |
ce4d5ce0 AD |
470 | break; |
471 | case near_edge: | |
342b8b6e | 472 | fputs ("\tnearedge: {\n", fout); |
ce4d5ce0 AD |
473 | break; |
474 | case bent_near_edge: | |
342b8b6e | 475 | fputs ("\tbentnearedge: {\n", fout); |
3e3da797 | 476 | break; |
ce4d5ce0 | 477 | default: |
342b8b6e | 478 | fputs ("\tedge: {\n", fout); |
3e3da797 | 479 | } |
ce4d5ce0 AD |
480 | } |
481 | ||
482 | void | |
342b8b6e | 483 | close_edge(FILE *fout) |
ce4d5ce0 | 484 | { |
342b8b6e | 485 | fputs ("\t}\n", fout); |
ce4d5ce0 AD |
486 | } |
487 | ||
488 | void | |
342b8b6e | 489 | open_node(FILE *fout) |
ce4d5ce0 | 490 | { |
342b8b6e | 491 | fputs ("\tnode: {\n", fout); |
ce4d5ce0 AD |
492 | } |
493 | ||
494 | void | |
342b8b6e | 495 | close_node(FILE *fout) |
3e3da797 | 496 | { |
342b8b6e | 497 | fputs ("\t}\n", fout); |
ce4d5ce0 AD |
498 | } |
499 | ||
500 | void | |
342b8b6e | 501 | open_graph(FILE *fout) |
ce4d5ce0 | 502 | { |
342b8b6e | 503 | fputs ("graph: {\n", fout); |
ce4d5ce0 AD |
504 | } |
505 | ||
506 | void | |
342b8b6e | 507 | close_graph(graph_t *graph, FILE *fout) |
ce4d5ce0 | 508 | { |
342b8b6e | 509 | fputc ('\n', fout); |
ce4d5ce0 | 510 | |
342b8b6e | 511 | /* FIXME: Unallocate nodes and edges if required. */ |
ce4d5ce0 AD |
512 | { |
513 | node_t *node; | |
3e3da797 | 514 | |
ce4d5ce0 AD |
515 | for (node = graph->node_list; node; node = node->next) |
516 | { | |
342b8b6e AD |
517 | open_node (fout); |
518 | output_node (node, fout); | |
519 | close_node (fout); | |
ce4d5ce0 AD |
520 | } |
521 | } | |
3e3da797 | 522 | |
342b8b6e | 523 | fputc ('\n', fout); |
3e3da797 | 524 | |
ce4d5ce0 AD |
525 | { |
526 | edge_t *edge; | |
3e3da797 | 527 | |
ce4d5ce0 | 528 | for (edge = graph->edge_list; edge; edge = edge->next) |
3e3da797 | 529 | { |
342b8b6e AD |
530 | open_edge (edge, fout); |
531 | output_edge (edge, fout); | |
532 | close_edge (fout); | |
ce4d5ce0 AD |
533 | } |
534 | } | |
3e3da797 | 535 | |
342b8b6e | 536 | fputs ("}\n", fout); |
3e3da797 AD |
537 | } |
538 | ||
ce4d5ce0 | 539 | /*-------------------------------------------. |
342b8b6e | 540 | | Output functions (formatted) in file FOUT | |
ce4d5ce0 AD |
541 | `-------------------------------------------*/ |
542 | ||
543 | void | |
342b8b6e | 544 | output_node (node_t *node, FILE *fout) |
ce4d5ce0 AD |
545 | { |
546 | if (node->title != N_TITLE) | |
08a946e0 | 547 | fprintf (fout, "\t\ttitle:\t%s\n", quote (node->title)); |
ce4d5ce0 | 548 | if (node->label != N_LABEL) |
08a946e0 | 549 | fprintf (fout, "\t\tlabel:\t%s\n", quote (node->label)); |
ce4d5ce0 AD |
550 | |
551 | if ((node->locx != N_LOCX) && (node->locy != N_LOCY)) | |
342b8b6e | 552 | fprintf (fout, "\t\tloc { x: %d y: %d }\t\n", node->locx, node->locy); |
3e3da797 | 553 | |
ce4d5ce0 | 554 | if (node->vertical_order != N_VERTICAL_ORDER) |
342b8b6e | 555 | fprintf (fout, "\t\tvertical_order:\t%d\n", node->vertical_order); |
ce4d5ce0 | 556 | if (node->horizontal_order != N_HORIZONTAL_ORDER) |
342b8b6e | 557 | fprintf (fout, "\t\thorizontal_order:\t%d\n", node->horizontal_order); |
3e3da797 | 558 | |
ce4d5ce0 | 559 | if (node->width != N_WIDTH) |
342b8b6e | 560 | fprintf (fout, "\t\twidth:\t%d\n", node->width); |
ce4d5ce0 | 561 | if (node->height != N_HEIGHT) |
342b8b6e | 562 | fprintf (fout, "\t\theight:\t%d\n", node->height); |
3e3da797 | 563 | |
ce4d5ce0 | 564 | if (node->shrink != N_SHRINK) |
342b8b6e | 565 | fprintf (fout, "\t\tshrink:\t%d\n", node->shrink); |
ce4d5ce0 | 566 | if (node->stretch != N_STRETCH) |
342b8b6e | 567 | fprintf (fout, "\t\tstretch:\t%d\n", node->stretch); |
3e3da797 | 568 | |
ce4d5ce0 | 569 | if (node->folding != N_FOLDING) |
342b8b6e | 570 | fprintf (fout, "\t\tfolding:\t%d\n", node->folding); |
3e3da797 | 571 | |
ce4d5ce0 | 572 | if (node->textmode != N_TEXTMODE) |
342b8b6e AD |
573 | fprintf (fout, "\t\ttextmode:\t%s\n", |
574 | get_textmode_str (node->textmode)); | |
3e3da797 | 575 | |
ce4d5ce0 | 576 | if (node->shape != N_SHAPE) |
342b8b6e | 577 | fprintf (fout, "\t\tshape:\t%s\n", get_shape_str (node->shape)); |
3e3da797 | 578 | |
ce4d5ce0 | 579 | if (node->borderwidth != N_BORDERWIDTH) |
342b8b6e | 580 | fprintf (fout, "\t\tborderwidth:\t%d\n", node->borderwidth); |
3e3da797 | 581 | |
ce4d5ce0 | 582 | if (node->color != N_COLOR) |
342b8b6e | 583 | fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (node->color)); |
ce4d5ce0 | 584 | if (node->textcolor != N_TEXTCOLOR) |
342b8b6e AD |
585 | fprintf (fout, "\t\ttextcolor:\t%s\n", |
586 | get_color_str (node->textcolor)); | |
ce4d5ce0 | 587 | if (node->bordercolor != N_BORDERCOLOR) |
342b8b6e AD |
588 | fprintf (fout, "\t\tbordercolor:\t%s\n", |
589 | get_color_str (node->bordercolor)); | |
3e3da797 | 590 | |
08a946e0 AD |
591 | { |
592 | int i; | |
593 | for (i = 0; i < 3; ++i) | |
594 | if (node->infos[i]) | |
595 | fprintf (fout, "\t\tinfo%d:\t%s\n", | |
596 | i, quote (node->infos[i])); | |
597 | } | |
ce4d5ce0 AD |
598 | } |
599 | ||
600 | void | |
342b8b6e | 601 | output_edge (edge_t *edge, FILE *fout) |
ce4d5ce0 | 602 | { |
600cad3b MA |
603 | /* FIXME: SOURCENAME and TARGETNAME are mandatory |
604 | so it has to be fatal not to give these informations. */ | |
ce4d5ce0 | 605 | if (edge->sourcename != E_SOURCENAME) |
08a946e0 | 606 | fprintf (fout, "\t\tsourcename:\t%s\n", quote (edge->sourcename)); |
ce4d5ce0 | 607 | if (edge->targetname != E_TARGETNAME) |
08a946e0 | 608 | fprintf (fout, "\t\ttargetname:\t%s\n", quote (edge->targetname)); |
3e3da797 | 609 | |
ce4d5ce0 | 610 | if (edge->label != E_LABEL) |
08a946e0 | 611 | fprintf (fout, "\t\tlabel:\t%s\n", quote (edge->label)); |
ce4d5ce0 AD |
612 | |
613 | if (edge->linestyle != E_LINESTYLE) | |
08a946e0 AD |
614 | fprintf (fout, "\t\tlinestyle:\t%s\n", |
615 | quote (get_linestyle_str(edge->linestyle))); | |
3e3da797 | 616 | |
ce4d5ce0 | 617 | if (edge->thickness != E_THICKNESS) |
342b8b6e | 618 | fprintf (fout, "\t\tthickness:\t%d\n", edge->thickness); |
ce4d5ce0 | 619 | if (edge->class != E_CLASS) |
342b8b6e | 620 | fprintf (fout, "\t\tclass:\t%d\n", edge->class); |
ce4d5ce0 AD |
621 | |
622 | if (edge->color != E_COLOR) | |
342b8b6e | 623 | fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (edge->color)); |
ce4d5ce0 | 624 | if (edge->color != E_TEXTCOLOR) |
342b8b6e AD |
625 | fprintf (fout, "\t\ttextcolor:\t%s\n", |
626 | get_color_str (edge->textcolor)); | |
ce4d5ce0 | 627 | if (edge->arrowcolor != E_ARROWCOLOR) |
342b8b6e AD |
628 | fprintf (fout, "\t\tarrowcolor:\t%s\n", |
629 | get_color_str (edge->arrowcolor)); | |
ce4d5ce0 | 630 | if (edge->backarrowcolor != E_BACKARROWCOLOR) |
342b8b6e AD |
631 | fprintf (fout, "\t\tbackarrowcolor:\t%s\n", |
632 | get_color_str (edge->backarrowcolor)); | |
ce4d5ce0 AD |
633 | |
634 | if (edge->arrowsize != E_ARROWSIZE) | |
342b8b6e | 635 | fprintf (fout, "\t\tarrowsize:\t%d\n", edge->arrowsize); |
ce4d5ce0 | 636 | if (edge->backarrowsize != E_BACKARROWSIZE) |
342b8b6e | 637 | fprintf (fout, "\t\tbackarrowsize:\t%d\n", edge->backarrowsize); |
3e3da797 | 638 | |
ce4d5ce0 | 639 | if (edge->arrowstyle != E_ARROWSTYLE) |
342b8b6e AD |
640 | fprintf (fout, "\t\tarrowstyle:\t%s\n", |
641 | get_arrowstyle_str(edge->arrowstyle)); | |
ce4d5ce0 | 642 | if (edge->backarrowstyle != E_BACKARROWSTYLE) |
342b8b6e AD |
643 | fprintf (fout, "\t\tbackarrowstyle:\t%s\n", |
644 | get_arrowstyle_str(edge->backarrowstyle)); | |
3e3da797 | 645 | |
ce4d5ce0 | 646 | if (edge->priority != E_PRIORITY) |
342b8b6e | 647 | fprintf (fout, "\t\tpriority:\t%d\n", edge->priority); |
ce4d5ce0 | 648 | if (edge->anchor != E_ANCHOR) |
342b8b6e | 649 | fprintf (fout, "\t\tanchor:\t%d\n", edge->anchor); |
ce4d5ce0 | 650 | if (edge->horizontal_order != E_HORIZONTAL_ORDER) |
342b8b6e | 651 | fprintf (fout, "\t\thorizontal_order:\t%d\n", edge->horizontal_order); |
ce4d5ce0 AD |
652 | } |
653 | ||
654 | void | |
342b8b6e | 655 | output_graph (graph_t *graph, FILE *fout) |
ce4d5ce0 AD |
656 | { |
657 | if (graph->title) | |
08a946e0 | 658 | fprintf (fout, "\ttitle:\t%s\n", quote (graph->title)); |
ce4d5ce0 | 659 | if (graph->label) |
08a946e0 | 660 | fprintf (fout, "\tlabel:\t%s\n", quote (graph->label)); |
3e3da797 | 661 | |
08a946e0 AD |
662 | { |
663 | int i; | |
664 | for (i = 0; i < 3; ++i) | |
665 | if (graph->infos[i]) | |
666 | fprintf (fout, "\tinfo%d:\t%s\n", i, quote (graph->infos[i])); | |
667 | } | |
3e3da797 | 668 | |
ce4d5ce0 | 669 | if (graph->color != G_COLOR) |
342b8b6e | 670 | fprintf (fout, "\tcolor:\t%s\n", get_color_str (graph->color)); |
ce4d5ce0 | 671 | if (graph->textcolor != G_TEXTCOLOR) |
342b8b6e | 672 | fprintf (fout, "\ttextcolor:\t%s\n", get_color_str (graph->textcolor)); |
ce4d5ce0 | 673 | if (graph->bordercolor != G_BORDERCOLOR) |
342b8b6e AD |
674 | fprintf (fout, "\tbordercolor:\t%s\n", |
675 | get_color_str (graph->bordercolor)); | |
3e3da797 | 676 | |
ce4d5ce0 | 677 | if (graph->width != G_WIDTH) |
342b8b6e | 678 | fprintf (fout, "\twidth:\t%d\n", graph->width); |
ce4d5ce0 | 679 | if (graph->height != G_HEIGHT) |
342b8b6e | 680 | fprintf (fout, "\theight:\t%d\n", graph->height); |
ce4d5ce0 | 681 | if (graph->borderwidth != G_BORDERWIDTH) |
342b8b6e | 682 | fprintf (fout, "\tborderwidth:\t%d\n", graph->borderwidth); |
3e3da797 | 683 | |
ce4d5ce0 | 684 | if (graph->x != G_X) |
342b8b6e | 685 | fprintf (fout, "\tx:\t%d\n", graph->x); |
ce4d5ce0 | 686 | if (graph->y != G_Y) |
342b8b6e | 687 | fprintf (fout, "\ty:\t%d\n", graph->y); |
ce4d5ce0 AD |
688 | |
689 | if (graph->folding != G_FOLDING) | |
342b8b6e | 690 | fprintf (fout, "\tfolding:\t%d\n", graph->folding); |
ce4d5ce0 AD |
691 | |
692 | if (graph->shrink != G_SHRINK) | |
342b8b6e | 693 | fprintf (fout, "\tshrink:\t%d\n", graph->shrink); |
ce4d5ce0 | 694 | if (graph->stretch != G_STRETCH) |
342b8b6e | 695 | fprintf (fout, "\tstretch:\t%d\n", graph->stretch); |
3e3da797 | 696 | |
ce4d5ce0 | 697 | if (graph->textmode != G_TEXTMODE) |
342b8b6e AD |
698 | fprintf (fout, "\ttextmode:\t%s\n", |
699 | get_textmode_str (graph->textmode)); | |
3e3da797 | 700 | |
ce4d5ce0 | 701 | if (graph->shape != G_SHAPE) |
342b8b6e | 702 | fprintf (fout, "\tshape:\t%s\n", get_shape_str (graph->shape)); |
08a946e0 | 703 | |
342b8b6e | 704 | if (graph->vertical_order != G_VERTICAL_ORDER) |
08a946e0 | 705 | fprintf (fout, "\tvertical_order:\t%d\n", graph->vertical_order); |
342b8b6e | 706 | if (graph->horizontal_order != G_HORIZONTAL_ORDER) |
08a946e0 | 707 | fprintf (fout, "\thorizontal_order:\t%d\n", graph->horizontal_order); |
3e3da797 | 708 | |
ce4d5ce0 | 709 | if (graph->xmax != G_XMAX) |
342b8b6e | 710 | fprintf (fout, "\txmax:\t%d\n", graph->xmax); |
ce4d5ce0 | 711 | if (graph->ymax != G_YMAX) |
342b8b6e | 712 | fprintf (fout, "\tymax:\t%d\n", graph->ymax); |
3e3da797 | 713 | |
ce4d5ce0 | 714 | if (graph->xbase != G_XBASE) |
342b8b6e | 715 | fprintf (fout, "\txbase:\t%d\n", graph->xbase); |
ce4d5ce0 | 716 | if (graph->ybase != G_YBASE) |
342b8b6e | 717 | fprintf (fout, "\tybase:\t%d\n", graph->ybase); |
ce4d5ce0 AD |
718 | |
719 | if (graph->xspace != G_XSPACE) | |
342b8b6e | 720 | fprintf (fout, "\txspace:\t%d\n", graph->xspace); |
ce4d5ce0 | 721 | if (graph->yspace != G_YSPACE) |
342b8b6e | 722 | fprintf (fout, "\tyspace:\t%d\n", graph->yspace); |
ce4d5ce0 | 723 | if (graph->xlspace != G_XLSPACE) |
342b8b6e | 724 | fprintf (fout, "\txlspace:\t%d\n", graph->xlspace); |
3e3da797 | 725 | |
ce4d5ce0 | 726 | if (graph->xraster != G_XRASTER) |
342b8b6e | 727 | fprintf (fout, "\txraster:\t%d\n", graph->xraster); |
ce4d5ce0 | 728 | if (graph->yraster != G_YRASTER) |
342b8b6e | 729 | fprintf (fout, "\tyraster:\t%d\n", graph->yraster); |
ce4d5ce0 | 730 | if (graph->xlraster != G_XLRASTER) |
342b8b6e | 731 | fprintf (fout, "\txlraster:\t%d\n", graph->xlraster); |
ce4d5ce0 AD |
732 | |
733 | if (graph->hidden != G_HIDDEN) | |
342b8b6e | 734 | fprintf (fout, "\thidden:\t%d\n", graph->hidden); |
08a946e0 AD |
735 | |
736 | /* FIXME: Unallocate struct list if required. | |
342b8b6e | 737 | Maybe with a little function. */ |
ce4d5ce0 AD |
738 | if (graph->classname != G_CLASSNAME) |
739 | { | |
740 | struct classname_s *ite; | |
3e3da797 | 741 | |
ce4d5ce0 | 742 | for (ite = graph->classname; ite; ite = ite->next) |
342b8b6e AD |
743 | fprintf (fout, "\tclassname %d :\t%s\n", ite->no, ite->name); |
744 | } | |
745 | ||
746 | if (graph->infoname != G_INFONAME) | |
747 | { | |
748 | struct infoname_s *ite; | |
749 | ||
750 | for (ite = graph->infoname; ite; ite = ite->next) | |
751 | fprintf (fout, "\tinfoname %d :\t%s\n", ite->integer, ite->string); | |
752 | } | |
753 | ||
754 | if (graph->colorentry != G_COLORENTRY) | |
755 | { | |
756 | struct colorentry_s *ite; | |
08a946e0 | 757 | |
342b8b6e | 758 | for (ite = graph->colorentry; ite; ite = ite->next) |
08a946e0 AD |
759 | { |
760 | fprintf (fout, "\tcolorentry %d :\t%d %d %d\n", | |
761 | ite->color_index, | |
342b8b6e AD |
762 | ite->red_cp, |
763 | ite->green_cp, | |
764 | ite->blue_cp); | |
08a946e0 | 765 | } |
ce4d5ce0 | 766 | } |
3e3da797 | 767 | |
ce4d5ce0 | 768 | if (graph->layoutalgorithm != G_LAYOUTALGORITHM) |
342b8b6e AD |
769 | fprintf (fout, "\tlayoutalgorithm:\t%s\n", |
770 | get_layoutalgorithm_str(graph->layoutalgorithm)); | |
3e3da797 | 771 | |
ce4d5ce0 | 772 | if (graph->layout_downfactor != G_LAYOUT_DOWNFACTOR) |
342b8b6e | 773 | fprintf (fout, "\tlayout_downfactor:\t%d\n", graph->layout_downfactor); |
ce4d5ce0 | 774 | if (graph->layout_upfactor != G_LAYOUT_UPFACTOR) |
342b8b6e | 775 | fprintf (fout, "\tlayout_upfactor:\t%d\n", graph->layout_upfactor); |
ce4d5ce0 | 776 | if (graph->layout_nearfactor != G_LAYOUT_NEARFACTOR) |
342b8b6e | 777 | fprintf (fout, "\tlayout_nearfactor:\t%d\n", graph->layout_nearfactor); |
ce4d5ce0 | 778 | if (graph->layout_splinefactor != G_LAYOUT_SPLINEFACTOR) |
342b8b6e AD |
779 | fprintf (fout, "\tlayout_splinefactor:\t%d\n", |
780 | graph->layout_splinefactor); | |
3e3da797 | 781 | |
ce4d5ce0 | 782 | if (graph->late_edge_labels != G_LATE_EDGE_LABELS) |
342b8b6e AD |
783 | fprintf (fout, "\tlate_edge_labels:\t%s\n", |
784 | get_decision_str(graph->late_edge_labels)); | |
ce4d5ce0 | 785 | if (graph->display_edge_labels != G_DISPLAY_EDGE_LABELS) |
342b8b6e AD |
786 | fprintf (fout, "\tdisplay_edge_labels:\t%s\n", |
787 | get_decision_str(graph->display_edge_labels)); | |
ce4d5ce0 | 788 | if (graph->dirty_edge_labels != G_DIRTY_EDGE_LABELS) |
342b8b6e AD |
789 | fprintf (fout, "\tdirty_edge_labels:\t%s\n", |
790 | get_decision_str(graph->dirty_edge_labels)); | |
ce4d5ce0 | 791 | if (graph->finetuning != G_FINETUNING) |
342b8b6e AD |
792 | fprintf (fout, "\tfinetuning:\t%s\n", |
793 | get_decision_str(graph->finetuning)); | |
ce4d5ce0 | 794 | if (graph->ignore_singles != G_IGNORE_SINGLES) |
342b8b6e AD |
795 | fprintf (fout, "\tignore_singles:\t%s\n", |
796 | get_decision_str(graph->ignore_singles)); | |
ce4d5ce0 | 797 | if (graph->straight_phase != G_STRAIGHT_PHASE) |
342b8b6e AD |
798 | fprintf (fout, "\tstraight_phase:\t%s\n", |
799 | get_decision_str(graph->straight_phase)); | |
ce4d5ce0 | 800 | if (graph->priority_phase != G_PRIORITY_PHASE) |
342b8b6e AD |
801 | fprintf (fout, "\tpriority_phase:\t%s\n", |
802 | get_decision_str(graph->priority_phase)); | |
ce4d5ce0 | 803 | if (graph->manhattan_edges != G_MANHATTAN_EDGES) |
342b8b6e AD |
804 | fprintf (fout, |
805 | "\tmanhattan_edges:\t%s\n", | |
806 | get_decision_str(graph->manhattan_edges)); | |
ce4d5ce0 | 807 | if (graph->smanhattan_edges != G_SMANHATTAN_EDGES) |
342b8b6e AD |
808 | fprintf (fout, |
809 | "\tsmanhattan_edges:\t%s\n", | |
810 | get_decision_str(graph->smanhattan_edges)); | |
ce4d5ce0 | 811 | if (graph->near_edges != G_NEAR_EDGES) |
342b8b6e AD |
812 | fprintf (fout, "\tnear_edges:\t%s\n", |
813 | get_decision_str(graph->near_edges)); | |
3e3da797 | 814 | |
ce4d5ce0 | 815 | if (graph->orientation != G_ORIENTATION) |
342b8b6e AD |
816 | fprintf (fout, "\torientation:\t%s\n", |
817 | get_orientation_str(graph->orientation)); | |
3e3da797 | 818 | |
ce4d5ce0 | 819 | if (graph->node_alignement != G_NODE_ALIGNEMENT) |
342b8b6e AD |
820 | fprintf (fout, "\tnode_alignement:\t%s\n", |
821 | get_node_alignement_str(graph->node_alignement)); | |
3e3da797 | 822 | |
ce4d5ce0 | 823 | if (graph->port_sharing != G_PORT_SHARING) |
342b8b6e AD |
824 | fprintf (fout, "\tport_sharing:\t%s\n", |
825 | get_decision_str(graph->port_sharing)); | |
3e3da797 | 826 | |
ce4d5ce0 | 827 | if (graph->arrow_mode != G_ARROW_MODE) |
342b8b6e AD |
828 | fprintf (fout, "\tarrow_mode:\t%s\n", |
829 | get_arrow_mode_str(graph->arrow_mode)); | |
3e3da797 | 830 | |
ce4d5ce0 | 831 | if (graph->treefactor != G_TREEFACTOR) |
342b8b6e | 832 | fprintf (fout, "\ttreefactor:\t%f\n", graph->treefactor); |
ce4d5ce0 | 833 | if (graph->spreadlevel != G_SPREADLEVEL) |
342b8b6e | 834 | fprintf (fout, "\tspreadlevel:\t%d\n", graph->spreadlevel); |
3e3da797 | 835 | |
ce4d5ce0 | 836 | if (graph->crossing_weight != G_CROSSING_WEIGHT) |
342b8b6e AD |
837 | fprintf (fout, "\tcrossing_weight:\t%s\n", |
838 | get_crossing_type_str(graph->crossing_weight)); | |
ce4d5ce0 | 839 | if (graph->crossing_phase2 != G_CROSSING_PHASE2) |
342b8b6e AD |
840 | fprintf (fout, "\tcrossing_phase2:\t%s\n", |
841 | get_decision_str(graph->crossing_phase2)); | |
ce4d5ce0 | 842 | if (graph->crossing_optimization != G_CROSSING_OPTIMIZATION) |
342b8b6e AD |
843 | fprintf (fout, "\tcrossing_optimization:\t%s\n", |
844 | get_decision_str(graph->crossing_optimization)); | |
3e3da797 | 845 | |
ce4d5ce0 | 846 | if (graph->view != G_VIEW) |
342b8b6e | 847 | fprintf (fout, "\tview:\t%s\n", get_view_str(graph->view)); |
3e3da797 | 848 | |
ce4d5ce0 | 849 | if (graph->edges != G_EDGES) |
342b8b6e | 850 | fprintf (fout, "\tedges:\t%s\n", get_decision_str(graph->edges)); |
3e3da797 | 851 | |
ce4d5ce0 | 852 | if (graph->nodes != G_NODES) |
342b8b6e | 853 | fprintf (fout,"\tnodes:\t%s\n", get_decision_str(graph->nodes)); |
3e3da797 | 854 | |
ce4d5ce0 | 855 | if (graph->splines != G_SPLINES) |
342b8b6e | 856 | fprintf (fout, "\tsplines:\t%s\n", get_decision_str(graph->splines)); |
3e3da797 | 857 | |
ce4d5ce0 | 858 | if (graph->bmax != G_BMAX) |
342b8b6e | 859 | fprintf (fout, "\tbmax:\t%d\n", graph->bmax); |
ce4d5ce0 | 860 | if (graph->cmin != G_CMIN) |
342b8b6e | 861 | fprintf (fout, "\tcmin:\t%d\n", graph->cmin); |
ce4d5ce0 | 862 | if (graph->cmax != G_CMAX) |
342b8b6e | 863 | fprintf (fout, "\tcmax:\t%d\n", graph->cmax); |
ce4d5ce0 | 864 | if (graph->pmin != G_PMIN) |
342b8b6e | 865 | fprintf (fout, "\tpmin:\t%d\n", graph->pmin); |
ce4d5ce0 | 866 | if (graph->pmax != G_PMAX) |
342b8b6e | 867 | fprintf (fout, "\tpmax:\t%d\n", graph->pmax); |
ce4d5ce0 | 868 | if (graph->rmin != G_RMIN) |
342b8b6e | 869 | fprintf (fout, "\trmin:\t%d\n", graph->rmin); |
ce4d5ce0 | 870 | if (graph->rmax != G_RMAX) |
342b8b6e | 871 | fprintf (fout, "\trmax:\t%d\n", graph->rmax); |
ce4d5ce0 | 872 | if (graph->smax != G_SMAX) |
342b8b6e | 873 | fprintf (fout, "\tsmax:\t%d\n", graph->smax); |
ce4d5ce0 | 874 | } |