29 static int indent = -1;
45 for (i = 0; i < indent; i++)
63 fprintf(stderr,
" LL (%f,%f) UR (%f,%f)\n", bb.
LL.
x, bb.
LL.
y,
66 fprintf(stderr,
" LL (%f,%f) UR (%f,%f)\n", b.
LL.
x, b.
LL.
y,
78 fprintf(stderr,
" {\n");
82 fprintf(stderr,
" subgraph %s : %d nodes\n",
agnameof(subg),
90 fprintf(stderr,
" }\n");
95 void dumpE(
graph_t * g,
int derived)
124 fprintf(stderr,
" %s\n",
agnameof(n));
129 if ((pp = PORTS(g))) {
131 fprintf(stderr,
" %d ports\n", sz);
133 fprintf(stderr,
" %s : ",
agnameof(pp->n));
143 void dump(
graph_t * g,
int level,
int doBB)
166 bb.
LL.
x = pos.
x - w / 2.0;
167 bb.
LL.
y = pos.
y - h / 2.0;
170 fprintf(stderr,
"%s: (%f,%f) ((%f,%f) , (%f,%f))\n",
174 fprintf(stderr,
"%s: (%f,%f) (%f,%f) \n",
181 void dumpG(
graph_t * g,
char *fname,
int expMode)
185 fp = fopen(fname,
"w");
187 fprintf(stderr,
"Couldn not open %s \n", fname);
190 outputGraph(g, fp, expMode);
200 double ArrowScale = 1.0;
202 #define ARROW_LENGTH 10
203 #define ARROW_WIDTH 5
206 static char *plog =
"%!PS-Adobe-2.0\n\n\
207 /Times-Roman findfont 14 scalefont setfont\n\
224 \t0 0 ht sub rlineto\n\
249 static char *elog =
"showpage\n";
269 static double PSWidth = 550.0;
270 static double PSHeight = 756.0;
272 static void pswrite(
Agraph_t * g, FILE * fp,
int expMode)
277 double minx, miny, maxx, maxy;
278 double scale, width, height;
283 double arrow_w, arrow_l;
286 fprintf(fp,
"%s", plog);
323 if ((p =
agget(g,
"rotate")) && (*p !=
'\0')
324 && ((angle = atoi(p)) != 0)) {
325 fprintf(fp,
"306 396 translate\n");
326 fprintf(fp,
"%d rotate\n", angle);
327 fprintf(fp,
"-306 -396 translate\n");
336 width = maxx - minx + 20;
337 height = maxy - miny + 20;
338 if (width > PSWidth) {
339 if (height > PSHeight) {
342 PSHeight / height ? PSWidth / width : PSHeight /
345 scale = PSWidth / width;
346 }
else if (height > PSHeight) {
347 scale = PSHeight / height;
352 fprintf(fp,
"%f %f translate\n",
353 (PSWidth - scale * (minx + maxx)) / 2.0,
354 (PSHeight - scale * (miny + maxy)) / 2.0);
355 fprintf(fp,
"%f %f scale\n", scale, scale);
364 arrow_w = ArrowScale * ARROW_WIDTH / scale;
368 fprintf(fp,
"0.0 setlinewidth\n");
372 fprintf(fp,
"%f %f 5 fillCircle\n", 0.0, 0.0);
373 for (i = 0; i < maxx; i += CellW) {
374 fprintf(fp,
"%f 0.0 moveto %f %f lineto stroke\n",
375 (
float) i, (
float) i, maxy);
377 for (i = 0; i < maxy; i += CellH) {
378 fprintf(fp,
"0.0 %f moveto %f %f lineto stroke\n",
379 (
float) i, maxx, (
float) i);
388 fprintf(fp,
"0 0 %f inch drawCircle\n", r);
396 fprintf(fp,
"%f inch %f inch moveto %f inch %f inch lineto\n",
399 fprintf(fp,
"stroke\n");
404 fprintf(fp,
"%f %f %.2f %.2f %.2f doArrow\n",
419 fprintf(fp,
"%f %f %f %f doBox\n", wd, ht,
420 data->pos.x - (wd / 2),
data->pos.y - (ht / 2));
424 fprintf(fp,
"%% %s\n",
agnameof(n));
430 r = sqrt((wd * wd / 4) + ht * ht / 4);
431 fprintf(fp,
"%f inch %f inch %f inch %f inch doBox\n", wd, ht,
433 fprintf(fp,
"%f inch %f inch %f inch drawCircle\n",
438 fprintf(fp,
"0.667 1.000 1.000 sethsbcolor\n");
443 fprintf(fp,
"0.0 0.000 0.000 sethsbcolor\n");
448 fprintf(fp,
"%f inch %f inch %f fillCircle\n",
ND_pos(n)[0],
453 fprintf(fp,
"0.667 1.000 1.000 sethsbcolor\n");
457 fprintf(fp,
"%f inch %f inch moveto %f inch %f inch lineto\n",
460 fprintf(fp,
"stroke\n");
465 fprintf(fp,
"%f %f %.2f %.2f %.2f doArrow\n",
473 fprintf(fp,
"%s", elog);
476 void outputGraph(
Agraph_t * g, FILE * fp,
int expMode)
478 pswrite(g, fp, expMode);
CGRAPH_API Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
char * agget(void *obj, char *name)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
CGRAPH_API char * agnameof(void *)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
EXTERN unsigned char Verbose
CGRAPH_API int agnnodes(Agraph_t *g)
CGRAPH_API int agnedges(Agraph_t *g)
CGRAPH_API Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
char * el(GVJ_t *job, char *template,...)