From: ellson Date: Sat, 29 Jul 2006 22:30:11 +0000 (+0000) Subject: eliminate job->comptrans X-Git-Tag: LAST_LIBGRAPH~32^2~6020 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b46d18129fff2a94f704829680fcde87dd924ade;p=graphviz eliminate job->comptrans fix bug with landscape bugs in -Tgif --- diff --git a/lib/common/emit.c b/lib/common/emit.c index e4599e431..0914731d5 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -364,7 +364,7 @@ static void setup_page(GVJ_t * job, graph_t * g) if (job->rotation) { if (job->flags & GVRENDER_Y_GOES_DOWN) { job->translation.x = -job->pageBox.UR.x - job->pageBoundingBox.LL.x / job->scale.x; - job->translation.y = job->pageBox.UR.y + job->pageBoundingBox.LL.y / job->scale.y; + job->translation.y = -job->pageBox.UR.y - job->pageBoundingBox.LL.y / job->scale.y; } else { job->translation.x = -job->pageBox.LL.x + job->pageBoundingBox.LL.y / job->scale.y; @@ -374,15 +374,13 @@ static void setup_page(GVJ_t * job, graph_t * g) else { job->translation.x = -job->pageBox.LL.x + job->pageBoundingBox.LL.x / job->scale.x; if (job->flags & GVRENDER_Y_GOES_DOWN) - job->translation.y = job->pageBox.UR.y + job->pageBoundingBox.LL.y / job->scale.y; + job->translation.y = -job->pageBox.UR.y - job->pageBoundingBox.LL.y / job->scale.y; else job->translation.y = -job->pageBox.LL.y + job->pageBoundingBox.LL.y / job->scale.y; } job->compscale = job->scale; job->compscale.y *= (job->flags & GVRENDER_Y_GOES_DOWN) ? -1. : 1.; - job->comptrans = job->translation; - job->comptrans.y *= (job->flags & GVRENDER_Y_GOES_DOWN) ? -1: 1; } #if 0 diff --git a/lib/gvc/gvcjob.h b/lib/gvc/gvcjob.h index 84ef73559..a2f6f51fe 100644 --- a/lib/gvc/gvcjob.h +++ b/lib/gvc/gvcjob.h @@ -263,11 +263,10 @@ extern "C" { box pageBoundingBox;/* rotated boundingBox - device units */ box boundingBox; /* cumulative boundingBox over all pages - device units */ - pointf scale; /* composite device scale (zoom and dpi) */ + pointf scale; /* composite device scale (zoom and dpi) */ pointf translation; /* composite translation */ pointf compscale; /* composite device scale incl: zoom, dpi, y_goes_down */ - pointf comptrans; /* composite translation */ - + bool fit_mode, needs_refresh, click, diff --git a/lib/gvc/gvevent.c b/lib/gvc/gvevent.c index cc1248cc6..0e2e9294d 100644 --- a/lib/gvc/gvevent.c +++ b/lib/gvc/gvevent.c @@ -292,29 +292,29 @@ static void gvevent_enter_obj(GVJ_t * job) static void gvevent_find_current_obj(GVJ_t * job, pointf pointer) { void *obj; - pointf p; + pointf p, translation = job->translation, scale = job->compscale; boxf b; double closeenough; if (job->rotation) { - p.x = pointer.y / job->compscale.y - job->comptrans.x; - p.y = -pointer.x / job->compscale.x - job->comptrans.y; + p.x = pointer.y / scale.y - translation.x; + p.y = -pointer.x / scale.x - translation.y; } else { - p.x = pointer.x / job->compscale.x - job->comptrans.x; - p.y = pointer.y / job->compscale.y - job->comptrans.y; + p.x = pointer.x / scale.x - translation.x; + p.y = pointer.y / scale.y - translation.y; } #if 0 fprintf(stderr,"pointer = %g,%g compscale = %g,%g comptrans = %g,%g, graphpoint = %g,%g\n", pointer.x, pointer.y, - job->compscale.x, job->compscale.y, - job->comptrans.x, job->comptrans.y, + scale.x, scale.y, + trans.x, trans.y, p.x, p.y); #endif /* convert window point to graph coordinates */ - closeenough = CLOSEENOUGH / job->compscale.x; + closeenough = CLOSEENOUGH / scale.x; b.UR.x = p.x + closeenough; b.UR.y = p.y + closeenough; diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index 99b2d7893..9c6581796 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -288,14 +288,14 @@ void gvrender_end_job(GVJ_t * job) static pointf gvrender_ptf(GVJ_t *job, pointf p) { - pointf rv; + pointf rv, translation = job->translation, scale = job->compscale; if (job->rotation) { - rv.x = -(p.y + job->comptrans.y) * job->compscale.x; - rv.y = (p.x + job->comptrans.x) * job->compscale.y; + rv.x = -(p.y + translation.y) * scale.x; + rv.y = (p.x + translation.x) * scale.y; } else { - rv.x = (p.x + job->comptrans.x) * job->compscale.x; - rv.y = (p.y + job->comptrans.y) * job->compscale.y; + rv.x = (p.x + translation.x) * scale.x; + rv.y = (p.y + translation.y) * scale.y; } return rv; } @@ -306,18 +306,20 @@ static pointf gvrender_ptf(GVJ_t *job, pointf p) static pointf* gvrender_ptf_A(GVJ_t *job, pointf *af, pointf *AF, int n) { int i; - pointf trans = job->comptrans, scale = job->compscale; + pointf translation = job->translation, scale = job->compscale; + double t; if (job->rotation) { for (i = 0; i < n; i++) { - AF[i].x = -(af[i].y + trans.y) * scale.x; - AF[i].y = (af[i].x + trans.x) * scale.y; + t = -(af[i].y + translation.y) * scale.x; + AF[i].y = (af[i].x + translation.x) * scale.y; + AF[i].x = t; } } else { for (i = 0; i < n; i++) { - AF[i].x = (af[i].x + trans.x) * scale.x; - AF[i].y = (af[i].y + trans.y) * scale.y; + AF[i].x = (af[i].x + translation.x) * scale.x; + AF[i].y = (af[i].y + translation.y) * scale.y; } } return AF; diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index ec9360da5..d75ee745c 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -265,7 +265,7 @@ static void svggen_begin_page(GVJ_t * job) svggen_printf(job, "common->viewNum); svggen_printf(job, " transform=\"scale(%g %g) rotate(%d) translate(%g %g)\">\n", job->scale.x, job->scale.y, -job->rotation, - job->translation.x, job->translation.y); + job->translation.x, -job->translation.y); /* default style */ if (obj->g->name[0]) { svggen_fputs(job, ""); diff --git a/plugin/pango/gvrender_pango.c b/plugin/pango/gvrender_pango.c index 699f78562..60d891f3b 100644 --- a/plugin/pango/gvrender_pango.c +++ b/plugin/pango/gvrender_pango.c @@ -195,7 +195,7 @@ static void cairogen_begin_page(GVJ_t * job) cairo_save(cr); cairo_scale(cr, job->scale.x, job->scale.y); cairo_rotate(cr, -job->rotation * M_PI / 180.); - cairo_translate(cr, job->translation.x, job->translation.y); + cairo_translate(cr, job->translation.x, -job->translation.y); } static void cairogen_end_page(GVJ_t * job)