From 1bff0cbfb0b0d24e3b3365c5562db392c33a8ece Mon Sep 17 00:00:00 2001 From: ellson Date: Tue, 25 Sep 2007 19:13:00 +0000 Subject: [PATCH] fix viewport size and focus calculations, correct documentation --- doc/info/attrs.html | 3 +-- lib/common/emit.c | 27 +++++++++++---------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/doc/info/attrs.html b/doc/info/attrs.html index 837dca898..c76ab20ad 100644 --- a/doc/info/attrs.html +++ b/doc/info/attrs.html @@ -1805,8 +1805,7 @@ the given types. dimensions (width and height) of the viewport image, in points, in the original graph drawing. - The optional Z is the zoom factor, i.e., the resulting image will be - Z*W by Z*H points in size. By default, Z is 1. + The optional Z is the zoom factor. By default, Z is 1. The optional pair (x,y) give the position in the graph, in points, of the center of the viewport. To focus on a particular node, (x,y) can be set to the diff --git a/lib/common/emit.c b/lib/common/emit.c index 71e6db278..cc281e55e 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -637,8 +637,7 @@ static void init_job_pagination(GVJ_t * job, graph_t *g) pointf centering = {0.0, 0.0}; /* centering offset - points */ /* unpaginated image size - in points - in graph orientation */ - imageSize.x = job->zoom*job->view.x; - imageSize.y = job->zoom*job->view.y; + imageSize = job->view; /* rotate imageSize to page orientation */ if (job->rotation) @@ -808,8 +807,7 @@ static void setup_page(GVJ_t * job, graph_t * g) { obj_state_t *obj = job->obj; int nump = 0, flags = job->flags; - pointf *p = NULL; - pointf sz, UR; + pointf sz, *p = NULL; box cbb; /* establish current box in graph units */ @@ -828,9 +826,9 @@ static void setup_page(GVJ_t * job, graph_t * g) job->pageOffset.y = job->pad.y - job->pageSize.y * job->pagesArrayElem.y; } - /* calculate clip region in graph units using width/heigh since window might - have been resized since view was calculated */ - sz.x = job->width / (job->scale.y * 2.); + /* calculate clip region in graph units using width/height since window + * might have been resized since view was calculated */ + sz.x = job->width / (job->scale.x * 2.); sz.y = job->height / (job->scale.y * 2.); if (job->rotation) sz = exch_xyf(sz); @@ -890,9 +888,8 @@ static void setup_page(GVJ_t * job, graph_t * g) } } - P2PF(job->view, UR); - job->translation.x -= job->focus.x + job->pad.x - (UR.x / 2.0); - job->translation.y -= job->focus.y + job->pad.y - (UR.y / 2.0); + job->translation.x -= job->focus.x + job->pad.x - job->view.x / (job->zoom * 2.0); + job->translation.y -= job->focus.y + job->pad.y - job->view.y / (job->zoom * 2.0); if ((flags & (GVRENDER_DOES_MAPS | GVRENDER_DOES_TOOLTIPS)) && (obj->url || obj->explicit_tooltip)) { @@ -2027,8 +2024,8 @@ static void init_job_viewport(GVJ_t * job, graph_t * g) /* rotate and scale bb to give default absolute size in points*/ job->rotation = job->gvc->rotation; - X = sz.x; - Y = sz.y; + X = sz.x * Z; + Y = sz.y * Z; /* user can override */ if ((str = agget(g, "viewport"))) @@ -2036,10 +2033,8 @@ static void init_job_viewport(GVJ_t * job, graph_t * g) /* rv is ignored since args retain previous values if not scanned */ /* job->view gives port size in graph units, unscaled or rotated - * job->focus gives center of port in graph units - * job->zoom gives scaling factor for viewport in device; that is, - * final image will be (view.x*zoom, view.y*zoom) (possibly - * 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; -- 2.50.1