[GRASS-SVN] r62026 - in grass/trunk: display/d.info include/defs lib/display

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 17 15:43:22 PDT 2014


Author: glynn
Date: 2014-09-17 15:43:22 -0700 (Wed, 17 Sep 2014)
New Revision: 62026

Modified:
   grass/trunk/display/d.info/main.c
   grass/trunk/include/defs/display.h
   grass/trunk/lib/display/r_raster.c
   grass/trunk/lib/display/setup.c
Log:
Change handling of display frame, graphical clip window
 Replace D_get_window with D_get_frame
 Add D_get_clip_window, D_set_clip_window
 Add D_set_clip_window_to_map_window, D_set_clip_window_to_screen_window
 Store initial frame size within display library
 Change D_setup* functions to set graphical clip window



Modified: grass/trunk/display/d.info/main.c
===================================================================
--- grass/trunk/display/d.info/main.c	2014-09-17 20:43:55 UTC (rev 62025)
+++ grass/trunk/display/d.info/main.c	2014-09-17 22:43:22 UTC (rev 62026)
@@ -71,7 +71,7 @@
 			"Use d.mon to select graphics device."));
     
     if (rflag->answer || dflag->answer || fflag->answer)
-	D_get_window(&t, &b, &l, &r);
+	D_get_frame(&t, &b, &l, &r);
 
 
     if (rflag->answer)

Modified: grass/trunk/include/defs/display.h
===================================================================
--- grass/trunk/include/defs/display.h	2014-09-17 20:43:55 UTC (rev 62025)
+++ grass/trunk/include/defs/display.h	2014-09-17 22:43:22 UTC (rev 62026)
@@ -149,8 +149,6 @@
 void D_close_driver(void);
 int D_save_command(const char *);
 
-void D_get_window(double *, double *, double *, double *);
-
 void D__erase(void);
 
 void D_text_size(double, double);
@@ -162,4 +160,10 @@
 void D_font_list(char ***, int *);
 void D_font_info(char ***, int *);
 
+void D_get_clip_window(double *, double *, double *, double *);
+void D_set_clip_window(double, double, double, double);
+void D_get_frame(double *, double *, double *, double *);
+void D_set_clip_window_to_map_window(void);
+void D_set_clip_window_to_screen_window(void);
+
 #endif /* GRASS_DISPLAYDEFS_H */

Modified: grass/trunk/lib/display/r_raster.c
===================================================================
--- grass/trunk/lib/display/r_raster.c	2014-09-17 20:43:55 UTC (rev 62025)
+++ grass/trunk/lib/display/r_raster.c	2014-09-17 22:43:22 UTC (rev 62026)
@@ -36,6 +36,10 @@
 
 static int read_env_file(const char *);
 
+static struct {
+    double t, b, l, r;
+} screen;
+
 static void init(void)
 {
     const char *fenc = getenv("GRASS_ENCODING");
@@ -60,10 +64,11 @@
     D_text_rotation(0);
 
     if (frame) {
-	double t, b, l, r;
-	sscanf(frame, "%lf,%lf,%lf,%lf", &t, &b, &l, &r);
-	COM_Set_window(t, b, l, r);
+	sscanf(frame, "%lf,%lf,%lf,%lf", &screen.t, &screen.b, &screen.l, &screen.r);
+	COM_Set_window(screen.t, screen.b, screen.l, screen.r);
     }
+    else
+	COM_Get_window(&screen.t, &screen.b, &screen.l, &screen.r);
 }
 
 int read_env_file(const char *path)
