]> granicus.if.org Git - graphviz/commitdiff
svgen.c fixes
authorellson <devnull@localhost>
Fri, 13 May 2005 21:54:49 +0000 (21:54 +0000)
committerellson <devnull@localhost>
Fri, 13 May 2005 21:54:49 +0000 (21:54 +0000)
2 less additions per rendererd point.

graphviz.spec.in
lib/common/emit.c
lib/common/svggen.c
lib/gvc/gvcint.h
lib/gvc/gvrender.c

index d5c98e649dbc86ab37b61258a64159aa44800570..5955ba77901a862d4faf8f06389939ebdf6a6db1 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$ $Revision$
 # @configure_input@
 
 Summary:        Graph Visualization Tools
index c80212a915c37f5ad62278a84fcab5329e4b2b66..731150432f964d1b6f2b1505d6c1233192b33f85 100644 (file)
@@ -92,6 +92,9 @@ static void init_job_flags(GVJ_t * job, graph_t * g)
     case POSTSCRIPT:
         job->flags = chkOrder(g) | GVRENDER_DOES_MULTIGRAPH_OUTPUT_FILES;
         break;
+    case SVG:
+        job->flags = chkOrder(g) | GVRENDER_Y_GOES_DOWN;
+        break;
     case ISMAP: case IMAP: case CMAP: case CMAPX:
         /* output in breadth first graph walk order, but
          * with nodes edges and nested clusters before
index 61846ca122bc88221ca679b7d87f8df54ff8d15b..c5c0ab7ae780508ca912ea92a328551b116f2fbd 100644 (file)
@@ -110,12 +110,11 @@ static char *sdotarray = "1,5";
 
 static int N_pages;
 /* static      point   Pages; */
-static int Rot;
 static int onetime = TRUE;
 
-static int Dpi;
-static pointf CompScale;
 static int Rot;
+static pointf CompScale;
+static pointf Offset;
 
 static point Viewport;
 static pointf GraphFocus;
@@ -200,17 +199,24 @@ static void init_svg(void)
     cstk[0].penwidth = WIDTH_NORMAL;
 }
 
-/* can't hack a transform directly in SVG preamble, alas */
 static point svgpt(point p)
 {
     point rv;
 
     if (Rot) {
+#if 0
         rv.x = ROUND(-(p.y - GraphFocus.y) * CompScale.x + Viewport.x / 2.);
-        rv.y = ROUND((p.x - GraphFocus.x) * CompScale.y + Viewport.y / 2.);
+        rv.y = ROUND( (p.x - GraphFocus.x) * CompScale.y + Viewport.y / 2.);
+    } else {
+        rv.x = ROUND( (p.x - GraphFocus.x) * CompScale.x + Viewport.x / 2.);
+        rv.y = ROUND( (p.y - GraphFocus.y) * CompScale.y + Viewport.y / 2.);
+#else
+        rv.x = ROUND(-p.y * CompScale.x + Offset.x);
+        rv.y = ROUND( p.x * CompScale.y + Offset.y);
     } else {
-        rv.x = ROUND((p.x - GraphFocus.x) * CompScale.x + Viewport.x / 2.);
-        rv.y = ROUND((p.y - GraphFocus.y) * CompScale.y + Viewport.y / 2.);
+        rv.x = ROUND( p.x * CompScale.x + Offset.x);
+        rv.y = ROUND( p.y * CompScale.y + Offset.y);
+#endif
     }
     return rv;
 }
