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;
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
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,
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;
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;
}
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;
svggen_printf(job, "<g id=\"graph%d\" class=\"graph\"", 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, "<title>");
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)