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