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