Browse Source

Check for either MONITOR or GRASS_RENDER_IMMEDIATE
(merge https://trac.osgeo.org/grass/changeset/63361,63742,63747-63748,63751-63752)


git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@63753 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 10 years ago
parent
commit
3dd61849ec
2 changed files with 22 additions and 10 deletions
  1. 13 6
      lib/display/r_raster.c
  2. 9 4
      lib/init/variables.html

+ 13 - 6
lib/display/r_raster.c

@@ -3,7 +3,7 @@
 
   \brief Display Library - Raster graphics subroutines
 
-  (C) 2001-2009, 2011 by the GRASS Development Team
+  (C) 2001-2014 by the GRASS Development Team
 
   This program is free software under the GNU General Public License
   (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -71,6 +71,8 @@ int read_env_file(const char *path)
     FILE *fd;
     char buf[1024];
     char **token;
+
+    G_debug(1, "read_env_file(): %s", path);
     
     fd = fopen(path, "r");
     if (!fd)
@@ -101,6 +103,7 @@ int read_env_file(const char *path)
 int D_open_driver(void)
 {
     const char *p, *m;
+    const struct driver *drv;
     
     G_debug(1, "D_open_driver():");
     p = getenv("GRASS_RENDER_IMMEDIATE");
@@ -109,7 +112,8 @@ int D_open_driver(void)
     if (m && G_strncasecmp(m, "wx", 2) == 0) {
 	/* wx monitors always use GRASS_RENDER_IMMEDIATE. */
 	p = NULL; /* use default display driver */
-    } else if (m) {
+    }
+    else if (m) {
 	char *env;
 	const char *v;
 	char *u_m;
@@ -133,8 +137,14 @@ int D_open_driver(void)
 	if (v) 
 	    read_env_file(v);
     }
+    else if (!p)
+	G_fatal_error(_("Neither %s (managed by d.mon command) nor %s (used for direct rendering) defined"),
+		      "MONITOR", "GRASS_RENDER_IMMEDIATE");
+
+    if (p && G_strcasecmp(p, "default") == 0)
+	p = NULL;
     
-    const struct driver *drv =
+    drv =
 	(p && G_strcasecmp(p, "png")   == 0) ? PNG_Driver() :
 	(p && G_strcasecmp(p, "ps")    == 0) ? PS_Driver() :
 	(p && G_strcasecmp(p, "html")  == 0) ? HTML_Driver() :
@@ -152,9 +162,6 @@ int D_open_driver(void)
 
     init();
 
-    if (!getenv("GRASS_RENDER_IMMEDIATE") && !m)
-	return 1;
-
     return 0;
 }
 

+ 9 - 4
lib/init/variables.html

@@ -329,15 +329,20 @@ PERMANENT
 
 <h3>List of selected GRASS environment variables for rendering</h3>
 <blockquote>
-[ In addition to those which are understood by specific <em>GRASS display
- drivers</em>, the following variables affect rendering. ]
+[ In addition to those which are understood by
+ specific <em><a href="displaydrivers.html">GRASS display
+ drivers</a></em>, the following variables affect rendering. ]
 </blockquote>
 
 <dl>
   <dt>GRASS_RENDER_IMMEDIATE</dt>
   <dd>tells the display library which driver to use; possible
-  values: <em><a href="cairodriver.html">cairo</a></em>, <em><a href="pngdriver.html">png</a></em>, <em><a href="psdriver.html">ps</a></em>
-  or <em><a href="htmldriver.html">html</a></em></dd>
+  values: <em><a href="cairodriver.html">cairo</a></em>, <em><a href="pngdriver.html">png</a></em>, <em><a href="psdriver.html">ps</a></em>,
+    <em><a href="htmldriver.html">html</a></em>
+    or <em>default</em><br>Default display driver
+    is <em><a href="cairodriver.html">cairo</a></em> (if available)
+    otherwise <em><a href="pngdriver.html">png</a></em>.
+  </dd>
   
   <dt>GRASS_RENDER_WIDTH</dt>
   <dd>defines the width of output image (default is 640).</dd>