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