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