22 static void place_flip_graph_label(
graph_t * g);
26 /Y exch %.5g sub def\n\
27 /X exch %.5g sub def\n\
28 /y exch %.5g sub def\n\
29 /x exch %.5g sub def\n\
36 /dbgstart { gsave %.5g %.5g translate } def\n\
37 /arrowlength 10 def\n\
38 /arrowwidth arrowlength 2 div def\n\
45 arrowlength arrowwidth 2 div rlineto\n\
46 0 arrowwidth neg rlineto\n\
51 currentpoint exch pop sub exch currentpoint pop sub atan\n\
71 /X exch neg %.5g sub def\n\
72 /Y exch %.5g sub def\n\
73 /x exch neg %.5g sub def\n\
74 /y exch %.5g sub def\n\
90 static void map_edge(
edge_t * e)
101 for (j = 0; j <
ED_spl(e)->size; j++) {
103 for (k = 0; k < bz.
size; k++)
106 ED_spl(e)->list[j].sp = map_point(
ED_spl(e)->list[j].sp);
108 ED_spl(e)->list[j].ep = map_point(
ED_spl(e)->list[j].ep);
128 new_bb.
LL = map_point(pointfof(bb.
LL.
x, bb.
UR.
y));
129 new_bb.
UR = map_point(pointfof(bb.
UR.
x, bb.
LL.
y));
131 new_bb.
LL = map_point(pointfof(bb.
LL.
x, bb.
LL.
y));
132 new_bb.
UR = map_point(pointfof(bb.
UR.
x, bb.
UR.
y));
147 static void translate_drawing(
graph_t * g)
151 int shift = (Offset.
x || Offset.
y);
153 if (!shift && !Rankdir)
201 centerPt (xlabel_t* xlp) {
205 p.
x += (xlp->sz.x)/2.0;
206 p.
y += (xlp->sz.y)/2.0;
212 printData (object_t* objs,
int n_objs, xlabel_t* lbls,
int n_lbls,
213 label_params_t* params) {
216 fprintf (stderr,
"%d objs %d xlabels force=%d bb=(%.02f,%.02f) (%.02f,%.02f)\n",
217 n_objs, n_lbls, params->force, params->bb.LL.x, params->bb.LL.y,
218 params->bb.UR.x, params->bb.UR.y);
220 fprintf(stderr,
"objects\n");
221 for (i = 0; i < n_objs; i++) {
223 fprintf (stderr,
" [%d] (%.02f,%.02f) (%.02f,%.02f) %p \"%s\"\n",
224 i, objs->pos.x,objs->pos.y,objs->sz.x,objs->sz.y, objs->lbl,
228 fprintf(stderr,
"xlabels\n");
229 for (i = 0; i < n_lbls; i++) {
230 fprintf (stderr,
" [%d] %p set %d (%.02f,%.02f) (%.02f,%.02f) %s\n",
231 i, lbls, lbls->set, lbls->pos.x,lbls->pos.y, lbls->sz.x,lbls->sz.y, ((
textlabel_t*)lbls->lbl)->text);
278 adjustBB (object_t* objp,
boxf bb)
285 ur.
x = objp->pos.x + objp->sz.x;
286 ur.
y = objp->pos.y + objp->sz.y;
298 addXLabel (
textlabel_t* lp, object_t* objp, xlabel_t* xlp,
int initObj,
pointf pos)
336 objp->pos.
x -= (objp->sz.x) / 2.0;
337 objp->pos.y -= (objp->sz.y) / 2.0;
339 return adjustBB(objp, bb);
348 addNodeObj (
node_t* np, object_t* objp,
boxf bb)
359 objp->pos.x -= (objp->sz.x) / 2.0;
360 objp->pos.y -= (objp->sz.y) / 2.0;
362 return adjustBB(objp, bb);
376 info = addClusterObj (
GD_clust(g)[c], info);
378 object_t* objp = info.
objp;
393 i += countClusterLabels (
GD_clust(g)[c]);
404 #define HAVE_EDGE(ep) ((et != ET_NONE) && (ED_spl(ep) != NULL))
406 static void addXLabels(
Agraph_t * gp)
410 int cnt, i, n_objs, n_lbls;
418 label_params_t params;
468 n_clbls = countClusterLabels (gp);
471 n_lbls = n_nlbls + n_elbls;
472 if (n_lbls == 0)
return;
477 n_objs =
agnnodes(gp) + n_set_lbls + n_clbls + n_elbls;
478 objp = objs =
N_NEW(n_objs, object_t);
479 xlp = lbls =
N_NEW(n_lbls, xlabel_t);
485 bb = addNodeObj (np, objp, bb);
489 bb = addLabelObj (lp, objp, bb);
492 addXLabel (lp, objp, xlp, 0, ur);
500 bb = addLabelObj (lp, objp, bb);
507 agerr(
AGWARN,
"no position for edge with label %s",
515 bb = addLabelObj (lp, objp, bb);
518 addXLabel (lp, objp, xlp, 1, edgeTailpoint(ep));
522 agerr(
AGWARN,
"no position for edge with tail label %s",
530 bb = addLabelObj (lp, objp, bb);
533 addXLabel (lp, objp, xlp, 1, edgeHeadpoint(ep));
537 agerr(
AGWARN,
"no position for edge with head label %s",
545 bb = addLabelObj (lp, objp, bb);
552 agerr(
AGWARN,
"no position for edge with xlabel %s",
564 info = addClusterObj (gp, info);
572 placeLabels(objs, n_objs, lbls, n_lbls, ¶ms);
574 printData(objs, n_objs, lbls, n_lbls, ¶ms);
578 for (i = 0; i < n_lbls; i++) {
583 lp->
pos = centerPt(xlp);
589 fprintf (stderr,
"%d out of %d labels positioned.\n", cnt, n_lbls);
590 else if (cnt != n_lbls)
591 agerr(
AGWARN,
"%d out of %d exterior labels positioned.\n", cnt, n_lbls);
606 pointf dimen = { 0., 0. };
613 place_flip_graph_label(g);
636 GD_bb(g).LL.y -= diff;
637 GD_bb(g).UR.y += diff;
655 GD_bb(g).LL.x -= diff;
656 GD_bb(g).UR.x += diff;
660 if (allowTranslation) {
663 Offset =
GD_bb(g).LL;
666 Offset = pointfof(-
GD_bb(g).UR.y,
GD_bb(g).LL.x);
669 Offset = pointfof(
GD_bb(g).LL.x, -
GD_bb(g).UR.y);
672 Offset = pointfof(
GD_bb(g).LL.y,
GD_bb(g).LL.x);
675 translate_drawing(g);
678 place_root_label(g, dimen);
683 sprintf(buf,
M2, Offset.
x, Offset.
y, Offset.
x, Offset.
y);
685 sprintf(buf,
M1, Offset.
y, Offset.
x, Offset.
y, Offset.
x,
686 -Offset.
x, -Offset.
y);
701 static void place_flip_graph_label(
graph_t * g)
727 place_flip_graph_label(
GD_clust(g)[c]);
void dotneato_postprocess(Agraph_t *g)
pointf edgeMidpoint(graph_t *g, edge_t *e)
splines * getsplinepoints(edge_t *e)
void gv_postprocess(Agraph_t *g, int allowTranslation)
int agerr(agerrlevel_t level, const char *fmt,...)
CGRAPH_API Agraph_t * agroot(void *obj)
CGRAPH_API Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
void translate_bb(graph_t *g, int rankdir)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
pointf ccwrotatepf(pointf p, int ccwrot)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
CGRAPH_API char * agnameof(void *)
#define INCH2PS(a_inches)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
EXTERN unsigned char Concentrate
#define agfindgraphattr(g, a)
EXTERN unsigned char Verbose
CGRAPH_API int agnnodes(Agraph_t *g)
void updateBB(graph_t *g, textlabel_t *lp)
EXTERN char ** Show_boxes
void gv_nodesize(node_t *n, boolean flip)
void place_graph_label(graph_t *g)
CGRAPH_API Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
EXTERN int EdgeLabelsDone
boolean late_bool(void *obj, attrsym_t *attr, int def)