@@ -266,19 +271,6 @@
 }
 
 /*!
-  \brief Get clipping frame
-  
-  \param[out] t top
-  \param[out] b bottom
-  \param[out] l left
-  \param[out] r right
-*/
-void D_get_window(double *t, double *b, double *l, double *r)
-{
-    return COM_Get_window(t, b, l, r);
-}
-
-/*!
   \brief Draw text
   
   Writes <em>text</em> in the current color and font, at the current text
@@ -334,3 +326,96 @@
 {
     COM_Font_info(list, count);
 }
+
+/*!
+ * \brief get graphical clipping window
+ *
+ * Queries the graphical clipping window (origin is top right)
+ *
+ *  \param[out] t top edge of clip window
+ *  \param[out] b bottom edge of clip window
+ *  \param[out] l left edge of clip window
+ *  \param[out] r right edge of clip window
+ *  \return ~
+ */
+
+void D_get_clip_window(double *t, double *b, double *l, double *r)
+{
+    COM_Get_window(t, b, l, r);
+}
+
+/*!
+ * \brief set graphical clipping window
+ *
+ * Sets the graphical clipping window to the specified rectangle
+ *  (origin is top right)
+ *
+ *  \param t top edge of clip window
+ *  \param b bottom edge of clip window
+ *  \param l left edge of clip window
+ *  \param r right edge of clip window
+ *  \return ~
+ */
+
+void D_set_clip_window(double t, double b, double l, double r)
+{
+    if (t < screen.t) t = screen.t;
+    if (b > screen.b) b = screen.b;
+    if (l < screen.l) l = screen.l;
+    if (r > screen.r) r = screen.r;
+
+    COM_Set_window(t, b, l, r);
+}
+
+/*!
+ * \brief get graphical window (frame)
+ *
+ * Queries the graphical frame (origin is top right)
+ *
+ *  \param[out] t top edge of frame
+ *  \param[out] b bottom edge of frame
+ *  \param[out] l left edge of frame
+ *  \param[out] r right edge of frame
+ *  \return ~
+ */
+
+void D_get_frame(double *t, double *b, double *l, double *r)
+{
+    *t = screen.t;
+    *b = screen.b;
+    *l = screen.l;
+    *r = screen.r;
+}
+
+/*!
+ * \brief set graphical clipping window to map window
+ *
+ * Sets the graphical clipping window to the pixel window that corresponds
+ * to the current database region.
+ *
+ *  \param ~
+ *  \return ~
+ */
+
+void D_set_clip_window_to_map_window(void)
+{
+    D_set_clip_window(
+	D_get_d_north(), D_get_d_south(),
+	D_get_d_west(), D_get_d_east());
+}
+
+/*!
+ * \brief set clipping window to screen window
+ *
+ * Sets the clipping window to the pixel window that corresponds to the
+ * full screen window. Off screen rendering is still clipped.
+ *
+ *  \param ~
+ *  \return ~
+ */
+
+void D_set_clip_window_to_screen_window(void)
+{
+    COM_Set_window(screen.t, screen.b, screen.l, screen.r);
+}
+

Modified: grass/trunk/lib/display/setup.c
===================================================================
--- grass/trunk/lib/display/setup.c	2014-09-17 20:43:55 UTC (rev 62025)
+++ grass/trunk/lib/display/setup.c	2014-09-17 22:43:22 UTC (rev 62026)
@@ -46,15 +46,19 @@
     struct Cell_head region;
     double dt, db, dl, dr;
 
-    D_get_window(&dt, &db, &dl, &dr);
+    D_get_frame(&dt, &db, &dl, &dr);
 
     G_get_set_window(&region);
     Rast_set_window(&region);
 
     D_do_conversions(&region, dt, db, dl, dr);
 
+    D_set_clip_window_to_screen_window();
+
     if (clear)
 	D_erase(DEFAULT_BG_COLOR);
+
+    D_set_clip_window_to_map_window();
 }
 
 /*!
@@ -73,15 +77,19 @@
 {
     double dt, db, dl, dr;
 
-    D_get_window(&dt, &db, &dl, &dr);
+    D_get_frame(&dt, &db, &dl, &dr);
 
     D_set_src(dt, db, dl, dr);
     D_set_dst(dt, db, dl, dr);
 
     D_update_conversions();
 
+    D_set_clip_window_to_screen_window();
+
     if (clear)
 	D_erase(DEFAULT_BG_COLOR);
+
+    D_set_clip_window_to_map_window();
 }
 
 /*!
@@ -105,7 +113,7 @@
 {
     double dt, db, dl, dr;
 
-    D_get_window(&dt, &db, &dl, &dr);
+    D_get_frame(&dt, &db, &dl, &dr);
 
     D_set_src(st, sb, sl, sr);
     D_set_dst(dt, db, dl, dr);
@@ -115,6 +123,10 @@
 
     D_update_conversions();
 
+    D_set_clip_window_to_screen_window();
+
     if (clear)
 	D_erase(DEFAULT_BG_COLOR);
+
+    D_set_clip_window_to_map_window();
 }



More information about the grass-commit mailing list