]> granicus.if.org Git - graphviz/commitdiff
fix zooming and clipping behaviors
authorellson <devnull@localhost>
Sat, 13 Sep 2008 03:17:18 +0000 (03:17 +0000)
committerellson <devnull@localhost>
Sat, 13 Sep 2008 03:17:18 +0000 (03:17 +0000)
lib/common/emit.c
lib/gvc/gvevent.c

index e9bd0a3cc1000c4e8f1d5d66c3c76dbacc96c585..7b876b9f71f321d2998b3e6536a69ca438ab5e5e 100644 (file)
@@ -848,10 +848,19 @@ static void setup_page(GVJ_t * job, graph_t * g)
     job->pageOffset.x = - job->pageSize.x * pagesArrayElem.x;
     job->pageOffset.y = - job->pageSize.y * pagesArrayElem.y;
 #endif
-    job->clip.LL.x = job->focus.x + job->pageSize.x * (pagesArrayElem.x - pagesArraySize.x / 2.);
-    job->clip.LL.y = job->focus.y + job->pageSize.y * (pagesArrayElem.y - pagesArraySize.y / 2.) - 1;
-    job->clip.UR.x = job->clip.LL.x + job->pageSize.x + 1;
-    job->clip.UR.y = job->clip.LL.y + job->pageSize.y + 1;
+
+    if (job->flags & GVDEVICE_EVENTS) {
+        job->clip.LL.x = job->focus.x - job->view.x / 2.;
+        job->clip.LL.y = job->focus.y - job->view.y / 2.;
+        job->clip.UR.x = job->focus.x + job->view.x / 2.;
+        job->clip.UR.y = job->focus.y + job->view.y / 2.;
+    }
+    else {
+        job->clip.LL.x = job->focus.x + job->pageSize.x * (pagesArrayElem.x - pagesArraySize.x / 2.);
+        job->clip.LL.y = job->focus.y + job->pageSize.y * (pagesArrayElem.y - pagesArraySize.y / 2.) - 1;
+        job->clip.UR.x = job->clip.LL.x + job->pageSize.x + 1;
+        job->clip.UR.y = job->clip.LL.y + job->pageSize.y + 1;
+    }
 
     /* CAUTION - job->translation was difficult to get right. */
     /* Test with and without assymetric margins, e.g: -Gmargin="1,0" */
@@ -2267,13 +2276,17 @@ void emit_graph(GVJ_t * job, graph_t * g)
 
     /* compute current view in graph units */
     if (job->rotation) {
-       job->view.y = job->width / job->scale.x;
-       job->view.x = job->height / job->scale.y;
+       job->view.y = job->width / job->scale.y;
+       job->view.x = job->height / job->scale.x;
     }
     else {
        job->view.x = job->width / job->scale.x;
        job->view.y = job->height / job->scale.y;
     }
+#if 0
+fprintf(stderr,"focus=%g,%g view=%g,%g\n",
+       job->focus.x, job->focus.y, job->view.x, job->view.y);
+#endif
 
     s = late_string(g, agfindattr(g, "comment"), "");
     gvrender_comment(job, s);
index af46ef2b59305ae4672d0153a1db8a6e45511c21..76ff5e273a69bf9d8b633bb1774e605e5d5d9559 100644 (file)
@@ -410,15 +410,15 @@ static void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
 /* FIXME - should code window 0,0 point as feature with Y_GOES_DOWN */
         job->fit_mode = 0;
         if (job->rotation) {
-            job->focus.x -= (pointer.y - job->height)
+            job->focus.x -= (pointer.y - job->height / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.y);
-            job->focus.y += (pointer.x)
+            job->focus.y += (pointer.x - job->width / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.x);
         }
         else {
-            job->focus.x += (pointer.x)
+            job->focus.x += (pointer.x - job->width / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.x);
-            job->focus.y += (pointer.y - job->height)
+            job->focus.y += (pointer.y - job->height / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.y);
         }
         job->zoom *= ZOOMFACTOR;
@@ -428,15 +428,15 @@ static void gvevent_button_press(GVJ_t * job, int button, pointf pointer)
         job->fit_mode = 0;
         job->zoom /= ZOOMFACTOR;
         if (job->rotation) {
-            job->focus.x += (pointer.y - job->height)
+            job->focus.x += (pointer.y - job->height / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.y);
-            job->focus.y -= (pointer.x)
+            job->focus.y -= (pointer.x - job->width / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.x);
         }
         else {
-            job->focus.x -= (pointer.x)
+            job->focus.x -= (pointer.x - job->width / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.x);
-            job->focus.y -= (pointer.y - job->height)
+            job->focus.y -= (pointer.y - job->height / 2.)
                     * (ZOOMFACTOR - 1.) / (job->zoom * job->devscale.y);
         }
         job->needs_refresh = 1;