@@ -424,12 +430,14 @@ svg_begin_job(FILE * ofp, graph_t * g, char **lib, char *user,
 
 static void svg_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
 {
-    Dpi = gvc->job->dpi;
+    int dpi = gvc->job->dpi;
+
     Viewport.x = gvc->job->width;
     Viewport.y = gvc->job->height;
     Zoom = gvc->job->zoom;
     GraphFocus = gvc->job->focus;
     CompScale = gvc->job->compscale;
+    Offset = gvc->job->offset;
 
     if (onetime) {
        init_svg();
@@ -438,13 +446,13 @@ static void svg_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
     svg_fputs("<!-- Title: ");
     svg_fputs(xml_string(g->name));
     svg_printf(" Pages: %d -->\n", N_pages);
-    if (Dpi == POINTS_PER_INCH) 
+    if (dpi == POINTS_PER_INCH) 
        svg_printf("<svg width=\"%dpt\" height=\"%dpt\"\n",
                   Viewport.x, Viewport.y);
     else
        svg_printf("<svg width=\"%dpx\" height=\"%dpx\"\n",
-                  Dpi * Viewport.x / POINTS_PER_INCH,
-                  Dpi * Viewport.y / POINTS_PER_INCH);
+                  dpi * Viewport.x / POINTS_PER_INCH,
+                  dpi * Viewport.y / POINTS_PER_INCH);
     /* establish absolute units in points */
     svg_printf(" viewBox = \"%d %d %d %d\"\n", 0, 0, Viewport.x, Viewport.y);
     /* namespace of svg */
@@ -752,7 +760,9 @@ static void svg_ellipse(point p, int rx, int ry, int filled)
     mp.x = p.x;
     mp.y = p.y;
     mp = svgpt(mp);
-    svg_printf("<ellipse cx=\"%d\" cy=\"%d\"", mp.x, mp.y);
+    svg_fputs("<ellipse");
+    svg_grstyle(&cstk[SP], filled);
+    svg_printf(" cx=\"%d\" cy=\"%d\"", mp.x, mp.y);
     if (Rot) {
        int t;
        t = rx;
@@ -761,9 +771,7 @@ static void svg_ellipse(point p, int rx, int ry, int filled)
     }
     mp.x = rx;
     mp.y = ry;
-    svg_printf(" rx=\"%d\" ry=\"%d\"", mp.x, mp.y);
-    svg_grstyle(&cstk[SP], filled);
-    svg_fputs("/>\n");
+    svg_printf(" rx=\"%d\" ry=\"%d\"/>\n", mp.x, mp.y);
 }
 
 static void
index 7a960d58ebb68bca56d149709653ad97e50b1089..59d9b3f4840a5568968d18c043f754e90cc4970f 100644 (file)
@@ -127,6 +127,7 @@ extern "C" {
        boxf pageBoxClip;       /* intersection of clip and pageBox */
 
        pointf compscale;       /* composite device scale incl: scale, zoom, dpi, y_goes_down */
+       pointf offset;          /* composite translation */
        
        boolean fit_mode, needs_refresh, click, active, has_grown;
        double oldx, oldy;      /* old pointer position in pixels */
index 2311e94b5f3ae6eb92b090d7566f5faeab6e97d0..cc3a902d3c67be19d22f330dd9a9503aa37633df 100644 (file)
@@ -194,6 +194,7 @@ static pointf gvrender_ptf(GVJ_t *job, pointf p)
 {
     pointf rv;
 
+#if 0
     if (job->rotation) {
        rv.x = -(p.y - job->focus.y) * job->compscale.x + job->width / 2.;
        rv.y = (p.x - job->focus.x) * job->compscale.y + job->height / 2.;
@@ -201,6 +202,15 @@ static pointf gvrender_ptf(GVJ_t *job, pointf p)
        rv.x = (p.x - job->focus.x) * job->compscale.x + job->width / 2.;
        rv.y = (p.y - job->focus.y) * job->compscale.y + job->height / 2.;
     }
+#else
+    if (job->rotation) {
+       rv.x = -p.y * job->compscale.x + job->offset.x;
+       rv.y =  p.x * job->compscale.y + job->offset.y;
+    } else {
+       rv.x =  p.x * job->compscale.x + job->offset.x;
+       rv.y =  p.y * job->compscale.y + job->offset.y;
+    }
+#endif
     return rv;
 }
 
@@ -250,9 +260,16 @@ void gvrender_begin_graph(GVJ_t * job, graph_t * g)
 
     job->sg = g;  /* current subgraph/cluster */
     job->compscale.y = job->compscale.x = job->zoom * job->dpi / POINTS_PER_INCH;
-    if (gvre) {
-       job->compscale.y *= (job->render_features->flags & GVRENDER_Y_GOES_DOWN) ? -1. : 1.;
+    job->compscale.y *= (job->flags & GVRENDER_Y_GOES_DOWN) ? -1. : 1.;
+    if (job->rotation) {
+       job->offset.x = -job->focus.y * job->compscale.x + job->width / 2.;
+       job->offset.y = -job->focus.x * job->compscale.y + job->height / 2.;
+    } else {
+       job->offset.x = -job->focus.x * job->compscale.x + job->width / 2.;
+       job->offset.y = -job->focus.y * job->compscale.y + job->height / 2.;
+    }
 
+    if (gvre) {
        /* render specific init */
        if (gvre->begin_graph)
            gvre->begin_graph(job, gvc->graphname);