From d9f3bb777f14f667569e9b31d72c1b1ff7c1832e Mon Sep 17 00:00:00 2001 From: ellson Date: Fri, 13 May 2005 21:54:49 +0000 Subject: [PATCH] svgen.c fixes 2 less additions per rendererd point. --- graphviz.spec.in | 1 + lib/common/emit.c | 3 +++ lib/common/svggen.c | 38 +++++++++++++++++++++++--------------- lib/gvc/gvcint.h | 1 + lib/gvc/gvrender.c | 21 +++++++++++++++++++-- 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/graphviz.spec.in b/graphviz.spec.in index d5c98e649..5955ba779 100644 --- a/graphviz.spec.in +++ b/graphviz.spec.in @@ -1,3 +1,4 @@ +# $Id$ $Revision$ # @configure_input@ Summary: Graph Visualization Tools diff --git a/lib/common/emit.c b/lib/common/emit.c index c80212a91..731150432 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -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 diff --git a/lib/common/svggen.c b/lib/common/svggen.c index 61846ca12..c5c0ab7ae 100644 --- a/lib/common/svggen.c +++ b/lib/common/svggen.c @@ -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("\n", N_pages); - if (Dpi == POINTS_PER_INCH) + if (dpi == POINTS_PER_INCH) svg_printf("\n"); + svg_printf(" rx=\"%d\" ry=\"%d\"/>\n", mp.x, mp.y); } static void diff --git a/lib/gvc/gvcint.h b/lib/gvc/gvcint.h index 7a960d58e..59d9b3f48 100644 --- a/lib/gvc/gvcint.h +++ b/lib/gvc/gvcint.h @@ -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 */ diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index 2311e94b5..cc3a902d3 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -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); -- 2.40.0