43 for (i = 0; i <
indent; i++)
61 fprintf(stderr,
" LL (%f,%f) UR (%f,%f)\n", bb.
LL.
x, bb.
LL.
y,
64 fprintf(stderr,
" LL (%f,%f) UR (%f,%f)\n", b.
LL.
x, b.
LL.
y,
76 fprintf(stderr,
" {\n");
80 fprintf(stderr,
" subgraph %s : %d nodes\n",
agnameof(subg),
88 fprintf(stderr,
" }\n");
93void dump(
graph_t *g,
int level) {
114 fprintf(stderr,
"%s: (%f,%f) (%f,%f) \n",
124 fp = fopen(
fname,
"w");
126 fprintf(stderr,
"Couldn not open %s \n",
fname);
129 outputGraph(g, fp, expMode);
133static const double ArrowScale = 1.0;
135#define ARROW_LENGTH 10
138static char *plog =
"%!PS-Adobe-2.0\n\n\
139/Times-Roman findfont 14 scalefont setfont\n\
156\t0 0 ht sub rlineto\n\
181static char *elog =
"showpage\n";
183static double PSWidth = 550.0;
184static double PSHeight = 756.0;
186static void pswrite(
Agraph_t * g, FILE * fp,
int expMode)
191 double minx, miny, maxx, maxy;
192 double scale, width, height;
197 double arrow_w, arrow_l;
200 fprintf(fp,
"%s", plog);
211 minx = fmin(minx,
ND_pos(n)[0]);
212 miny = fmin(miny,
ND_pos(n)[1]);
213 maxx = fmax(maxx,
ND_pos(n)[0]);
214 maxy = fmax(maxy,
ND_pos(n)[1]);
226 if ((p =
agget(g,
"rotate")) && *p !=
'\0' && (angle = atoi(p)) != 0) {
227 fprintf(fp,
"306 396 translate\n");
228 fprintf(fp,
"%d rotate\n", angle);
229 fprintf(fp,
"-306 -396 translate\n");
235 width = maxx - minx + 20;
236 height = maxy - miny + 20;
237 if (width > PSWidth) {
238 if (height > PSHeight) {
239 scale = fmin(PSWidth / width, PSHeight / height);
241 scale = PSWidth / width;
242 }
else if (height > PSHeight) {
243 scale = PSHeight / height;
247 fprintf(fp,
"%f %f translate\n",
248 (PSWidth -
scale * (minx + maxx)) / 2.0,
249 (PSHeight -
scale * (miny + maxy)) / 2.0);
259 arrow_w = ArrowScale * ARROW_WIDTH /
scale;
263 fprintf(fp,
"0.0 setlinewidth\n");
269 fprintf(fp,
"0 0 %f inch drawCircle\n", r);
277 fprintf(fp,
"%f inch %f inch moveto %f inch %f inch lineto\n",
280 fprintf(fp,
"stroke\n");
285 fprintf(fp,
"%f %f %.2f %.2f %.2f doArrow\n",
300 fprintf(fp,
"%f %f %f %f doBox\n", wd, ht,
301 data->pos.x - wd / 2,
data->pos.y - ht / 2);
305 fprintf(fp,
"%% %s\n",
agnameof(n));
311 r = sqrt(wd * wd / 4 + ht * ht / 4);
312 fprintf(fp,
"%f inch %f inch %f inch %f inch doBox\n", wd, ht,
314 fprintf(fp,
"%f inch %f inch %f inch drawCircle\n",
319 fprintf(fp,
"0.667 1.000 1.000 sethsbcolor\n");
324 fprintf(fp,
"0.0 0.000 0.000 sethsbcolor\n");
329 fprintf(fp,
"%f inch %f inch %f fillCircle\n",
ND_pos(n)[0],
334 fprintf(fp,
"0.667 1.000 1.000 sethsbcolor\n");
338 fprintf(fp,
"%f inch %f inch moveto %f inch %f inch lineto\n",
341 fprintf(fp,
"stroke\n");
346 fprintf(fp,
"%f %f %.2f %.2f %.2f doArrow\n",
354 fprintf(fp,
"%s", elog);
357void outputGraph(
Agraph_t * g, FILE * fp,
int expMode)
359 pswrite(g, fp, expMode);
static NORETURN void graphviz_exit(int status)
static pointf scale(double c, pointf p)
int agnnodes(Agraph_t *g)
char * agget(void *obj, char *name)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
char * agnameof(void *)
returns a string descriptor for the object.
static void indent(int ix)