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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 4 04:25:43 PST 2015


Author: glynn
Date: 2015-02-04 04:25:43 -0800 (Wed, 04 Feb 2015)
New Revision: 64459

Modified:
   grass/trunk/display/d.info/main.c
   grass/trunk/include/defs/display.h
   grass/trunk/lib/display/r_raster.c
Log:
Fix d.info with regard to r62026 (ticket #2577)


Modified: grass/trunk/display/d.info/main.c
===================================================================
--- grass/trunk/display/d.info/main.c	2015-02-04 09:24:00 UTC (rev 64458)
+++ grass/trunk/display/d.info/main.c	2015-02-04 12:25:43 UTC (rev 64459)
@@ -24,9 +24,9 @@
 int main(int argc, char *argv[])
 {
     struct GModule *module;
-    struct Flag *rflag, *dflag, *fflag, *bflag, *gflag, *sflag;
-    double t, b, l, r;
-    double n, s, e, w;
+    struct Flag *rflag, *dflag, *fflag, *eflag, *bflag, *gflag, *sflag;
+    double st, sb, sl, sr;
+    double ft, fb, fl, fr;
 
     G_gisinit(argv[0]);
 
@@ -52,6 +52,10 @@
     fflag->key = 'f';
     fflag->description = _("Display active frame rectangle");
 
+    eflag = G_define_flag();
+    eflag->key = 'e';
+    eflag->description = _("Display frame dimensions (width, height)");
+
     bflag = G_define_flag();
     bflag->key = 'b';
     bflag->description = _("Display screen rectangle of current region");
@@ -59,34 +63,41 @@
     gflag = G_define_flag();
     gflag->key = 'g';
     gflag->description =
-	_("Display geographic coordinates and resolution of entire screen");
+	_("Display geographic coordinates and resolution of entire frame");
 
     sflag = G_define_flag();
     sflag->key = 's';
     sflag->description =
 	_("Print path to support files of currently selected monitor");
 
-    G_option_required(rflag, dflag, fflag, bflag, gflag, sflag, NULL);
+    G_option_required(rflag, dflag, fflag, eflag, bflag, gflag, sflag, NULL);
     
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
     D_open_driver();
     
-    if (rflag->answer || dflag->answer || fflag->answer)
-	D_get_frame(&t, &b, &l, &r);
+    if (rflag->answer || dflag->answer)
+	D_get_screen(&st, &sb, &sl, &sr);
+    
+    if (fflag->answer || eflag->answer || gflag->answer)
+	D_get_frame(&ft, &fb, &fl, &fr);
 
 
     if (rflag->answer)
-	fprintf(stdout, "rectangle: %f %f %f %f\n", l, r, t, b);
+	fprintf(stdout, "screen rectangle: %f %f %f %f\n", sl, sr, st, sb);
 
     if (dflag->answer)
-	fprintf(stdout, "dimensions: %f %f\n", r - l, b - t);
+	fprintf(stdout, "screen dimensions: %f %f\n", sr - sl, sb - st);
 
     if (fflag->answer)
-	fprintf(stdout, "frame: %f %f %f %f\n", l, r, t, b);
+	fprintf(stdout, "frame rectangle: %f %f %f %f\n", fl, fr, ft, fb);
 
+    if (eflag->answer)
+	fprintf(stdout, "frame dimensions: %f %f\n", fr - fl, fb - ft);
+
     if (bflag->answer) {
+	double t, b, l, r;
 	D_setup(0);
 
 	l = D_get_d_west();
@@ -99,19 +110,20 @@
 
     if (gflag->answer) {
 	/* outer bounds of the screen (including margins) */
+	double n, s, e, w;
 	D_setup(0);
 
-	n = D_get_u_north();
-	s = D_get_u_south();
-	w = D_get_u_west();
-	e = D_get_u_east();
+	n = D_d_to_u_row(ft);
+	s = D_d_to_u_row(fb);
+	w = D_d_to_u_col(fl);
+	e = D_d_to_u_col(fr);
 
 	fprintf(stdout, "n=%f\n", n );
 	fprintf(stdout, "s=%f\n", s );
 	fprintf(stdout, "w=%f\n", w );
 	fprintf(stdout, "e=%f\n", e );
-	fprintf(stdout, "ewres=%.15g\n", (e-w)/(r-l) );
-	fprintf(stdout, "nsres=%.15g\n", (n-s)/(b-t) );
+	fprintf(stdout, "ewres=%.15g\n",  D_get_d_to_u_xconv() );
+	fprintf(stdout, "nsres=%.15g\n", -D_get_d_to_u_yconv() );
     }
 
     if (sflag->answer) {

Modified: grass/trunk/include/defs/display.h
===================================================================
--- grass/trunk/include/defs/display.h	2015-02-04 09:24:00 UTC (rev 64458)
+++ grass/trunk/include/defs/display.h	2015-02-04 12:25:43 UTC (rev 64459)
@@ -162,6 +162,7 @@
 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_get_screen(double *, double *, double *, double *);
 void D_set_clip_window_to_map_window(void);
 void D_set_clip_window_to_screen_window(void);
 

Modified: grass/trunk/lib/display/r_raster.c
===================================================================
--- grass/trunk/lib/display/r_raster.c	2015-02-04 09:24:00 UTC (rev 64458)
+++ grass/trunk/lib/display/r_raster.c	2015-02-04 12:25:43 UTC (rev 64459)
@@ -37,7 +37,7 @@
 
 static struct {
     double t, b, l, r;
-} screen;
+} screen, frame;
 
 static void init(void)
 {
@@ -45,7 +45,7 @@
     const char *font = getenv("GRASS_FONT");
     const char *line_width = getenv("GRASS_RENDER_LINE_WIDTH");
     const char *text_size = getenv("GRASS_RENDER_TEXT_SIZE");
-    const char *frame = getenv("GRASS_RENDER_FRAME");
+    const char *frame_str = getenv("GRASS_RENDER_FRAME");
 
     D_font(font ? font : "romans");
 
@@ -62,12 +62,13 @@
 
     D_text_rotation(0);
 
-    if (frame) {
-	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);
+    COM_Get_window(&screen.t, &screen.b, &screen.l, &screen.r);
+    if (frame_str) {
+	sscanf(frame_str, "%lf,%lf,%lf,%lf", &frame.t, &frame.b, &frame.l, &frame.r);
+	COM_Set_window(frame.t, frame.b, frame.l, frame.r);
     }
     else
-	COM_Get_window(&screen.t, &screen.b, &screen.l, &screen.r);
+	frame = screen;
 }
 
 /*!
@@ -298,10 +299,10 @@
 
 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;
+    if (t < frame.t) t = frame.t;
+    if (b > frame.b) b = frame.b;
+    if (l < frame.l) l = frame.l;
+    if (r > frame.r) r = frame.r;
 
     COM_Set_window(t, b, l, r);
 }
@@ -320,6 +321,26 @@
 
 void D_get_frame(double *t, double *b, double *l, double *r)
 {
+    *t = frame.t;
+    *b = frame.b;
+    *l = frame.l;
+    *r = frame.r;
+}
+
+/*!
+ * \brief get screen bounds
+ *
+ * Queries the screen bounds (origin is top right)
+ *
+ *  \param[out] t top edge of screen
+ *  \param[out] b bottom edge of screen
+ *  \param[out] l left edge of screen
+ *  \param[out] r right edge of screen
+ *  \return ~
+ */
+
+void D_get_screen(double *t, double *b, double *l, double *r)
+{
     *t = screen.t;
     *b = screen.b;
     *l = screen.l;
@@ -355,6 +376,6 @@
 
 void D_set_clip_window_to_screen_window(void)
 {
-    COM_Set_window(screen.t, screen.b, screen.l, screen.r);
+    COM_Set_window(frame.t, frame.b, frame.l, frame.r);
 }
 



More information about the grass-commit mailing list