[GRASS-SVN] r58382 - grass/trunk/display/d.mon

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Dec 4 02:11:36 PST 2013


Author: martinl
Date: 2013-12-04 02:11:36 -0800 (Wed, 04 Dec 2013)
New Revision: 58382

Modified:
   grass/trunk/display/d.mon/main.c
   grass/trunk/display/d.mon/proto.h
   grass/trunk/display/d.mon/start.c
Log:
d.mon: implement `resolution` parameter (similar to d.out.file in G6)


Modified: grass/trunk/display/d.mon/main.c
===================================================================
--- grass/trunk/display/d.mon/main.c	2013-12-04 00:55:30 UTC (rev 58381)
+++ grass/trunk/display/d.mon/main.c	2013-12-04 10:11:36 UTC (rev 58382)
@@ -25,7 +25,7 @@
 {
     struct GModule *module;
     struct Option *start_opt, *select_opt, *stop_opt, *output_opt,
-      *width_opt, *height_opt, *bgcolor_opt;
+        *width_opt, *height_opt, *bgcolor_opt, *res_opt;
     struct Flag *list_flag, *selected_flag, *select_flag, *release_flag, 
         *cmd_flag, *truecolor_flag, *update_flag;
     
@@ -63,18 +63,28 @@
 
     width_opt = G_define_option();
     width_opt->key = "width";
-    width_opt->description = _("Width for display monitor if not set by GRASS_WIDTH");
+    width_opt->label = _("Width for display monitor if not set by GRASS_WIDTH");
+    width_opt->description = _("Default value: 640");
     width_opt->type = TYPE_INTEGER;
     width_opt->key_desc = "value";
     width_opt->guisection = _("Settings");
 
     height_opt = G_define_option();
     height_opt->key = "height";
-    height_opt->description = _("Height for display monitor if not set by GRASS_HEIGHT");
+    height_opt->label = _("Height for display monitor if not set by GRASS_HEIGHT");
+    height_opt->description = _("Default value: 480");
     height_opt->type = TYPE_INTEGER;
     height_opt->key_desc = "value";
     height_opt->guisection = _("Settings");
 
+    res_opt = G_define_option();
+    res_opt->key = "resolution";
+    res_opt->label = _("Dimensions of display monitor versus current size");
+    res_opt->description = _("Example: resolution=2 enlarge display monitor twice to 1280x960"); 
+    res_opt->type = TYPE_INTEGER;
+    res_opt->key_desc = "value";
+    res_opt->guisection = _("Settings");
+
     bgcolor_opt = G_define_standard_option(G_OPT_C_BG);
     bgcolor_opt->guisection = _("Settings");
 
@@ -170,8 +180,20 @@
 	G_warning(_("Option <%s> ignored"), output_opt->key);
     
     if (start_opt->answer) {
+        int width, height;
+
+        width = width_opt->answer ? atoi(width_opt->answer) : 640;
+        height = height_opt->answer ? atoi(height_opt->answer) : 480;
+        if (res_opt->answer) {
+            int res;
+            
+            res = atoi(res_opt->answer);
+            width *= res;
+            height *= res;
+        }
+
 	ret = start_mon(start_opt->answer, output_opt->answer, !select_flag->answer,
-			width_opt->answer, height_opt->answer, bgcolor_opt->answer,
+			width, height, bgcolor_opt->answer,
 			!truecolor_flag->answer);
         if (output_opt->answer && !update_flag->answer) {
             if (D_open_driver() != 0)

Modified: grass/trunk/display/d.mon/proto.h
===================================================================
--- grass/trunk/display/d.mon/proto.h	2013-12-04 00:55:30 UTC (rev 58381)
+++ grass/trunk/display/d.mon/proto.h	2013-12-04 10:11:36 UTC (rev 58382)
@@ -1,6 +1,6 @@
 /* start */
-int start_mon(const char *, const char *, int, const char *,
-	      const char *, const char *, int);
+int start_mon(const char *, const char *, int, int, int,
+	      const char *, int);
 
 /* select.c */
 int select_mon(const char *);

Modified: grass/trunk/display/d.mon/start.c
===================================================================
--- grass/trunk/display/d.mon/start.c	2013-12-04 00:55:30 UTC (rev 58381)
+++ grass/trunk/display/d.mon/start.c	2013-12-04 10:11:36 UTC (rev 58382)
@@ -8,7 +8,7 @@
 
 static void start(const char *, const char *);
 static void start_wx(const char *, const char *, const char *,
-		     const char *, const char *, const char *);
+		     const char *, int, int);
 
 /* start file-based monitor */
 void start(const char *name, const char *output)
@@ -26,10 +26,10 @@
 /* start wxGUI display monitor */
 void start_wx(const char *name, const char *tempfile,
 	      const char *env_value, const char *cmd_value,
-	      const char *width, const char *height)
+	      int width, int height)
 {
     char progname[GPATH_MAX];
-    char *env_name, *map_value;
+    char *env_name, *map_value, str_width[1024], str_height[1024];
 
     env_name = NULL;
     G_asprintf(&env_name, "MONITOR_%s_MAPFILE", name);
@@ -40,12 +40,22 @@
     G_debug(3, "       mapfile = %s", map_value);
 
     sprintf(progname, "%s/etc/gui/wxpython/mapdisp/main.py", G_gisbase());
+    if (width > 0)
+        sprintf(str_width, "%d", width);
+    else
+        str_width[0] = '\0';
+    if (height > 0)
+        sprintf(str_height, "%d", height);
+    else
+        str_height[0] = '\0';
+
     G_spawn_ex(getenv("GRASS_PYTHON"), progname, progname,
-	       name, map_value, cmd_value, env_value, width ? width : "", height ? height : "", SF_BACKGROUND, NULL);
+	       name, map_value, cmd_value, env_value,
+               str_width, str_height, SF_BACKGROUND, NULL);
 }
 
 int start_mon(const char *name, const char *output, int select,
-	      const char *width, const char *height, const char *bgcolor,
+	      int width, int height, const char *bgcolor,
 	      int truecolor)
 {
     const char *curr_mon;
@@ -70,11 +80,11 @@
     sprintf(buf, "GRASS_PNG_READ=TRUE\n");
     write(env_fd, buf, strlen(buf));
     if (width) {
-	sprintf(buf, "GRASS_WIDTH=%s\n", width);
+	sprintf(buf, "GRASS_WIDTH=%d\n", width);
 	write(env_fd, buf, strlen(buf));
     }
     if (height) {
-	sprintf(buf, "GRASS_HEIGHT=%s\n", height);
+	sprintf(buf, "GRASS_HEIGHT=%d\n", height);
 	write(env_fd, buf, strlen(buf));
     }
     if (bgcolor) {



More information about the grass-commit mailing list