From 36302b1d3e4becd5e15ab18aa8d0099e8d8b68e5 Mon Sep 17 00:00:00 2001 From: ellson Date: Fri, 13 May 2005 18:48:14 +0000 Subject: [PATCH] partially fix "whitespace" issue in svggen.c --- lib/common/emit.c | 1 + lib/common/svggen.c | 89 +++++++++++++++++---------------------------- lib/gvc/gvrender.c | 17 +++------ 3 files changed, 40 insertions(+), 67 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 102d36bd2..c80212a91 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1050,6 +1050,7 @@ static void init_job_dpi(GVJ_t *job, graph_t *g) job->dpi = job->render_features->default_dpi; break; case POSTSCRIPT: + case SVG: job->dpi = POINTS_PER_INCH; break; default: diff --git a/lib/common/svggen.c b/lib/common/svggen.c index 996b0c44e..61846ca12 100644 --- a/lib/common/svggen.c +++ b/lib/common/svggen.c @@ -110,12 +110,17 @@ static char *sdotarray = "1,5"; static int N_pages; /* static point Pages; */ -static double Scale; -static pointf Offset; static int Rot; -static box PB; static int onetime = TRUE; +static int Dpi; +static pointf CompScale; +static int Rot; + +static point Viewport; +static pointf GraphFocus; +static double Zoom; + static node_t *Curnode; typedef struct context_t { @@ -200,12 +205,12 @@ static point svgpt(point p) { point rv; - if (Rot == 0) { - rv.x = PB.LL.x / Scale + p.x + Offset.x; - rv.y = PB.UR.y / Scale - 1 - p.y - Offset.y; + if (Rot) { + rv.x = ROUND(-(p.y - GraphFocus.y) * CompScale.x + Viewport.x / 2.); + rv.y = ROUND((p.x - GraphFocus.x) * CompScale.y + Viewport.y / 2.); } else { - rv.x = PB.UR.x / Scale - 1 - p.y - Offset.x; - rv.y = PB.UR.y / Scale - 1 - p.x - Offset.y; + rv.x = ROUND((p.x - GraphFocus.x) * CompScale.x + Viewport.x / 2.); + rv.y = ROUND((p.y - GraphFocus.y) * CompScale.y + Viewport.y / 2.); } return rv; } @@ -403,18 +408,9 @@ svg_begin_job(FILE * ofp, graph_t * g, char **lib, char *user, svg_fputs("proto->n, "href") - || agfindattr(g->proto->e, "href") - || agfindattr(g, "URL") - || agfindattr(g->proto->n, "URL") - || agfindattr(g->proto->e, "URL"))) { - svg_fputs - (" [\n \n]"); - } -#endif + svg_fputs + (" [\n \n]"); svg_fputs(">\n\n", N_pages); + svg_fputs(" -->\n"); } static void svg_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb) { - double dpi = GD_drawing(g)->dpi; + 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; - PB.LL.x = PB.LL.y = 0; - PB.UR.x = (bb.UR.x - bb.LL.x + 2 * GD_drawing(g)->margin.x) * SCALE; - PB.UR.y = (bb.UR.y - bb.LL.y + 2 * GD_drawing(g)->margin.y) * SCALE; - Offset.x = GD_drawing(g)->margin.x * SCALE; - Offset.y = GD_drawing(g)->margin.y * SCALE; if (onetime) { -#if 0 - fprintf(stderr, "LL %d %d UR %d %d\n", PB.LL.x, PB.LL.y, PB.UR.x, - PB.UR.y); -#endif init_svg(); onetime = FALSE; } - if (dpi < 1.0) + svg_fputs("\n", N_pages); + if (Dpi == POINTS_PER_INCH) svg_printf("proto->n, "href") - || agfindattr(g->proto->e, "href") - || agfindattr(g, "URL") - || agfindattr(g->proto->n, "URL") - || agfindattr(g->proto->e, "URL"))) { - svg_fputs(" xmlns:xlink=\"http://www.w3.org/1999/xlink\""); - } + /* namespace of xlink */ + svg_fputs(" xmlns:xlink=\"http://www.w3.org/1999/xlink\""); svg_fputs(">\n"); } @@ -490,13 +475,7 @@ static void svg_begin_page(graph_t * g, point page, double scale, int rot, point offset) { -/* int page_number; */ - /* point sz; */ - - Scale = scale; Rot = rot; -/* page_number = page.x + page.y * Pages.x + 1; */ - /* sz = sub_points(PB.UR,PB.LL); */ /* its really just a page of the graph, but its still a graph, * and it is the entire graph if we're not currently paging */ @@ -748,8 +727,8 @@ static void svg_textline(point p, textline_t * line) if (Rot) { svg_printf(" transform=\"rotate(-90 %d %d)\"", mp.x, mp.y); } + svg_printf(" x=\"%d\" y=\"%d\"", mp.x, mp.y); svg_font(cp); - svg_printf(" x=\"%d\" y=\"%d", mp.x, mp.y); #if 0 /* adobe svg doesn't like the dx propert */ if (line->xshow) { @@ -757,7 +736,7 @@ static void svg_textline(point p, textline_t * line) svg_fputs(line->xshow); } #endif - svg_fputs("\">"); + svg_fputs(">"); svg_fputs(string); svg_fputs("\n"); } diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index c81715851..2311e94b5 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -206,16 +206,10 @@ static pointf gvrender_ptf(GVJ_t *job, pointf p) static pointf gvrender_pt(GVJ_t *job, point p) { - pointf rv; + pointf pf; - if (job->rotation) { - rv.x = -((double) p.y - job->focus.y) * job->compscale.x + job->width / 2.; - rv.y = ((double) p.x - job->focus.x) * job->compscale.y + job->height / 2.; - } else { - rv.x = ((double) p.x - job->focus.x) * job->compscale.x + job->width / 2.; - rv.y = ((double) p.y - job->focus.y) * job->compscale.y + job->height / 2.; - } - return rv; + P2PF(p, pf); + return gvrender_ptf(job, pf); } static int gvrender_comparestr(const void *s1, const void *s2) @@ -255,10 +249,9 @@ void gvrender_begin_graph(GVJ_t * job, graph_t * g) job->clip.LL.y = job->focus.y - sy - EPSILON; job->sg = g; /* current subgraph/cluster */ + job->compscale.y = job->compscale.x = job->zoom * job->dpi / POINTS_PER_INCH; if (gvre) { - job->compscale.x = job->zoom * job->dpi / POINTS_PER_INCH; - job->compscale.y = job->compscale.x * - ((job->render_features->flags & GVRENDER_Y_GOES_DOWN) ? -1.0 : 1.0); + job->compscale.y *= (job->render_features->flags & GVRENDER_Y_GOES_DOWN) ? -1. : 1.; /* render specific init */ if (gvre->begin_graph) -- 2.40.0