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; }
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); GD_drawing(g)->quantum = late_double(g, agfindattr(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, 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); p = late_string(g, agfindattr(g, "fontnames"), NULL); GD_fontnames(g) = maptoken(p, fontnamenames, fontnamecodes); setRatio(g); GD_drawing(g)->filled = getdoubles2pt(g, "size", &(GD_drawing(g)->size)); getdoubles2pt(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; 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; /* initialize nodes */ N_height = agfindattr(g->proto->n, "height"); N_width = agfindattr(g->proto->n, "width"); N_shape = agfindattr(g->proto->n, "shape"); N_color = agfindattr(g->proto->n, "color"); N_fillcolor = agfindattr(g->proto->n, "fillcolor"); N_style = agfindattr(g->proto->n, "style"); N_fontsize = agfindattr(g->proto->n, "fontsize"); N_fontname = agfindattr(g->proto->n, "fontname"); N_fontcolor = agfindattr(g->proto->n, "fontcolor"); N_label = agfindattr(g->proto->n, "label"); N_showboxes = agfindattr(g->proto->n, "showboxes"); N_penwidth = agfindattr(g->proto->n, "penwidth"); /* attribs for polygon shapes */ N_sides = agfindattr(g->proto->n, "sides"); N_peripheries = agfindattr(g->proto->n, "peripheries"); N_skew = agfindattr(g->proto->n, "skew"); N_orientation = agfindattr(g->proto->n, "orientation"); N_distortion = agfindattr(g->proto->n, "distortion"); N_fixed = agfindattr(g->proto->n, "fixedsize"); N_imagescale = agfindattr(g->proto->n, "imagescale"); N_nojustify = agfindattr(g->proto->n, "nojustify"); N_layer = agfindattr(g->proto->n, "layer"); N_group = agfindattr(g->proto->n, "group"); N_comment = agfindattr(g->proto->n, "comment"); N_vertices = agfindattr(g->proto->n, "vertices"); N_z = agfindattr(g->proto->n, "z"); /* initialize edges */ E_weight = agfindattr(g->proto->e, "weight"); E_color = agfindattr(g->proto->e, "color"); E_fontsize = agfindattr(g->proto->e, "fontsize"); E_fontname = agfindattr(g->proto->e, "fontname"); E_fontcolor = agfindattr(g->proto->e, "fontcolor"); E_label = agfindattr(g->proto->e, "label"); E_label_float = agfindattr(g->proto->e, "labelfloat"); /* vladimir */ E_dir = agfindattr(g->proto->e, "dir"); E_arrowhead = agfindattr(g->proto->e, "arrowhead"); E_arrowtail = agfindattr(g->proto->e, "arrowtail"); E_headlabel = agfindattr(g->proto->e, "headlabel"); E_taillabel = agfindattr(g->proto->e, "taillabel"); E_labelfontsize = agfindattr(g->proto->e, "labelfontsize"); E_labelfontname = agfindattr(g->proto->e, "labelfontname"); E_labelfontcolor = agfindattr(g->proto->e, "labelfontcolor"); E_labeldistance = agfindattr(g->proto->e, "labeldistance"); E_labelangle = agfindattr(g->proto->e, "labelangle"); /* end vladimir */ E_minlen = agfindattr(g->proto->e, "minlen"); E_showboxes = agfindattr(g->proto->e, "showboxes"); E_style = agfindattr(g->proto->e, "style"); E_decorate = agfindattr(g->proto->e, "decorate"); E_arrowsz = agfindattr(g->proto->e, "arrowsize"); E_constr = agfindattr(g->proto->e, "constraint"); E_layer = agfindattr(g->proto->e, "layer"); E_comment = agfindattr(g->proto->e, "comment"); E_tailclip = agfindattr(g->proto->e, "tailclip"); E_headclip = agfindattr(g->proto->e, "headclip"); E_penwidth = agfindattr(g->proto->e, "penwidth"); }