From: ellson <devnull@localhost>
Date: Thu, 30 Dec 2004 04:32:35 +0000 (+0000)
Subject: compute a clip box in graph coords to enable clipping during emit
X-Git-Tag: LAST_LIBGRAPH~32^2~8175
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3367620016009da7191fca1f184b8c31740a708c;p=graphviz

compute a clip box in graph coords to enable clipping during emit
---

diff --git a/lib/common/emit.c b/lib/common/emit.c
index 19a7b47af..1872ef0c3 100644
--- a/lib/common/emit.c
+++ b/lib/common/emit.c
@@ -364,8 +364,7 @@ void emit_node(GVC_t * gvc, node_t * n)
 
     if (ND_shape(n) == NULL)
 	return;
-    if (node_in_layer(n->graph, n) && node_in_CB(n)
-	&& (ND_state(n) != Page)) {
+    if (node_in_layer(n->graph, n) && node_in_CB(n) && (ND_state(n) != Page)) {
 	gvrender_begin_node(gvc, n);
 	if (((s = agget(n, "href")) && s[0])
 	    || ((s = agget(n, "URL")) && s[0])) {
@@ -685,6 +684,11 @@ void emit_graph(GVC_t * gvc, graph_t * g, int flags)
     /* FIXME - some of setup_pagination should be in emit_init() */
     setup_pagination(gvc, g);
 
+    gvc->clip.UR.x = ROUND(gvc->focus.x + (gvc->width+1) / (gvc->zoom * 2.));
+    gvc->clip.UR.y = ROUND(gvc->focus.y + (gvc->height+1) / (gvc->zoom * 2.));
+    gvc->clip.LL.x = ROUND(gvc->focus.x - (gvc->width+1) / (gvc->zoom * 2.));
+    gvc->clip.LL.y = ROUND(gvc->focus.y - (gvc->height+1) / (gvc->zoom * 2.));
+
     gvrender_begin_graph(gvc, g, PB, PFC);
     if (flags & EMIT_COLORS) {
 	gvrender_set_fillcolor(gvc, DEFAULT_FILL);
diff --git a/lib/gvc/gvrenderint.h b/lib/gvc/gvrenderint.h
index 6091d5672..613ceef25 100644
--- a/lib/gvc/gvrenderint.h
+++ b/lib/gvc/gvrenderint.h
@@ -137,6 +137,7 @@ extern "C" {
 	double zoom;		/* viewport zoom factor */
 	pointf focus;		/* viewport focus in graph units */
 	pointf compscale;	/* composite device scale incl: scale, zoom, dpi, y_goes_down */
+	box clip;		/* clip region in graph units */
 
 	/* gvrender_begin_page() */
 	point page;