Graphviz 16.1.3~dev.20261121.1645
Loading...
Searching...
No Matches
postproc.c
Go to the documentation of this file.
1
3/*************************************************************************
4 * Copyright (c) 2011 AT&T Intellectual Property
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v2.0
7 * which accompanies this distribution, and is available at
8 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
9 *
10 * Contributors: Details at https://graphviz.org
11 *************************************************************************/
12
13#include "config.h"
14
15#include <common/render.h>
16#include <float.h>
17#include <label/xlabels.h>
18#include <stdbool.h>
19#include <stddef.h>
20#include <util/agxbuf.h>
21#include <util/alloc.h>
22#include <util/list.h>
23#include <util/prisize_t.h>
24#include <util/unreachable.h>
25
26static int Rankdir;
27static bool Flip;
29
30static void place_flip_graph_label(graph_t *g);
31
32#define M1 \
33 "/pathbox {\n\
34 /Y exch %.5g sub def\n\
35 /X exch %.5g sub def\n\
36 /y exch %.5g sub def\n\
37 /x exch %.5g sub def\n\
38 newpath x y moveto\n\
39 X y lineto\n\
40 X Y lineto\n\
41 x Y lineto\n\
42 closepath stroke\n \
43} def\n\
44/dbgstart { gsave %.5g %.5g translate } def\n\
45/arrowlength 10 def\n\
46/arrowwidth arrowlength 2 div def\n\
47/arrowhead {\n\
48 gsave\n\
49 rotate\n\
50 currentpoint\n\
51 newpath\n\
52 moveto\n\
53 arrowlength arrowwidth 2 div rlineto\n\
54 0 arrowwidth neg rlineto\n\
55 closepath fill\n\
56 grestore\n\
57} bind def\n\
58/makearrow {\n\
59 currentpoint exch pop sub exch currentpoint pop sub atan\n\
60 arrowhead\n\
61} bind def\n\
62/point {\
63 newpath\
64 2 0 360 arc fill\
65} def\
66/makevec {\n\
67 /Y exch def\n\
68 /X exch def\n\
69 /y exch def\n\
70 /x exch def\n\
71 newpath x y moveto\n\
72 X Y lineto stroke\n\
73 X Y moveto\n\
74 x y makearrow\n\
75} def\n"
76
77#define M2 \
78 "/pathbox {\n\
79 /X exch neg %.5g sub def\n\
80 /Y exch %.5g sub def\n\
81 /x exch neg %.5g sub def\n\
82 /y exch %.5g sub def\n\
83 newpath x y moveto\n\
84 X y lineto\n\
85 X Y lineto\n\
86 x Y lineto\n\
87 closepath stroke\n\
88} def\n"
89
91 p = ccwrotatepf(p, Rankdir * 90);
92 p.x -= Offset.x;
93 p.y -= Offset.y;
94 return p;
95}
96
97static void map_edge(edge_t *e) {
98 bezier bz;
99
100 if (ED_spl(e) == NULL) {
101 if (!Concentrate && ED_edge_type(e) != IGNORED)
102 agerrorf("lost %s %s edge\n", agnameof(agtail(e)), agnameof(aghead(e)));
103 return;
104 }
105 for (size_t j = 0; j < ED_spl(e)->size; j++) {
106 bz = ED_spl(e)->list[j];
107 for (size_t k = 0; k < bz.size; k++)
108 bz.list[k] = map_point(bz.list[k]);
109 if (bz.sflag)
110 ED_spl(e)->list[j].sp = map_point(ED_spl(e)->list[j].sp);
111 if (bz.eflag)
112 ED_spl(e)->list[j].ep = map_point(ED_spl(e)->list[j].ep);
113 }
114 if (ED_label(e))
115 ED_label(e)->pos = map_point(ED_label(e)->pos);
116 if (ED_xlabel(e))
117 ED_xlabel(e)->pos = map_point(ED_xlabel(e)->pos);
118 if (ED_head_label(e))
119 ED_head_label(e)->pos = map_point(ED_head_label(e)->pos);
120 if (ED_tail_label(e))
121 ED_tail_label(e)->pos = map_point(ED_tail_label(e)->pos);
122}
123
124void translate_bb(graph_t *g, int rankdir) {
125 int c;
126 boxf bb, new_bb;
127
128 bb = GD_bb(g);
129 if (rankdir == RANKDIR_LR || rankdir == RANKDIR_BT) {
130 new_bb.LL = map_point((pointf){bb.LL.x, bb.UR.y});
131 new_bb.UR = map_point((pointf){bb.UR.x, bb.LL.y});
132 } else {
133 new_bb.LL = map_point((pointf){bb.LL.x, bb.LL.y});
134 new_bb.UR = map_point((pointf){bb.UR.x, bb.UR.y});
135 }
136 GD_bb(g) = new_bb;
137 if (GD_label(g)) {
138 GD_label(g)->pos = map_point(GD_label(g)->pos);
139 }
140 for (c = 1; c <= GD_n_cluster(g); c++)
141 translate_bb(GD_clust(g)[c], rankdir);
142}
143
144/* translate_drawing:
145 * Translate and/or rotate nodes, spline points, and bbox info if
146 * necessary. Also, if Rankdir (!= RANKDIR_BT), reset ND_lw, ND_rw,
147 * and ND_ht to correct value.
148 */
149static void translate_drawing(graph_t *g) {
150 node_t *v;
151 edge_t *e;
152 bool shift = Offset.x || Offset.y;
153
154 if (!shift && !Rankdir)
155 return;
156 for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
157 if (Rankdir)
158 gv_nodesize(v, false);
159 ND_coord(v) = map_point(ND_coord(v));
160 if (ND_xlabel(v))
161 ND_xlabel(v)->pos = map_point(ND_xlabel(v)->pos);
162 if (State == GVSPLINES)
163 for (e = agfstout(g, v); e; e = agnxtout(g, e))
164 map_edge(e);
165 }
167}
168
169/* place_root_label:
170 * Set position of root graph label.
171 * Note that at this point, after translate_drawing, a
172 * flipped drawing has been transposed, so we don't have
173 * to worry about switching x and y.
174 */
175static void place_root_label(graph_t *g, pointf d) {
176 pointf p;
177
178 if (GD_label_pos(g) & LABEL_AT_RIGHT) {
179 p.x = GD_bb(g).UR.x - d.x / 2;
180 } else if (GD_label_pos(g) & LABEL_AT_LEFT) {
181 p.x = GD_bb(g).LL.x + d.x / 2;
182 } else {
183 p.x = (GD_bb(g).LL.x + GD_bb(g).UR.x) / 2;
184 }
185
186 if (GD_label_pos(g) & LABEL_AT_TOP) {
187 p.y = GD_bb(g).UR.y - d.y / 2;
188 } else {
189 p.y = GD_bb(g).LL.y + d.y / 2;
190 }
191
192 GD_label(g)->pos = p;
193 GD_label(g)->set = true;
194}
195
196/* centerPt:
197 * Calculate the center point of the xlabel. The returned positions for
198 * xlabels always correspond to the lower left corner.
199 */
201 pointf p;
202
203 p = xlp->pos;
204 p.x += xlp->sz.x / 2.0;
205 p.y += xlp->sz.y / 2.0;
206
207 return p;
208}
209
210static void printData(object_t *objs, size_t n_objs, xlabel_t *lbls,
211 size_t n_lbls, label_params_t *params) {
212 xlabel_t *xp;
213 fprintf(stderr,
214 "%" PRISIZE_T " objs %" PRISIZE_T
215 " xlabels force=%d bb=(%.02f,%.02f) (%.02f,%.02f)\n",
216 n_objs, n_lbls, (int)params->force, params->bb.LL.x, params->bb.LL.y,
217 params->bb.UR.x, params->bb.UR.y);
218 if (Verbose < 2)
219 return;
220 fprintf(stderr, "objects\n");
221 for (size_t i = 0; i < n_objs; i++) {
222 xp = objs->lbl;
223 fprintf(stderr, " [%" PRISIZE_T "] (%.02f,%.02f) (%.02f,%.02f) %p \"%s\"\n",
224 i, objs->pos.x, objs->pos.y, objs->sz.x, objs->sz.y, objs->lbl,
225 xp ? xp->lbl->text : "");
226 objs++;
227 }
228 fprintf(stderr, "xlabels\n");
229 for (size_t i = 0; i < n_lbls; i++) {
230 fprintf(stderr,
231 " [%" PRISIZE_T "] %p set %d (%.02f,%.02f) (%.02f,%.02f) %s\n", i,
232 lbls, (int)lbls->set, lbls->pos.x, lbls->pos.y, lbls->sz.x,
233 lbls->sz.y, lbls->lbl->text);
234 lbls++;
235 }
236}
237
239 splines *spl;
240 bezier *bez;
241
242 if ((spl = getsplinepoints(e)) == NULL) {
243 pointf p;
244 p.x = p.y = 0;
245 return p;
246 }
247 bez = &spl->list[0];
248 if (bez->sflag) {
249 return bez->sp;
250 } else {
251 return bez->list[0];
252 }
253}
254
256 splines *spl;
257 bezier *bez;
258
259 if ((spl = getsplinepoints(e)) == NULL) {
260 pointf p;
261 p.x = p.y = 0;
262 return p;
263 }
264 bez = &spl->list[spl->size - 1];
265 if (bez->eflag) {
266 return bez->ep;
267 } else {
268 return bez->list[bez->size - 1];
269 }
270}
271
272/* adjustBB:
273 */
274static boxf adjustBB(object_t *objp, boxf bb) {
275 pointf ur;
276
277 /* Adjust bounding box */
278 bb.LL.x = MIN(bb.LL.x, objp->pos.x);
279 bb.LL.y = MIN(bb.LL.y, objp->pos.y);
280 ur.x = objp->pos.x + objp->sz.x;
281 ur.y = objp->pos.y + objp->sz.y;
282 bb.UR.x = MAX(bb.UR.x, ur.x);
283 bb.UR.y = MAX(bb.UR.y, ur.y);
284
285 return bb;
286}
287
288/* addXLabel:
289 * Set up xlabel_t object and connect with related object.
290 * If initObj is set, initialize the object.
291 */
292static void addXLabel(textlabel_t *lp, object_t *objp, xlabel_t *xlp,
293 int initObj, pointf pos) {
294 if (initObj) {
295 *objp = (object_t){.pos = pos};
296 }
297
298 if (Flip) {
299 xlp->sz.x = lp->dimen.y;
300 xlp->sz.y = lp->dimen.x;
301 } else {
302 xlp->sz = lp->dimen;
303 }
304 xlp->lbl = lp;
305 xlp->set = false;
306 objp->lbl = xlp;
307}
308
309/* addLabelObj:
310 * Set up obstacle object based on set external label.
311 * This includes dot edge labels.
312 * Use label information to determine size and position of object.
313 * Then adjust given bounding box bb to include label and return new bb.
314 */
315static boxf addLabelObj(textlabel_t *lp, object_t *objp, boxf bb) {
316 if (Flip) {
317 objp->sz.x = lp->dimen.y;
318 objp->sz.y = lp->dimen.x;
319 } else {
320 objp->sz.x = lp->dimen.x;
321 objp->sz.y = lp->dimen.y;
322 }
323 objp->pos = lp->pos;
324 objp->pos.x -= objp->sz.x / 2.0;
325 objp->pos.y -= objp->sz.y / 2.0;
326
327 return adjustBB(objp, bb);
328}
329
330/* addNodeOjb:
331 * Set up obstacle object based on a node.
332 * Use node information to determine size and position of object.
333 * Then adjust given bounding box bb to include label and return new bb.
334 */
335static boxf addNodeObj(node_t *np, object_t *objp, boxf bb) {
336 if (Flip) {
337 objp->sz.x = INCH2PS(ND_height(np));
338 objp->sz.y = INCH2PS(ND_width(np));
339 } else {
340 objp->sz.x = INCH2PS(ND_width(np));
341 objp->sz.y = INCH2PS(ND_height(np));
342 }
343 objp->pos = ND_coord(np);
344 objp->pos.x -= objp->sz.x / 2.0;
345 objp->pos.y -= objp->sz.y / 2.0;
346
347 return adjustBB(objp, bb);
348}
349
350typedef struct {
353} cinfo_t;
354
356 int c;
357
358 for (c = 1; c <= GD_n_cluster(g); c++)
360 if (g != agroot(g) && GD_label(g) && GD_label(g)->set) {
361 object_t *objp = info.objp;
362 info.bb = addLabelObj(GD_label(g), objp, info.bb);
363 info.objp++;
364 }
365
366 return info;
367}
368
369static size_t countClusterLabels(Agraph_t *g) {
370 size_t i = 0;
371 if (g != agroot(g) && GD_label(g) && GD_label(g)->set)
372 i++;
373 for (int c = 1; c <= GD_n_cluster(g); c++)
374 i += countClusterLabels(GD_clust(g)[c]);
375 return i;
376}
377
378/* True if edges geometries were computed and this edge has a geometry */
379#define HAVE_EDGE(ep) ((et != EDGETYPE_NONE) && (ED_spl(ep) != NULL))
380
385static void addXLabels(Agraph_t *gp) {
386 Agnode_t *np;
387 Agedge_t *ep;
388 size_t n_nlbls = 0; // # of unset node xlabels
389 size_t n_elbls = 0; // # of unset edge labels or xlabels
390 size_t n_set_lbls = 0; // # of set xlabels and edge labels
391 size_t n_clbls = 0; // # of set cluster labels
392 boxf bb;
393 textlabel_t *lp;
394 object_t *objs;
395 xlabel_t *lbls;
396 Agsym_t *force;
397 int et = EDGE_TYPE(gp);
398
399 if (!(GD_has_labels(gp) & NODE_XLABEL) &&
400 !(GD_has_labels(gp) & EDGE_XLABEL) && !(GD_has_labels(gp) & TAIL_LABEL) &&
401 !(GD_has_labels(gp) & HEAD_LABEL) &&
403 return;
404
405 for (np = agfstnode(gp); np; np = agnxtnode(gp, np)) {
406 if (ND_xlabel(np)) {
407 if (ND_xlabel(np)->set)
408 n_set_lbls++;
409 else
410 n_nlbls++;
411 }
412 for (ep = agfstout(gp, np); ep; ep = agnxtout(gp, ep)) {
413 if (ED_xlabel(ep)) {
414 if (ED_xlabel(ep)->set)
415 n_set_lbls++;
416 else if (HAVE_EDGE(ep))
417 n_elbls++;
418 }
419 if (ED_head_label(ep)) {
420 if (ED_head_label(ep)->set)
421 n_set_lbls++;
422 else if (HAVE_EDGE(ep))
423 n_elbls++;
424 }
425 if (ED_tail_label(ep)) {
426 if (ED_tail_label(ep)->set)
427 n_set_lbls++;
428 else if (HAVE_EDGE(ep))
429 n_elbls++;
430 }
431 if (ED_label(ep)) {
432 if (ED_label(ep)->set)
433 n_set_lbls++;
434 else if (HAVE_EDGE(ep))
435 n_elbls++;
436 }
437 }
438 }
439 if (GD_has_labels(gp) & GRAPH_LABEL)
440 n_clbls = countClusterLabels(gp);
441
442 /* A label for each unpositioned external label */
443 size_t n_lbls = n_nlbls + n_elbls;
444 if (n_lbls == 0)
445 return;
446
447 /* An object for each node, each positioned external label, any cluster label,
448 * and all unset edge labels and xlabels.
449 */
450 size_t n_objs = agnnodes_z(gp) + n_set_lbls + n_clbls + n_elbls;
451 object_t *objp = objs = gv_calloc(n_objs, sizeof(object_t));
452 xlabel_t *xlp = lbls = gv_calloc(n_lbls, sizeof(xlabel_t));
453 bb.LL = (pointf){DBL_MAX, DBL_MAX};
454 bb.UR = (pointf){-DBL_MAX, -DBL_MAX};
455
456 for (np = agfstnode(gp); np; np = agnxtnode(gp, np)) {
457
458 bb = addNodeObj(np, objp, bb);
459 if ((lp = ND_xlabel(np))) {
460 if (lp->set) {
461 objp++;
462 bb = addLabelObj(lp, objp, bb);
463 } else {
464 pointf ignored = {0.0, 0.0};
465 addXLabel(lp, objp, xlp, 0, ignored);
466 xlp++;
467 }
468 }
469 objp++;
470 for (ep = agfstout(gp, np); ep; ep = agnxtout(gp, ep)) {
471 if ((lp = ED_label(ep))) {
472 if (lp->set) {
473 bb = addLabelObj(lp, objp, bb);
474 } else if (HAVE_EDGE(ep)) {
475 addXLabel(lp, objp, xlp, 1, edgeMidpoint(gp, ep));
476 xlp++;
477 } else {
478 agwarningf("no position for edge with label %s\n",
479 ED_label(ep)->text);
480 continue;
481 }
482 objp++;
483 }
484 if ((lp = ED_tail_label(ep))) {
485 if (lp->set) {
486 bb = addLabelObj(lp, objp, bb);
487 } else if (HAVE_EDGE(ep)) {
488 addXLabel(lp, objp, xlp, 1, edgeTailpoint(ep));
489 xlp++;
490 } else {
491 agwarningf("no position for edge with tail label %s\n",
492 ED_tail_label(ep)->text);
493 continue;
494 }
495 objp++;
496 }
497 if ((lp = ED_head_label(ep))) {
498 if (lp->set) {
499 bb = addLabelObj(lp, objp, bb);
500 } else if (HAVE_EDGE(ep)) {
501 addXLabel(lp, objp, xlp, 1, edgeHeadpoint(ep));
502 xlp++;
503 } else {
504 agwarningf("no position for edge with head label %s\n",
505 ED_head_label(ep)->text);
506 continue;
507 }
508 objp++;
509 }
510 if ((lp = ED_xlabel(ep))) {
511 if (lp->set) {
512 bb = addLabelObj(lp, objp, bb);
513 } else if (HAVE_EDGE(ep)) {
514 addXLabel(lp, objp, xlp, 1, edgeMidpoint(gp, ep));
515 xlp++;
516 } else {
517 agwarningf("no position for edge with xlabel %s\n",
518 ED_xlabel(ep)->text);
519 continue;
520 }
521 objp++;
522 }
523 }
524 }
525 if (n_clbls) {
527 info.bb = bb;
528 info.objp = objp;
529 info = addClusterObj(gp, info);
530 bb = info.bb;
531 }
532
533 force = agfindgraphattr(gp, "forcelabels");
534
535 label_params_t params = {.bb = bb, .force = late_bool(gp, force, true)};
536 placeLabels(objs, n_objs, &params);
537 if (Verbose)
538 printData(objs, n_objs, lbls, n_lbls, &params);
539
540 xlp = lbls;
541 size_t cnt = 0;
542 for (size_t i = 0; i < n_lbls; i++) {
543 if (xlp->set) {
544 cnt++;
545 lp = xlp->lbl;
546 lp->set = 1;
547 lp->pos = centerPt(xlp);
548 updateBB(gp, lp);
549 }
550 xlp++;
551 }
552 if (Verbose)
553 fprintf(stderr, "%" PRISIZE_T " out of %" PRISIZE_T " labels positioned.\n",
554 cnt, n_lbls);
555 else if (cnt != n_lbls)
556 agwarningf("%" PRISIZE_T " out of %" PRISIZE_T
557 " exterior labels positioned.\n",
558 cnt, n_lbls);
559 free(objs);
560 free(lbls);
561}
562
563/* gv_postprocess:
564 * Set graph and cluster label positions.
565 * Add space for root graph label and translate graph accordingly.
566 * Set final nodesize using ns.
567 * Assumes the boxes of all clusters have been computed.
568 * When done, the bounding box of g has LL at origin.
569 */
570void gv_postprocess(Agraph_t *g, int allowTranslation) {
571 pointf dimen = {0};
572
573 Rankdir = GD_rankdir(g);
574 Flip = GD_flip(g);
575 /* Handle cluster labels */
576 if (Flip)
578 else
580
581 /* Everything has been placed except the root graph label, if any.
582 * The graph positions have not yet been rotated back if necessary.
583 */
584 addXLabels(g);
585
586 /* Add space for graph label if necessary */
587 if (GD_label(g) && !GD_label(g)->set) {
588 dimen = GD_label(g)->dimen;
589 PAD(dimen);
590 if (Flip) {
591 if (GD_label_pos(g) & LABEL_AT_TOP) {
592 GD_bb(g).UR.x += dimen.y;
593 } else {
594 GD_bb(g).LL.x -= dimen.y;
595 }
596
597 if (dimen.x > GD_bb(g).UR.y - GD_bb(g).LL.y) {
598 const double diff = (dimen.x - (GD_bb(g).UR.y - GD_bb(g).LL.y)) / 2.0;
599 GD_bb(g).LL.y -= diff;
600 GD_bb(g).UR.y += diff;
601 }
602 } else {
603 if (GD_label_pos(g) & LABEL_AT_TOP) {
604 if (Rankdir == RANKDIR_TB)
605 GD_bb(g).UR.y += dimen.y;
606 else
607 GD_bb(g).LL.y -= dimen.y;
608 } else {
609 if (Rankdir == RANKDIR_TB)
610 GD_bb(g).LL.y -= dimen.y;
611 else
612 GD_bb(g).UR.y += dimen.y;
613 }
614
615 if (dimen.x > GD_bb(g).UR.x - GD_bb(g).LL.x) {
616 const double diff = (dimen.x - (GD_bb(g).UR.x - GD_bb(g).LL.x)) / 2.0;
617 GD_bb(g).LL.x -= diff;
618 GD_bb(g).UR.x += diff;
619 }
620 }
621 }
622 if (allowTranslation) {
623 switch (Rankdir) {
624 case RANKDIR_TB:
625 Offset = GD_bb(g).LL;
626 break;
627 case RANKDIR_LR:
628 Offset = (pointf){-GD_bb(g).UR.y, GD_bb(g).LL.x};
629 break;
630 case RANKDIR_BT:
631 Offset = (pointf){GD_bb(g).LL.x, -GD_bb(g).UR.y};
632 break;
633 case RANKDIR_RL:
634 Offset = (pointf){GD_bb(g).LL.y, GD_bb(g).LL.x};
635 break;
636 default:
637 UNREACHABLE();
638 }
640 }
641 if (GD_label(g) && !GD_label(g)->set)
642 place_root_label(g, dimen);
643
644 if (!LIST_IS_EMPTY(&Show_boxes)) {
645 agxbuf buf = {0};
646 if (Flip)
647 agxbprint(&buf, M2, Offset.x, Offset.y, Offset.x, Offset.y);
648 else
650 -Offset.y);
652 }
653}
654
655/* dotneato_postprocess:
656 */
658
659/* place_flip_graph_label:
660 * Put cluster labels recursively in the flip case.
661 */
663 int c;
664 pointf p, d;
665
666 if (g != agroot(g) && GD_label(g) && !GD_label(g)->set) {
667 if (GD_label_pos(g) & LABEL_AT_TOP) {
668 d = GD_border(g)[RIGHT_IX];
669 p.x = GD_bb(g).UR.x - d.x / 2;
670 } else {
671 d = GD_border(g)[LEFT_IX];
672 p.x = GD_bb(g).LL.x + d.x / 2;
673 }
674
675 if (GD_label_pos(g) & LABEL_AT_RIGHT) {
676 p.y = GD_bb(g).LL.y + d.y / 2;
677 } else if (GD_label_pos(g) & LABEL_AT_LEFT) {
678 p.y = GD_bb(g).UR.y - d.y / 2;
679 } else {
680 p.y = (GD_bb(g).LL.y + GD_bb(g).UR.y) / 2;
681 }
682 GD_label(g)->pos = p;
683 GD_label(g)->set = true;
684 }
685
686 for (c = 1; c <= GD_n_cluster(g); c++)
688}
689
690/* place_graph_label:
691 * Put cluster labels recursively in the non-flip case.
692 * The adjustments to the bounding boxes should no longer
693 * be necessary, since we now guarantee the label fits in
694 * the cluster.
695 */
697 int c;
698 pointf p, d;
699
700 if (g != agroot(g) && GD_label(g) && !GD_label(g)->set) {
701 if (GD_label_pos(g) & LABEL_AT_TOP) {
702 d = GD_border(g)[TOP_IX];
703 p.y = GD_bb(g).UR.y - d.y / 2;
704 } else {
705 d = GD_border(g)[BOTTOM_IX];
706 p.y = GD_bb(g).LL.y + d.y / 2;
707 }
708
709 if (GD_label_pos(g) & LABEL_AT_RIGHT) {
710 p.x = GD_bb(g).UR.x - d.x / 2;
711 } else if (GD_label_pos(g) & LABEL_AT_LEFT) {
712 p.x = GD_bb(g).LL.x + d.x / 2;
713 } else {
714 p.x = (GD_bb(g).LL.x + GD_bb(g).UR.x) / 2;
715 }
716 GD_label(g)->pos = p;
717 GD_label(g)->set = true;
718 }
719
720 for (c = 1; c <= GD_n_cluster(g); c++)
722}
Dynamically expanding string buffers.
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
Definition agxbuf.h:252
static char * agxbdisown(agxbuf *xb)
Definition agxbuf.h:345
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
Definition alloc.h:26
#define MIN(a, b)
Definition arith.h:28
#define MAX(a, b)
Definition arith.h:33
void updateBB(graph_t *g, textlabel_t *lp)
Definition utils.c:575
void gv_nodesize(node_t *n, bool flip)
Definition utils.c:1465
bool late_bool(void *obj, attrsym_t *attr, bool defaultValue)
Definition utils.c:99
#define LABEL_AT_LEFT
Definition const.h:177
#define BOTTOM_IX
Definition const.h:111
#define HEAD_LABEL
Definition const.h:168
#define TOP_IX
Definition const.h:113
#define EDGE_XLABEL
Definition const.h:172
#define GRAPH_LABEL
Definition const.h:170
#define RANKDIR_BT
Definition const.h:183
#define TAIL_LABEL
Definition const.h:169
#define EDGE_LABEL
Definition const.h:167
#define LEFT_IX
Definition const.h:114
#define IGNORED
Definition const.h:30
#define RANKDIR_TB
Definition const.h:181
#define RANKDIR_LR
Definition const.h:182
#define LABEL_AT_TOP
Definition const.h:176
#define LABEL_AT_RIGHT
Definition const.h:178
#define RANKDIR_RL
Definition const.h:184
#define GVSPLINES
Definition const.h:164
#define NODE_XLABEL
Definition const.h:171
#define RIGHT_IX
Definition const.h:112
pointf ccwrotatepf(pointf p, int ccwrot)
Definition geom.c:148
struct pointf_s pointf
#define INCH2PS(a_inches)
Definition geom.h:63
show_boxes_t Show_boxes
Definition globals.c:23
int State
Definition globals.h:66
bool Concentrate
Definition globals.h:62
int EdgeLabelsDone
Definition globals.h:68
static bool Verbose
Definition gml2gv.c:26
void free(void *)
node NULL
Definition grammar.y:181
static int cnt(Dict_t *d, Dtlink_t **set)
Definition graph.c:204
size_t agnnodes_z(const Agraph_t *g)
Definition graph.c:161
#define ED_xlabel(e)
Definition types.h:590
#define ED_head_label(e)
Definition types.h:587
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Definition edge.c:28
#define ED_spl(e)
Definition types.h:595
#define agtail(e)
Definition cgraph.h:982
#define ED_edge_type(e)
Definition types.h:582
#define ED_tail_label(e)
Definition types.h:596
#define aghead(e)
Definition cgraph.h:983
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:42
#define ED_label(e)
Definition types.h:589
void agwarningf(const char *fmt,...)
Definition agerror.c:175
void agerrorf(const char *fmt,...)
Definition agerror.c:167
#define agfindgraphattr(g, a)
Definition types.h:613
#define GD_border(g)
Definition types.h:359
#define GD_has_labels(g)
Definition types.h:368
#define GD_clust(g)
Definition types.h:360
#define GD_bb(g)
Definition types.h:354
#define GD_label_pos(g)
Definition types.h:400
#define GD_n_cluster(g)
Definition types.h:389
#define GD_label(g)
Definition types.h:374
#define GD_rankdir(g)
Definition types.h:377
#define GD_flip(g)
Definition types.h:378
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:50
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:43
#define ND_height(n)
Definition types.h:498
#define ND_width(n)
Definition types.h:536
#define ND_xlabel(n)
Definition types.h:503
#define ND_coord(n)
Definition types.h:490
char * agnameof(void *)
returns a string descriptor for the object.
Definition id.c:145
Agraph_t * agroot(void *obj)
Definition obj.c:170
type-generic dynamically expanding list
#define LIST_PREPEND(list, item)
Definition list.h:179
#define LIST_IS_EMPTY(list)
Definition list.h:102
#define EDGE_TYPE(g)
Definition macros.h:25
#define PAD(d)
Definition macros.h:29
#define M2
Definition postproc.c:77
static pointf edgeTailpoint(Agedge_t *e)
Definition postproc.c:238
static boxf adjustBB(object_t *objp, boxf bb)
Definition postproc.c:274
void translate_bb(graph_t *g, int rankdir)
Definition postproc.c:124
#define HAVE_EDGE(ep)
Definition postproc.c:379
static int Rankdir
Definition postproc.c:26
static void place_root_label(graph_t *g, pointf d)
Definition postproc.c:175
static void place_flip_graph_label(graph_t *g)
Definition postproc.c:662
static boxf addNodeObj(node_t *np, object_t *objp, boxf bb)
Definition postproc.c:335
static void map_edge(edge_t *e)
Definition postproc.c:97
void place_graph_label(graph_t *g)
Definition postproc.c:696
static size_t countClusterLabels(Agraph_t *g)
Definition postproc.c:369
static cinfo_t addClusterObj(Agraph_t *g, cinfo_t info)
Definition postproc.c:355
static pointf centerPt(xlabel_t *xlp)
Definition postproc.c:200
void dotneato_postprocess(Agraph_t *g)
Definition postproc.c:657
static void printData(object_t *objs, size_t n_objs, xlabel_t *lbls, size_t n_lbls, label_params_t *params)
Definition postproc.c:210
static pointf Offset
Definition postproc.c:28
static pointf edgeHeadpoint(Agedge_t *e)
Definition postproc.c:255
static bool Flip
Definition postproc.c:27
#define M1
Definition postproc.c:32
static void addXLabels(Agraph_t *gp)
Definition postproc.c:385
void gv_postprocess(Agraph_t *g, int allowTranslation)
Definition postproc.c:570
static void translate_drawing(graph_t *g)
Definition postproc.c:149
static boxf addLabelObj(textlabel_t *lp, object_t *objp, boxf bb)
Definition postproc.c:315
static pointf map_point(pointf p)
Definition postproc.c:90
static void addXLabel(textlabel_t *lp, object_t *objp, xlabel_t *xlp, int initObj, pointf pos)
Definition postproc.c:292
#define PRISIZE_T
Definition prisize_t.h:25
splines * getsplinepoints(edge_t *e)
Definition splines.c:1304
pointf edgeMidpoint(graph_t *g, edge_t *e)
Definition splines.c:1227
graph or subgraph
Definition cgraph.h:424
string attribute descriptor symbol in Agattr_s.dict
Definition cgraph.h:641
Definition types.h:89
size_t size
Definition types.h:91
pointf sp
Definition types.h:94
pointf * list
Definition types.h:90
uint32_t eflag
Definition types.h:93
pointf ep
Definition types.h:95
uint32_t sflag
Definition types.h:92
Definition geom.h:41
pointf UR
Definition geom.h:41
pointf LL
Definition geom.h:41
object_t * objp
Definition postproc.c:352
boxf bb
Definition postproc.c:351
boxf bb
Definition constraint.c:607
bool force
if true, all labels must be placed
Definition xlabels.h:38
xlabel_t * lbl
Definition xlabels.h:33
pointf pos
Definition xlabels.h:31
pointf sz
Definition xlabels.h:32
double x
Definition geom.h:29
double y
Definition geom.h:29
bezier * list
Definition types.h:99
size_t size
Definition types.h:100
pointf pos
Definition types.h:114
char * text
Definition types.h:105
bool set
Definition types.h:123
pointf dimen
Definition types.h:110
textlabel_t * lbl
pointer to label in the graph
Definition xlabels.h:26
bool set
true if the position has been set (input/output)
Definition xlabels.h:27
pointf sz
Definition xlabels.h:24
pointf pos
Definition xlabels.h:25
#define UNREACHABLE()
Definition unreachable.h:30
int placeLabels(object_t *objs, size_t n_objs, const label_params_t *params)
Definition xlabels.c:541