/* _write_plain: */ void write_plain(GVJ_t * job, graph_t * g, FILE * f, bool extend) { int i, j, splinePoints; char *tport, *hport; node_t *n; edge_t *e; bezier bz; point pt; char *lbl; // setup_graph(job, g); setYInvert(g); pt = GD_bb(g).UR; fprintf(f, "graph %.3f %.3f %.3f\n", job->zoom, PS2INCH(pt.x), PS2INCH(pt.y)); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { if (IS_CLUST_NODE(n)) continue; fprintf(f, "node %s ", agcanonical(n->name)); printptf(f, ND_coord_i(n)); if (ND_label(n)->html) /* if html, get original text */ lbl = agxget(n, N_label->index); else lbl = ND_label(n)->text; if (lbl) lbl = agcanonical(lbl); else lbl = "\"\""; fprintf(f, " %.3f %.3f %s %s %s %s %s\n", ND_width(n), ND_height(n), lbl, late_nnstring(n, N_style, "solid"), ND_shape(n)->name, late_nnstring(n, N_color, DEFAULT_COLOR), late_nnstring(n, N_fillcolor, DEFAULT_FILL)); } for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { if (extend && e->attr) { tport = e->attr[TAILX]; hport = e->attr[HEADX]; } else tport = hport = ""; if (ED_spl(e)) { splinePoints = 0; for (i = 0; i < ED_spl(e)->size; i++) { bz = ED_spl(e)->list[i]; splinePoints += bz.size; } fprintf(f, "edge "); writenodeandport(f, e->tail, tport); fprintf(f, " "); writenodeandport(f, e->head, hport); fprintf(f, " %d", splinePoints); for (i = 0; i < ED_spl(e)->size; i++) { bz = ED_spl(e)->list[i]; for (j = 0; j < bz.size; j++) printptf(f, bz.list[j]); } } if (ED_label(e)) { fprintf(f, " %s", agcanonical(ED_label(e)->text)); printptf(f, ED_label(e)->p); } fprintf(f, " %s %s\n", late_nnstring(e, E_style, "solid"), late_nnstring(e, E_color, DEFAULT_COLOR)); } } fprintf(f, "stop\n"); }
void write_plainstr(graph_t* g, std::string *str) { int i; node_t *n; edge_t *e; bezier bz; char buf[SMALLBUF],buf1[SMALLBUF]; char tmpbuf[1000]; setup_graph(g); sprintf(tmpbuf, "graph %.3f", g->u.drawing->scale); str->append(tmpbuf); printptf(str, g->u.bb.UR); str->append("\n"); for (n = agfstnode(g); n; n = agnxtnode(g,n)) { str->append("node "); str->append(agstrcanon(n->name,buf)); printptf(str,n->u.coord); sprintf(tmpbuf, " %.3f", n->u.width); str->append(tmpbuf); sprintf(tmpbuf, " %.3f ", n->u.height); str->append(tmpbuf); str->append(agstrcanon(n->u.label->text,buf)); str->append(" "); str->append(late_nnstring(n,N_style,"solid")); str->append(" "); str->append(n->u.shape->name); str->append(" "); str->append(late_nnstring(n,N_color,DEFAULT_COLOR)); str->append(" "); str->append(late_nnstring(n,N_fillcolor,DEFAULT_FILL)); str->append("\n"); } for (n = agfstnode(g); n; n = agnxtnode(g,n)) { for (e = agfstout(g,n); e; e = agnxtout(g,e)) { bz = e->u.spl->list[0]; str->append("edge "); str->append(agstrcanon(e->tail->name,buf)); str->append(" "); str->append(agstrcanon(e->head->name,buf1)); str->append(" "); sprintf(tmpbuf, " %d", bz.size); str->append(tmpbuf); for (i = 0; i < bz.size; i++) printptf(str,bz.list[i]); if (e->u.label) { str->append(" "); str->append(agstrcanon(e->u.label->text,buf)); printptf(str,e->u.label->p); } str->append(" "); str->append(late_nnstring(e,E_style,"solid")); str->append(" "); str->append(late_nnstring(e,E_color,DEFAULT_COLOR)); str->append("\n"); } } str->append("stop\n"); }