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