void common_init_node(node_t * n) { struct fontinfo fi; char *str; ND_width(n) = late_double(n, N_width, DEFAULT_NODEWIDTH, MIN_NODEWIDTH); ND_height(n) = late_double(n, N_height, DEFAULT_NODEHEIGHT, MIN_NODEHEIGHT); ND_shape(n) = bind_shape(late_nnstring(n, N_shape, DEFAULT_NODESHAPE), n); str = agxget(n, N_label); fi.fontsize = late_double(n, N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE); fi.fontname = late_nnstring(n, N_fontname, DEFAULT_FONTNAME); fi.fontcolor = late_nnstring(n, N_fontcolor, DEFAULT_COLOR); ND_label(n) = make_label((void*)n, str, ((aghtmlstr(str) ? LT_HTML : LT_NONE) | ( (shapeOf(n) == SH_RECORD) ? LT_RECD : LT_NONE)), fi.fontsize, fi.fontname, fi.fontcolor); if (N_xlabel && (str = agxget(n, N_xlabel)) && (str[0])) { ND_xlabel(n) = make_label((void*)n, str, (aghtmlstr(str) ? LT_HTML : LT_NONE), fi.fontsize, fi.fontname, fi.fontcolor); GD_has_labels(agraphof(n)) |= NODE_XLABEL; } ND_showboxes(n) = late_int(n, N_showboxes, 0, 0); ND_shape(n)->fns->initfn(n); }
/* tuneControl: * Use user values to reset control * * Possible parameters: * ctrl->use_node_weights */ static void tuneControl (graph_t* g, spring_electrical_control ctrl) { long seed; int init; seed = ctrl->random_seed; init = setSeed (g, INIT_RANDOM, &seed); if (init != INIT_RANDOM) { agerr(AGWARN, "sfdp only supports start=random\n"); } ctrl->random_seed = seed; ctrl->K = late_double(g, agfindgraphattr(g, "K"), -1.0, 0.0); ctrl->p = -1.0*late_double(g, agfindgraphattr(g, "repulsiveforce"), -AUTOP, 0.0); ctrl->multilevels = late_int(g, agfindgraphattr(g, "levels"), INT_MAX, 0); ctrl->smoothing = late_smooth(g, agfindgraphattr(g, "smoothing"), SMOOTHING_NONE); ctrl->tscheme = late_quadtree_scheme(g, agfindgraphattr(g, "quadtree"), QUAD_TREE_NORMAL); /* ctrl->method = late_mode(g, agfindgraphattr(g, "mode"), METHOD_SPRING_ELECTRICAL); */ ctrl->method = METHOD_SPRING_ELECTRICAL; ctrl->beautify_leaves = mapBool (agget(g, "beautify"), FALSE); ctrl->rotation = late_double(g, agfindgraphattr(g, "rotation"), 0.0, -MAXDOUBLE); ctrl->edge_labeling_scheme = late_int(g, agfindgraphattr(g, "label_scheme"), 0, 0); if (ctrl->edge_labeling_scheme > 4) { agerr (AGWARN, "label_scheme = %d > 4 : ignoring\n", ctrl->edge_labeling_scheme); ctrl->edge_labeling_scheme = 0; } }
/* init_edge: */ static void init_edge(edge_t * e, attrsym_t * E_len) { ED_factor(e) = late_double(e, E_weight, 1.0, 0.0); ED_dist(e) = late_double(e, E_len, fdp_parms.K, 0.0); common_init_edge(e); }
static void ptest_initNode(node_t * n) { char *str; ND_width(n) = late_double(n, N_width, DEFAULT_NODEWIDTH, MIN_NODEWIDTH); ND_height(n) = late_double(n, N_height, DEFAULT_NODEHEIGHT, MIN_NODEWIDTH); if (N_label == NULL) str = NODENAME_ESC; else str = agxget(n, N_label->index); str = strdup_and_subst(str, NODENAME_ESC, n->name); ND_label(n) = make_label(str, late_double(n, N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE), late_nnstring(n, N_fontname, DEFAULT_FONTNAME), late_nnstring(n, N_fontcolor, DEFAULT_COLOR), n->graph); ND_shape(n) = bind_shape(late_nnstring(n, N_shape, DEFAULT_NODESHAPE)); ND_shape(n)->initfn(n); /* ### need to quantize ? */ ptest_nodesize(n, n->GD_flip(graph)); }
/* initGraphAttrs: * Set attributes based on original root graph. * This is obtained by taking a node of g, finding its node * in the original graph, and finding that node's graph. */ static void initGraphAttrs(Agraph_t * g, circ_state * state) { static Agraph_t *rootg; static attrsym_t *N_artpos; static attrsym_t *N_root; static attrsym_t *G_mindist; static char *rootname; Agraph_t *rg; node_t *n = agfstnode(g); rg = agraphof(ORIGN(n)); if (rg != rootg) { /* new root graph */ state->blockCount = 0; rootg = rg; G_mindist = agattr(rootg,AGRAPH, "mindist", NULL); N_artpos = agattr(rootg,AGNODE, "articulation_pos", NULL); N_root = agattr(rootg,AGNODE, "root", NULL); } rootname = agget(rootg, "root"); initBlocklist(&state->bl); state->orderCount = 1; state->min_dist = late_double(rootg, G_mindist, MINDIST, 0.0); state->N_artpos = N_artpos; state->N_root = N_root; state->rootname = rootname; }
static void initFontEdgeAttr(edge_t * e, struct fontinfo *fi) { fi->fontsize = late_double(e, E_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE); fi->fontname = late_nnstring(e, E_fontname, DEFAULT_FONTNAME); fi->fontcolor = late_nnstring(e, E_fontcolor, DEFAULT_COLOR); }
static void dot_init_edge(edge_t * e) { char *tailgroup, *headgroup; #ifdef WITH_CGRAPH agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //graph custom data #endif /* WITH_CGRAPH */ common_init_edge(e); ED_weight(e) = late_double(e, E_weight, 1.0, 0.0); tailgroup = late_string(agtail(e), N_group, ""); headgroup = late_string(aghead(e), N_group, ""); ED_count(e) = ED_xpenalty(e) = 1; if (tailgroup[0] && (tailgroup == headgroup)) { ED_xpenalty(e) = CL_CROSS; ED_weight(e) *= 100; } if (nonconstraint_edge(e)) { ED_xpenalty(e) = 0; ED_weight(e) = 0; } ED_showboxes(e) = late_int(e, E_showboxes, 0, 0); ED_minlen(e) = late_int(e, E_minlen, 1, 0); }
static void circular_init_edge(edge_t * e) { agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data common_init_edge(e); ED_factor(e) = late_double(e, E_weight, 1.0, 0.0); }
static void twopi_init_edge(edge_t * e) { #ifdef WITH_CGRAPH agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //edge custom data #endif /* WITH_CGRAPH */ common_init_edge(e); ED_factor(e) = late_double(e, E_weight, 1.0, 0.0); }
static void initFontLabelEdgeAttr(edge_t * e, struct fontinfo *fi, struct fontinfo *lfi) { if (!fi->fontname) initFontEdgeAttr(e, fi); lfi->fontsize = late_double(e, E_labelfontsize, fi->fontsize, MIN_FONTSIZE); lfi->fontname = late_nnstring(e, E_labelfontname, fi->fontname); lfi->fontcolor = late_nnstring(e, E_labelfontcolor, fi->fontcolor); }
/* get_inputscale: * Return value for PSinputscale. If this is > 0, it has been set on the * command line and this value is used. * Otherwise, we check the graph's inputscale attribute. If this is not set * or has a bad value, we return -1. * If the value is 0, we return the default. Otherwise, we return the value. * Set but negative values are treated like 0. */ double get_inputscale (graph_t* g) { double d; if (PSinputscale > 0) return PSinputscale; /* command line flag prevails */ d = late_double(g, agfindgraphattr(g, "inputscale"), -1, 0); if (d == 0) return POINTS_PER_INCH; else return d; }
void common_init_node(node_t * n) { char *str; int html = 0; ND_width(n) = late_double(n, N_width, DEFAULT_NODEWIDTH, MIN_NODEWIDTH); ND_height(n) = late_double(n, N_height, DEFAULT_NODEHEIGHT, MIN_NODEHEIGHT); if (N_label == NULL) str = NODENAME_ESC; else { str = agxget(n, N_label->index); html = aghtmlstr(str); } if (html) str = strdup(str); else str = strdup_and_subst_node(str, n); ND_label(n) = make_label(html, str, late_double(n, N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE), late_nnstring(n, N_fontname, DEFAULT_FONTNAME), late_nnstring(n, N_fontcolor, DEFAULT_COLOR), n->graph); #ifdef ENABLE_HTML //maks if (html) { if (make_html_label(ND_label(n), n) == 1) agerr(AGPREV, "in label of node %s\n", n->name); } #endif ND_shape(n) = bind_shape(late_nnstring(n, N_shape, DEFAULT_NODESHAPE), n); ND_showboxes(n) = late_int(n, N_showboxes, 0, 0); ND_shape(n)->fns->initfn(n); }
/* fdp_initParams: * Initialize parameters based on root graph attributes. * Should K be a function of nnodes? */ void fdp_initParams (graph_t* g) { if (fdp_args.numIters == -1) numIters = late_int (g, agfindattr (g,"maxiter"),dflt_numIters,0); else numIters = fdp_args.numIters; if (fdp_args.K == -1.0) T_K = late_double (g, agfindattr (g,"K"),dflt_K,0.0); else T_K = fdp_args.K; if (fdp_args.T0 == -1.0) { T0 = late_double (g, agfindattr (g,"T0"),-1.0,0.0); } else T0 = fdp_args.T0; if (fdp_args.smode == seed_unset) { if (fdp_setSeed(&smode,agget (g,"start"))) { smode = dflt_smode; } } else smode = fdp_args.smode; pass1 = (T_unscaled*numIters)/100; K2 = T_K*T_K; if (T_useGrid) { if (Cell <= 0.0) Cell = 3*T_K; Cell2 = Cell * Cell; } if (Verbose) { fprintf (stderr, "Params: K %f T0 %f Tfact %f numIters %d unscaled %d\n", T_K, T0, T_Tfact, numIters, T_unscaled); } }
static void dot_init_edge(edge_t * e) { char *tailgroup, *headgroup; common_init_edge(e); ED_weight(e) = late_double(e, E_weight, 1.0, 0.0); tailgroup = late_string(e->tail, N_group, ""); headgroup = late_string(e->head, N_group, ""); ED_count(e) = ED_xpenalty(e) = 1; if (tailgroup[0] && (tailgroup == headgroup)) { ED_xpenalty(e) = CL_CROSS; ED_weight(e) *= 100; } if (nonconstraint_edge(e)) { ED_xpenalty(e) = 0; ED_weight(e) = 0; } ED_showboxes(e) = late_int(e, E_showboxes, 0, 0); ED_minlen(e) = late_int(e, E_minlen, 1, 0); }
static void twopi_init_edge(edge_t * e) { common_init_edge(e); ED_factor(e) = late_double(e, E_weight, 1.0, 0.0); }
void neato_init_edge(edge_t * e) { common_init_edge(e); ED_factor(e) = late_double(e, E_weight, 1.0, 1.0); }
/* do_graph_label: * Set characteristics of graph label if it exists. * */ void do_graph_label(graph_t * sg) { char *p, *pos, *just; int pos_ix; /* it would be nice to allow multiple graph labels in the future */ if ((p = agget(sg, "label"))) { char pos_flag; int lbl_kind = LT_NONE; point dpt; pointf dimen; if (aghtmlstr(p)) lbl_kind = LT_HTML; GD_has_labels(sg->root) |= GRAPH_LABEL; if (lbl_kind) p = strdup (p); else p = strdup_and_subst_obj(p, (void*)sg); GD_label(sg) = make_label(sg->root, lbl_kind, p, late_double(sg, agfindattr(sg, "fontsize"), DEFAULT_FONTSIZE, MIN_FONTSIZE), late_nnstring(sg, agfindattr(sg, "fontname"), DEFAULT_FONTNAME), late_nnstring(sg, agfindattr(sg, "fontcolor"), DEFAULT_COLOR)); if (lbl_kind) { if (make_html_label(sg->root, GD_label(sg), sg) == 1) agerr(AGPREV, "in label of graph %s\n", sg->name); } /* set label position */ pos = agget(sg, "labelloc"); if (sg != sg->root) { if (pos && (pos[0] == 'b')) pos_flag = LABEL_AT_BOTTOM; else pos_flag = LABEL_AT_TOP; } else { if (pos && (pos[0] == 't')) pos_flag = LABEL_AT_TOP; else pos_flag = LABEL_AT_BOTTOM; } just = agget(sg, "labeljust"); if (just) { if (just[0] == 'l') pos_flag |= LABEL_AT_LEFT; else if (just[0] == 'r') pos_flag |= LABEL_AT_RIGHT; } GD_label_pos(sg) = pos_flag; if (sg == sg->root) return; /* Set border information for cluster labels to allow space */ dimen = GD_label(sg)->dimen; PAD(dimen); PF2P(dimen, dpt); if (!GD_flip(sg->root)) { if (GD_label_pos(sg) & LABEL_AT_TOP) pos_ix = TOP_IX; else pos_ix = BOTTOM_IX; GD_border(sg)[pos_ix] = dpt; } else { /* when rotated, the labels will be restored to TOP or BOTTOM */ if (GD_label_pos(sg) & LABEL_AT_TOP) pos_ix = RIGHT_IX; else pos_ix = LEFT_IX; GD_border(sg)[pos_ix].x = dpt.y; GD_border(sg)[pos_ix].y = dpt.x; } } }
/* do_graph_label: * Set characteristics of graph label if it exists. * */ void do_graph_label(graph_t * sg) { char *str, *pos, *just; int pos_ix; /* it would be nice to allow multiple graph labels in the future */ if ((str = agget(sg, "label")) && (*str != '\0')) { char pos_flag; pointf dimen; GD_has_labels(sg->root) |= GRAPH_LABEL; GD_label(sg) = make_label((void*)sg, str, (aghtmlstr(str) ? LT_HTML : LT_NONE), late_double(sg, agfindgraphattr(sg, "fontsize"), DEFAULT_FONTSIZE, MIN_FONTSIZE), late_nnstring(sg, agfindgraphattr(sg, "fontname"), DEFAULT_FONTNAME), late_nnstring(sg, agfindgraphattr(sg, "fontcolor"), DEFAULT_COLOR)); /* set label position */ pos = agget(sg, "labelloc"); if (sg != agroot(sg)) { if (pos && (pos[0] == 'b')) pos_flag = LABEL_AT_BOTTOM; else pos_flag = LABEL_AT_TOP; } else { if (pos && (pos[0] == 't')) pos_flag = LABEL_AT_TOP; else pos_flag = LABEL_AT_BOTTOM; } just = agget(sg, "labeljust"); if (just) { if (just[0] == 'l') pos_flag |= LABEL_AT_LEFT; else if (just[0] == 'r') pos_flag |= LABEL_AT_RIGHT; } GD_label_pos(sg) = pos_flag; if (sg == agroot(sg)) return; /* Set border information for cluster labels to allow space */ dimen = GD_label(sg)->dimen; PAD(dimen); if (!GD_flip(agroot(sg))) { if (GD_label_pos(sg) & LABEL_AT_TOP) pos_ix = TOP_IX; else pos_ix = BOTTOM_IX; GD_border(sg)[pos_ix] = dimen; } else { /* when rotated, the labels will be restored to TOP or BOTTOM */ if (GD_label_pos(sg) & LABEL_AT_TOP) pos_ix = RIGHT_IX; else pos_ix = LEFT_IX; GD_border(sg)[pos_ix].x = dimen.y; GD_border(sg)[pos_ix].y = dimen.x; } } }
/* cgraph requires */ void graph_init(graph_t * g, boolean use_rankdir) { char *p; double xf; static char *rankname[] = { "local", "global", "none", NULL }; static int rankcode[] = { LOCAL, GLOBAL, NOCLUST, LOCAL }; static char *fontnamenames[] = {"gd","ps","svg", NULL}; static int fontnamecodes[] = {NATIVEFONTS,PSFONTS,SVGFONTS,-1}; int rankdir; GD_drawing(g) = NEW(layout_t); /* set this up fairly early in case any string sizes are needed */ if ((p = agget(g, "fontpath")) || (p = getenv("DOTFONTPATH"))) { /* overide GDFONTPATH in local environment if dot * wants its own */ #ifdef HAVE_SETENV setenv("GDFONTPATH", p, 1); #else static char *buf = 0; buf = grealloc(buf, strlen("GDFONTPATH=") + strlen(p) + 1); strcpy(buf, "GDFONTPATH="); strcat(buf, p); putenv(buf); #endif } GD_charset(g) = findCharset (g); if (!HTTPServerEnVar) { Gvimagepath = agget (g, "imagepath"); if (!Gvimagepath) Gvimagepath = Gvfilepath; } GD_drawing(g)->quantum = late_double(g, agfindgraphattr(g, "quantum"), 0.0, 0.0); /* setting rankdir=LR is only defined in dot, * but having it set causes shape code and others to use it. * The result is confused output, so we turn it off unless requested. * This effective rankdir is stored in the bottom 2 bits of g->u.rankdir. * Sometimes, the code really needs the graph's rankdir, e.g., neato -n * with record shapes, so we store the real rankdir in the next 2 bits. */ rankdir = RANKDIR_TB; if ((p = agget(g, "rankdir"))) { if (streq(p, "LR")) rankdir = RANKDIR_LR; else if (streq(p, "BT")) rankdir = RANKDIR_BT; else if (streq(p, "RL")) rankdir = RANKDIR_RL; } if (use_rankdir) SET_RANKDIR (g, (rankdir << 2) | rankdir); else SET_RANKDIR (g, (rankdir << 2)); xf = late_double(g, agfindgraphattr(g, "nodesep"), DEFAULT_NODESEP, MIN_NODESEP); GD_nodesep(g) = POINTS(xf); p = late_string(g, agfindgraphattr(g, "ranksep"), NULL); if (p) { if (sscanf(p, "%lf", &xf) == 0) xf = DEFAULT_RANKSEP; else { if (xf < MIN_RANKSEP) xf = MIN_RANKSEP; } if (strstr(p, "equally")) GD_exact_ranksep(g) = TRUE; } else xf = DEFAULT_RANKSEP; GD_ranksep(g) = POINTS(xf); GD_showboxes(g) = late_int(g, agfindgraphattr(g, "showboxes"), 0, 0); p = late_string(g, agfindgraphattr(g, "fontnames"), NULL); GD_fontnames(g) = maptoken(p, fontnamenames, fontnamecodes); setRatio(g); GD_drawing(g)->filled = getdoubles2ptf(g, "size", &(GD_drawing(g)->size)); getdoubles2ptf(g, "page", &(GD_drawing(g)->page)); GD_drawing(g)->centered = mapbool(agget(g, "center")); if ((p = agget(g, "rotate"))) GD_drawing(g)->landscape = (atoi(p) == 90); else if ((p = agget(g, "orientation"))) GD_drawing(g)->landscape = ((p[0] == 'l') || (p[0] == 'L')); else if ((p = agget(g, "landscape"))) GD_drawing(g)->landscape = mapbool(p); p = agget(g, "clusterrank"); CL_type = maptoken(p, rankname, rankcode); p = agget(g, "concentrate"); Concentrate = mapbool(p); State = GVBEGIN; EdgeLabelsDone = 0; GD_drawing(g)->dpi = 0.0; if (((p = agget(g, "dpi")) && p[0]) || ((p = agget(g, "resolution")) && p[0])) GD_drawing(g)->dpi = atof(p); do_graph_label(g); Initial_dist = MYHUGE; G_ordering = agfindgraphattr(g, "ordering"); G_gradientangle = agfindgraphattr(g,"gradientangle"); G_margin = agfindgraphattr(g, "margin"); /* initialize nodes */ N_height = agfindnodeattr(g, "height"); N_width = agfindnodeattr(g, "width"); N_shape = agfindnodeattr(g, "shape"); N_color = agfindnodeattr(g, "color"); N_fillcolor = agfindnodeattr(g, "fillcolor"); N_style = agfindnodeattr(g, "style"); N_fontsize = agfindnodeattr(g, "fontsize"); N_fontname = agfindnodeattr(g, "fontname"); N_fontcolor = agfindnodeattr(g, "fontcolor"); N_label = agfindnodeattr(g, "label"); if (!N_label) N_label = agattr(g, AGNODE, "label", NODENAME_ESC); N_xlabel = agfindnodeattr(g, "xlabel"); N_showboxes = agfindnodeattr(g, "showboxes"); N_penwidth = agfindnodeattr(g, "penwidth"); N_ordering = agfindnodeattr(g, "ordering"); N_margin = agfindnodeattr(g, "margin"); /* attribs for polygon shapes */ N_sides = agfindnodeattr(g, "sides"); N_peripheries = agfindnodeattr(g, "peripheries"); N_skew = agfindnodeattr(g, "skew"); N_orientation = agfindnodeattr(g, "orientation"); N_distortion = agfindnodeattr(g, "distortion"); N_fixed = agfindnodeattr(g, "fixedsize"); N_imagescale = agfindnodeattr(g, "imagescale"); N_nojustify = agfindnodeattr(g, "nojustify"); N_layer = agfindnodeattr(g, "layer"); N_group = agfindnodeattr(g, "group"); N_comment = agfindnodeattr(g, "comment"); N_vertices = agfindnodeattr(g, "vertices"); N_z = agfindnodeattr(g, "z"); N_gradientangle = agfindnodeattr(g,"gradientangle"); /* initialize edges */ E_weight = agfindedgeattr(g, "weight"); E_color = agfindedgeattr(g, "color"); E_fillcolor = agfindedgeattr(g, "fillcolor"); E_fontsize = agfindedgeattr(g, "fontsize"); E_fontname = agfindedgeattr(g, "fontname"); E_fontcolor = agfindedgeattr(g, "fontcolor"); E_label = agfindedgeattr(g, "label"); E_xlabel = agfindedgeattr(g, "xlabel"); E_label_float = agfindedgeattr(g, "labelfloat"); /* vladimir */ E_dir = agfindedgeattr(g, "dir"); E_arrowhead = agfindedgeattr(g, "arrowhead"); E_arrowtail = agfindedgeattr(g, "arrowtail"); E_headlabel = agfindedgeattr(g, "headlabel"); E_taillabel = agfindedgeattr(g, "taillabel"); E_labelfontsize = agfindedgeattr(g, "labelfontsize"); E_labelfontname = agfindedgeattr(g, "labelfontname"); E_labelfontcolor = agfindedgeattr(g, "labelfontcolor"); E_labeldistance = agfindedgeattr(g, "labeldistance"); E_labelangle = agfindedgeattr(g, "labelangle"); /* end vladimir */ E_minlen = agfindedgeattr(g, "minlen"); E_showboxes = agfindedgeattr(g, "showboxes"); E_style = agfindedgeattr(g, "style"); E_decorate = agfindedgeattr(g, "decorate"); E_arrowsz = agfindedgeattr(g, "arrowsize"); E_constr = agfindedgeattr(g, "constraint"); E_layer = agfindedgeattr(g, "layer"); E_comment = agfindedgeattr(g, "comment"); E_tailclip = agfindedgeattr(g, "tailclip"); E_headclip = agfindedgeattr(g, "headclip"); E_penwidth = agfindedgeattr(g, "penwidth"); /* background */ GD_drawing(g)->xdots = init_xdot (g); /* initialize id, if any */ if ((p = agget(g, "id")) && *p) GD_drawing(g)->id = strdup_and_subst_obj(p, g); }
void init_ugraph(graph_t *g) { char *p; double xf; static char *rankname[] = {"local","global","none",NULL}; static int rankcode[] = {LOCAL, GLOBAL, NOCLUST, LOCAL}; double X,Y,Z,x,y; GD_drawing(g) = NEW(layout_t); /* set this up fairly early in case any string sizes are needed */ if ((p = agget(g,"fontpath")) || (p = getenv("DOTFONTPATH"))) { /* overide GDFONTPATH in local environment if dot * wants its own */ #ifdef HAVE_SETENV setenv("GDFONTPATH", p, 1); #else static char *buf=0; buf=grealloc(buf,strlen("GDFONTPATH=")+strlen(p)+1); strcpy(buf,"GDFONTPATH="); strcat(buf,p); putenv(buf); #endif } GD_drawing(g)->quantum = late_double(g,agfindattr(g,"quantum"),0.0,0.0); GD_drawing(g)->font_scale_adj = 1.0; /* setting rankdir=LR is only defined in dot, * but having it set causes shape code and others to use it. * The result is confused output, so we turn it off unless requested. */ if (UseRankdir) GD_left_to_right(g) = ((p = agget(g,"rankdir")) && streq(p,"LR")); else GD_left_to_right(g) = FALSE; do_graph_label(g); xf = late_double(g,agfindattr(g,"nodesep"),DEFAULT_NODESEP,MIN_NODESEP); GD_nodesep(g) = POINTS(xf); p = late_string(g,agfindattr(g,"ranksep"),NULL); if (p) { if (sscanf(p,"%lf",&xf) == 0) xf = DEFAULT_RANKSEP; else {if (xf < MIN_RANKSEP) xf = MIN_RANKSEP;} if (strstr(p,"equally")) GD_exact_ranksep(g) = TRUE; } else xf = DEFAULT_RANKSEP; GD_ranksep(g) = POINTS(xf); GD_showboxes(g) = late_int(g,agfindattr(g,"showboxes"),0,0); Epsilon = .0001 * agnnodes(g); getdoubles2pt(g,"size",&(GD_drawing(g)->size)); getdoubles2pt(g,"page",&(GD_drawing(g)->page)); getdouble(g,"epsilon",&Epsilon); getdouble(g,"nodesep",&Nodesep); getdouble(g,"nodefactor",&Nodefactor); X = Y = Z = x = y = 0.0; if ((p = agget(g,"viewport"))) sscanf(p,"%lf,%lf,%lf,%lf,%lf",&X,&Y,&Z,&x,&y); GD_drawing(g)->viewport.size.x = ROUND(X); /* viewport size in dev units - pixels */ GD_drawing(g)->viewport.size.y = ROUND(Y); GD_drawing(g)->viewport.zoom = Z; /* scaling factor */ GD_drawing(g)->viewport.focus.x = x; /* graph coord of focus - points */ GD_drawing(g)->viewport.focus.y = y; GD_drawing(g)->centered = mapbool(agget(g,"center")); if ((p = agget(g,"rotate"))) GD_drawing(g)->landscape = (atoi(p) == 90); else { /* today we learned the importance of backward compatibilty */ if ((p = agget(g,"orientation"))) GD_drawing(g)->landscape = ((p[0] == 'l') || (p[0] == 'L')); } p = agget(g,"clusterrank"); CL_type = maptoken(p,rankname,rankcode); p = agget(g,"concentrate"); Concentrate = mapbool(p); Nodesep = 1.0; Nodefactor = 1.0; Initial_dist = MYHUGE; }
/* do_graph_label: * If the ifdef'ed parts are added, clusters are guaranteed not * to overlap and have sufficient room for the label. The problem * is this approach does not use the actual size of the cluster, so * the resulting cluster tends to be far too large. */ void do_graph_label(graph_t* sg) { char *p, *pos, *just; int pos_ix; GVC_t *gvc = GD_gvc(sg->root); /* it would be nice to allow multiple graph labels in the future */ if ((p = agget(sg,"label"))) { char pos_flag; int html = aghtmlstr(p); GD_has_labels(sg->root) |= GRAPH_LABEL; GD_label(sg) = make_label(gvc, html,strdup_and_subst_graph(p,sg), late_double(sg,agfindattr(sg,"fontsize"),DEFAULT_FONTSIZE,MIN_FONTSIZE), late_nnstring(sg,agfindattr(sg,"fontname"),DEFAULT_FONTNAME), late_nnstring(sg,agfindattr(sg,"fontcolor"),DEFAULT_COLOR),sg); if (html) { if (make_html_label(gvc, GD_label(sg), sg)) agerr (AGPREV, "in label of graph %s\n", sg->name); } /* set label position */ pos = agget(sg,"labelloc"); if (sg != sg->root) { if (pos && (pos[0] == 'b')) pos_flag = LABEL_AT_BOTTOM; else pos_flag = LABEL_AT_TOP; } else { if (pos && (pos[0] == 't')) pos_flag = LABEL_AT_TOP; else pos_flag = LABEL_AT_BOTTOM; } just = agget(sg,"labeljust"); if (just) { if (just[0] == 'l') pos_flag |= LABEL_AT_LEFT; else if (just[0] == 'r') pos_flag |= LABEL_AT_RIGHT; } GD_label_pos(sg) = pos_flag; if(!GD_left_to_right(sg->root)) { point dpt; dpt = cvt2pt(GD_label(sg)->dimen); if (GD_label_pos(sg) & LABEL_AT_TOP) pos_ix = TOP_IX; else pos_ix = BOTTOM_IX; GD_border(sg)[pos_ix] = dpt; #if 0 if(g != g->root) { GD_border(g)[LEFT_IX].x = dpt.x/2; GD_border(g)[RIGHT_IX].x = dpt.x/2; GD_border(g)[LEFT_IX].y = 0; GD_border(g)[RIGHT_IX].y = 0; } #endif } else { point dpt; dpt = cvt2pt(GD_label(sg)->dimen); /* when rotated, the labels will be restored to TOP or BOTTOM */ if (GD_label_pos(sg) & LABEL_AT_TOP) pos_ix = RIGHT_IX; else pos_ix = LEFT_IX; GD_border(sg)[pos_ix].x = dpt.y; GD_border(sg)[pos_ix].y = dpt.x; #if 0 if(g != g->root) { GD_border(g)[TOP_IX].y = dpt.x/2; GD_border(g)[BOTTOM_IX].y = dpt.x/2; GD_border(g)[TOP_IX].x = 0; GD_border(g)[BOTTOM_IX].x = 0; } #endif } } }