]> granicus.if.org Git - graphviz/commitdiff
extend -Gviewport to also accept "X,Y,Z,nodename"
authorellson <devnull@localhost>
Fri, 16 Nov 2007 22:05:20 +0000 (22:05 +0000)
committerellson <devnull@localhost>
Fri, 16 Nov 2007 22:05:20 +0000 (22:05 +0000)
lib/common/emit.c

index 45ed9ae0e8e662ccddbc353fec17702eaf7231d4..c9c6d5623de8456f247d3575e13b1fe16710a638 100644 (file)
@@ -1934,6 +1934,8 @@ static void init_job_viewport(GVJ_t * job, graph_t * g)
     char *str;
     double X, Y, Z, x, y;
     int rv;
+    Agnode_t *n;
+    char *nodename = NULL;
 
     assert((gvc->bb.LL.x == 0) && (gvc->bb.LL.y == 0));
     P2PF(gvc->bb.UR, UR);
@@ -1968,14 +1970,27 @@ static void init_job_viewport(GVJ_t * job, graph_t * g)
     Y = sz.y * Z;
 
     /* user can override */
-    if ((str = agget(g, "viewport")))
-       rv = sscanf(str, "%lf,%lf,%lf,%lf,%lf", &X, &Y, &Z, &x, &y);
+    if ((str = agget(g, "viewport"))) {
+        nodename = malloc(strlen(str)+1);
+       rv = sscanf(str, "%lf,%lf,%lf,%[^\"]", &X, &Y, &Z, nodename);
+       if (rv == 4) {
+           n = agfindnode(g->root, nodename);
+           if (n) {
+               x = ND_coord_i(n).x;
+               y = ND_coord_i(n).y;
+           }
+       }
+       else {
+           rv = sscanf(str, "%lf,%lf,%lf,%lf,%lf", &X, &Y, &Z, &x, &y);
+        }
+       free (nodename);
+    }
     /* rv is ignored since args retain previous values if not scanned */
 
-       /* job->view gives port size in graph units, unscaled or rotated
-        * job->zoom gives scaling factor.
-        * job->focus gives the position in the graph of the center of the port
-        */
+    /* job->view gives port size in graph units, unscaled or rotated
+     * job->zoom gives scaling factor.
+     * job->focus gives the position in the graph of the center of the port
+     */
     job->view.x = X;
     job->view.y = Y;
     job->zoom = Z;              /* scaling factor */