[GRASS-SVN] r64472 - in grass/branches/releasebranch_7_0: display/d.info include/defs lib/display
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Feb 5 06:47:04 PST 2015
Author: martinl
Date: 2015-02-05 06:47:04 -0800 (Thu, 05 Feb 2015)
New Revision: 64472
Modified:
grass/branches/releasebranch_7_0/display/d.info/main.c
grass/branches/releasebranch_7_0/include/defs/display.h
grass/branches/releasebranch_7_0/lib/display/r_raster.c
Log:
Fix d.info with regard to r62026 (ticket #2577)
(merge r64459 from trunk)
Modified: grass/branches/releasebranch_7_0/display/d.info/main.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.info/main.c 2015-02-05 13:46:12 UTC (rev 64471)
+++ grass/branches/releasebranch_7_0/display/d.info/main.c 2015-02-05 14:47:04 UTC (rev 64472)
@@ -21,9 +21,9 @@
int main(int argc, char *argv[])
{
struct GModule *module;
- struct Flag *rflag, *dflag, *fflag, *bflag, *gflag;
- double t, b, l, r;
- double n, s, e, w;
+ struct Flag *rflag, *dflag, *fflag, *eflag, *bflag, *gflag;
+ double st, sb, sl, sr;
+ double ft, fb, fl, fr;
G_gisinit(argv[0]);
@@ -49,6 +49,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");
@@ -56,32 +60,36 @@
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");
+ G_option_required(rflag, dflag, fflag, eflag, bflag, gflag, NULL);
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- if (!rflag->answer && !dflag->answer &&
- !fflag->answer && !bflag->answer && !gflag->answer) {
- G_fatal_error(_("No flag given"));
- }
-
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();
@@ -94,19 +102,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() );
}
Modified: grass/branches/releasebranch_7_0/include/defs/display.h
===================================================================
--- grass/branches/releasebranch_7_0/include/defs/display.h 2015-02-05 13:46:12 UTC (rev 64471)
+++ grass/branches/releasebranch_7_0/include/defs/display.h 2015-02-05 14:47:04 UTC (rev 64472)
@@ -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/branches/releasebranch_7_0/lib/display/r_raster.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/display/r_raster.c 2015-02-05 13:46:12 UTC (rev 64471)
+++ grass/branches/releasebranch_7_0/lib/display/r_raster.c 2015-02-05 14:47:04 UTC (rev 64472)
@@ -38,7 +38,7 @@
static struct {
double t, b, l, r;
-} screen;
+} screen, frame;
static void init(void)
{
@@ -46,7 +46,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");
@@ -63,12 +63,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;
}
int read_env_file(const char *path)
@@ -362,10 +363,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);
}
@@ -384,6 +385,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;
@@ -419,6 +440,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