From 408b8aecb88214fb71040217963a47096313bc42 Mon Sep 17 00:00:00 2001 From: ellson Date: Tue, 1 Feb 2005 16:45:15 +0000 Subject: [PATCH] fix problem with PS %BoundingBox for scaled graphs (e.g.crazy.dot) --- lib/common/emit.c | 18 ++++++++++-------- lib/gvc/gvcint.h | 8 ++++---- lib/gvc/gvrender.c | 7 ++----- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 5ad1c8393..6b6ad0909 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -298,10 +298,12 @@ static void init_job_pagination(GVC_t * gvc, graph_t * g) job->pageBox.LL.x += extra.x / 2; job->pageBox.LL.y += extra.y / 2; } - /* FIXME - this is used by begin_graph, but overwritten by setup_page - so it will be wrong if two PS outputs generated from same graph. - Perhaps it should be "pageBoundingBox" or somesuch ? */ - job->pageBox.UR = add_pointfs(job->pageBox.LL, job->pageSize); + + /* FIXME, the treatment of margins doesn't look right. are margins + in device coords or graph coords ? what happens to margins under zooming */ + PF2P(job->pageBox.LL,job->boundingBox.LL); + job->boundingBox.UR.x = ROUND(job->pageBox.LL.x + job->pageSize.x * job->zoom); + job->boundingBox.UR.y = ROUND(job->pageBox.LL.y + job->pageSize.y * job->zoom); } static void firstpage(GVC_t *gvc) @@ -420,12 +422,12 @@ static void setup_page(GVC_t * gvc, graph_t * g) job->pageBox.UR.x = job->pageBox.LL.x + job->pageSize.x; job->pageBox.UR.y = job->pageBox.LL.y + job->pageSize.y; - /* establish offset to be applied, in graph coordinates */ + /* establish pageOffset to be applied, in graph coordinates */ if (job->rotation == 0) - job->offset = pointof(-job->pageBox.LL.x, -job->pageBox.LL.y); + job->pageOffset = pointof(-job->pageBox.LL.x, -job->pageBox.LL.y); else { - job->offset.x = (job->pagesArrayElem.y + 1) * job->pageSize.y; - job->offset.y = -(job->pagesArrayElem.x) * job->pageSize.x; + job->pageOffset.x = (job->pagesArrayElem.y + 1) * job->pageSize.y; + job->pageOffset.y = -(job->pagesArrayElem.x) * job->pageSize.x; } gvrender_begin_page(gvc); diff --git a/lib/gvc/gvcint.h b/lib/gvc/gvcint.h index 86669227c..fb44a99f8 100644 --- a/lib/gvc/gvcint.h +++ b/lib/gvc/gvcint.h @@ -89,9 +89,9 @@ extern "C" { pointf margin; /* job-specific margin */ int rotation; /* job-specific page rotation */ - boxf pageBox; /* drawable region in device coords */ - /* basically width*height - margins */ - pointf pageSize; /* device page size */ + box boundingBox; /* drawable region in device coords */ + boxf pageBox; /* drawable region in graph coords */ + pointf pageSize; /* page size in graph coords */ pointf pageSizeCentered; /* device page box for centering */ point pagesArraySize; /* 2D size of page array */ point pagesArrayFirst; /* 2D starting corner in */ @@ -100,7 +100,7 @@ extern "C" { point pagesArrayElem; /* 2D coord of current page - 0,0 based */ int numPages; /* number of pages */ int pageNum; /* current page - 1 based */ - point offset; /* offset for current page */ + point pageOffset; /* offset for current page in graph coords */ unsigned int width; /* width in pixels */ unsigned int height; /* height in pixels */ diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index c0d9f0ff9..bcec11622 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -260,12 +260,9 @@ void gvrender_begin_graph(GVC_t * gvc, graph_t * g) #ifndef DISABLE_CODEGENS else { codegen_t *cg = job->codegen; - box bb; - BF2B(job->pageBox, bb); - if (cg && cg->begin_graph) - cg->begin_graph(gvc, g, bb, gvc->pb); + cg->begin_graph(gvc, g, job->boundingBox, gvc->pb); } #endif } @@ -300,7 +297,7 @@ void gvrender_begin_page(GVC_t * gvc) codegen_t *cg = job->codegen; if (cg && cg->begin_page) - cg->begin_page(job->g, job->pagesArrayElem, job->zoom, job->rotation, job->offset); + cg->begin_page(job->g, job->pagesArrayElem, job->zoom, job->rotation, job->pageOffset); } #endif } -- 2.40.0