Re: [graphviz-interest] viewport feature enanchement proposal

"Emden R. Gansner" <[email protected]> Mon, 17 Nov 2014 14:25:50 -0500
Newsgroups gmane.comp.video.graphviz
Message-ID <[email protected]>
You've already got this feature. Run whatever commands you need to generate a dot file with complete 
layout information, e.g.,

sfdp -Goverlap=prism -Gcharset=latin1 gd_1994_2007_8comp.gv | gvmap -e > graph.gv

and assume the nodes you want in the viewport have the attribute viewport=true. You can then run

      neato -n2 -Tpdf -Gviewport=$(gvpr -fmkview graph.gv) graph.gv > graph.pdf

to get what you want. The mkview script takes an optional margin argument:

      neato -n2 -Tpdf -Gviewport=$(gvpr -fmkview -a300 graph.gv) graph.gv > graph.pdf

(You may need to modify the command to work with the shell or scripting language you are using.) The 
mkview gvpr script is appended.

          Emden

=====================
/* mkview */
BEGIN {
   double mg, margin = 36;
   double maxd = 1.7976931348623157e+308;
   double llx, lly, urx, ury, x, y, w2, h2;
   llx = lly = maxd;
   urx = ury = -maxd;
   if (ARGC) {
     if ((sscanf (ARGV[0],"%lf", &mg)) && (mg >= 0))
       margin = mg;
   }
}
N [viewport] {
   sscanf (pos, "%lf,%lf", &x, &y);
   sscanf (width, "%lf", &w2);
   sscanf (height, "%lf", &h2);
   w2 *= 36.0;
   h2 *= 36.0;
   if (x-w2 < llx) llx = x-w2;
   if (x+w2 > urx) urx = x+w2;
   if (y-h2 < lly) lly = y-h2;
   if (y+h2 > ury) ury = y+h2;
}
END {
   printf("%.06f,%.06f,1,%.06f,%.06f", urx-llx+margin, ury-lly+margin, (urx+llx)/2.0, (ury+lly)/2.0);
}

_______________________________________________
[email protected]
http://lists.research.att.com/mailman/listinfo/graphviz-interest