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) {
113 fprintf(stderr,
"%s: (%f,%f) (%f,%f) \n",
123 fp = fopen(
fname,
"w");
125 fprintf(stderr,
"Couldn not open %s \n",
fname);
128 outputGraph(g, fp, expMode);
132static const double ArrowScale = 1.0;
134#define ARROW_LENGTH 10
137static char *plog =
"%!PS-Adobe-2.0\n\n\
138/Times-Roman findfont 14 scalefont setfont\n\
155\t0 0 ht sub rlineto\n\
180static char *elog =
"showpage\n";
182static double PSWidth = 550.0;
183static double PSHeight = 756.0;
185static void pswrite(
Agraph_t * g, FILE * fp,
int expMode)
190 double minx, miny, maxx, maxy;
191 double scale, width, height;
196 double arrow_w, arrow_l;
199 fprintf(fp,
"%s", plog);
210 minx = fmin(minx,
ND_pos(n)[0]);
211 miny = fmin(miny,
ND_pos(n)[1]);
212 maxx = fmax(maxx,
ND_pos(n)[0]);
213 maxy = fmax(maxy,
ND_pos(n)[1]);
225 if ((p =
agget(g,
"rotate")) && *p !=
'\0' && (angle = atoi(p)) != 0) {
226 fprintf(fp,
"306 396 translate\n");
227 fprintf(fp,
"%d rotate\n", angle);
228 fprintf(fp,
"-306 -396 translate\n");
234 width = maxx - minx + 20;
235 height = maxy - miny + 20;
236 if (width > PSWidth) {
237 if (height > PSHeight) {
238 scale = fmin(PSWidth / width, PSHeight / height);
240 scale = PSWidth / width;
241 }
else if (height > PSHeight) {
242 scale = PSHeight / height;
246 fprintf(fp,
"%f %f translate\n",
247 (PSWidth -
scale * (minx + maxx)) / 2.0,
248 (PSHeight -
scale * (miny + maxy)) / 2.0);
258 arrow_w = ArrowScale * ARROW_WIDTH /
scale;
262 fprintf(fp,
"0.0 setlinewidth\n");
268 fprintf(fp,
"0 0 %f inch drawCircle\n", r);
276 fprintf(fp,
"%f inch %f inch moveto %f inch %f inch lineto\n",
279 fprintf(fp,
"stroke\n");
284 fprintf(fp,
"%f %f %.2f %.2f %.2f doArrow\n",
293 fprintf(fp,
"%% %s\n",
agnameof(n));
299 r = sqrt(wd * wd / 4 + ht * ht / 4);
300 fprintf(fp,
"%f inch %f inch %f inch %f inch doBox\n", wd, ht,
302 fprintf(fp,
"%f inch %f inch %f inch drawCircle\n",
307 fprintf(fp,
"0.667 1.000 1.000 sethsbcolor\n");
312 fprintf(fp,
"0.0 0.000 0.000 sethsbcolor\n");
317 fprintf(fp,
"%f inch %f inch %f fillCircle\n",
ND_pos(n)[0],
321 fprintf(fp,
"0.667 1.000 1.000 sethsbcolor\n");
325 fprintf(fp,
"%f inch %f inch moveto %f inch %f inch lineto\n",
328 fprintf(fp,
"stroke\n");
333 fprintf(fp,
"%f %f %.2f %.2f %.2f doArrow\n",
341 fprintf(fp,
"%s", elog);
344void outputGraph(
Agraph_t * g, FILE * fp,
int expMode)
346 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)