[GRASS-SVN] r63533 - in grass/branches/releasebranch_7_0: . display/d.mon include/defs lib/cairodriver lib/display lib/driver lib/htmldriver lib/pngdriver lib/psdriver
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 14 01:58:50 PST 2014
Author: martinl
Date: 2014-12-14 01:58:50 -0800 (Sun, 14 Dec 2014)
New Revision: 63533
Modified:
grass/branches/releasebranch_7_0/
grass/branches/releasebranch_7_0/display/d.mon/start.c
grass/branches/releasebranch_7_0/include/defs/display.h
grass/branches/releasebranch_7_0/lib/cairodriver/cairodriver.h
grass/branches/releasebranch_7_0/lib/cairodriver/driver.c
grass/branches/releasebranch_7_0/lib/cairodriver/graph.c
grass/branches/releasebranch_7_0/lib/display/r_raster.c
grass/branches/releasebranch_7_0/lib/display/setup.c
grass/branches/releasebranch_7_0/lib/driver/driver.h
grass/branches/releasebranch_7_0/lib/driver/graph.c
grass/branches/releasebranch_7_0/lib/htmldriver/driver.c
grass/branches/releasebranch_7_0/lib/pngdriver/driver.c
grass/branches/releasebranch_7_0/lib/pngdriver/graph_set.c
grass/branches/releasebranch_7_0/lib/pngdriver/pngdriver.h
grass/branches/releasebranch_7_0/lib/psdriver/driver.c
grass/branches/releasebranch_7_0/lib/psdriver/graph_set.c
grass/branches/releasebranch_7_0/lib/psdriver/psdriver.h
Log:
displaylib: add D_get_file (#2509)
d.mon: use always full path for output files (even if using default file name) - #2509
d.mon: fix #2509 (d.mon output overwrite)
d.mon: stop monitor on failure (#2509)
displaylib: display driver lower case by default (cosmetics)
d.mon: print warning when overwritting the output file
(merge r63464-r63470 from trunk)
Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
- /grass/trunk:60817,61096,61141,61994,62105,62179-62180,62182,62403,62422,62424,62437,62466,62469,62487,62491,62494,62501,62506,62508-62509,62515,62518-62519,62521,62526,62533,62539,62541,62555,62562,62566,62570,62573,62575,62585,62588,62597,62603,62606,62608-62609,62614,62618,62628,62632,62638,62642,62648-62649,62652,62654-62657,62666,62691,62705,62709,62723,62730,62739,62741,62743,62746,62750,62752,62757,62762,62785,62798,62800-62801,62803,62805,62812,62822,62824,62831,62838,62847,62850,62856,62879,62881,62886,62904,62907-62908,62910,62912,62914,62916,62918,62920,62925,62932-62933,62935,62940,62942,62944-62946,62949,62955-62956,62958,62960,62962,62964,62966-62968,62970,62973,62975,62977,62981,62983,62985,62987,62989,62991,62993,62995,62997,62999-63000,63003,63005,63007,63009,63011,63013,63015,63017,63020,63022,63024,63026,63028-63031,63033,63035,63037,63040,63043-63044,63047,63049,63051,63053,63055,63057,63060,63062-63064,63066,63068,63070-63071,63074,63076,63079,63081,
63083,63085,63087,63089,63091,63093,63095,63098,63100,63102,63105,63107,63109,63111,63113-63114,63116,63119,63121,63123,63125,63130,63132-63133,63135,63137,63140,63143,63145,63147,63149,63151,63153-63154,63157,63160,63165,63170,63173,63175,63187,63192-63193,63196,63199-63200,63202,63209,63216,63220-63221,63224,63227,63240,63246,63250,63255,63259,63261,63276,63279,63281,63283,63287,63290,63292,63302,63307,63315,63319,63330,63332,63339,63342,63345,63362,63367,63391,63393,63408-63409,63416-63417,63425,63427,63429,63431,63433,63451,63453,63457,63459,63473,63482,63497,63505,63508,63510,63515,63524,63526
+ /grass/trunk:60817,61096,61141,61994,62105,62179-62180,62182,62403,62422,62424,62437,62466,62469,62487,62491,62494,62501,62506,62508-62509,62515,62518-62519,62521,62526,62533,62539,62541,62555,62562,62566,62570,62573,62575,62585,62588,62597,62603,62606,62608-62609,62614,62618,62628,62632,62638,62642,62648-62649,62652,62654-62657,62666,62691,62705,62709,62723,62730,62739,62741,62743,62746,62750,62752,62757,62762,62785,62798,62800-62801,62803,62805,62812,62822,62824,62831,62838,62847,62850,62856,62879,62881,62886,62904,62907-62908,62910,62912,62914,62916,62918,62920,62925,62932-62933,62935,62940,62942,62944-62946,62949,62955-62956,62958,62960,62962,62964,62966-62968,62970,62973,62975,62977,62981,62983,62985,62987,62989,62991,62993,62995,62997,62999-63000,63003,63005,63007,63009,63011,63013,63015,63017,63020,63022,63024,63026,63028-63031,63033,63035,63037,63040,63043-63044,63047,63049,63051,63053,63055,63057,63060,63062-63064,63066,63068,63070-63071,63074,63076,63079,63081,
63083,63085,63087,63089,63091,63093,63095,63098,63100,63102,63105,63107,63109,63111,63113-63114,63116,63119,63121,63123,63125,63130,63132-63133,63135,63137,63140,63143,63145,63147,63149,63151,63153-63154,63157,63160,63165,63170,63173,63175,63187,63192-63193,63196,63199-63200,63202,63209,63216,63220-63221,63224,63227,63240,63246,63250,63255,63259,63261,63276,63279,63281,63283,63287,63290,63292,63302,63307,63315,63319,63330,63332,63339,63342,63345,63362,63367,63391,63393,63408-63409,63416-63417,63425,63427,63429,63431,63433,63451,63453,63457,63459,63464-63470,63473,63482,63497,63505,63508,63510,63515,63524,63526
Modified: grass/branches/releasebranch_7_0/display/d.mon/start.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.mon/start.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/display/d.mon/start.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -2,6 +2,7 @@
#include <string.h>
#include <grass/gis.h>
#include <grass/spawn.h>
+#include <grass/display.h>
#include <grass/glocale.h>
#include "proto.h"
@@ -9,16 +10,43 @@
static void start(const char *, const char *);
static void start_wx(const char *, const char *, const char *,
const char *, int, int);
+static void error_handler(void *);
/* start file-based monitor */
void start(const char *name, const char *output)
{
char *env_name, output_path[GPATH_MAX];
+ const char *output_name;
- if (!output)
- return;
+ /* stop monitor on failure */
+ G_add_error_handler(error_handler, (char *)name);
+
+ if (!output) {
+ if (D_open_driver() != 0)
+ G_fatal_error(_("No graphics device selected. "
+ "Use d.mon to select graphics device."));
+ output_name = D_get_file();
+ if (!output_name)
+ return;
+ if (access(output_name, F_OK) == 0) {
+ if (G_get_overwrite()) {
+ G_warning(_("File '%s' already exists and will be overwritten"), output_name);
+ }
+ else {
+ D_close_driver();
+ G_fatal_error(_("option <%s>: <%s> exists."),
+ "output", output_name);
+ }
+ }
+ D_close_driver(); /* must be called after check because this
+ * function produces default map file */
+ }
+ else {
+ output_name = output;
+ }
- if (!strchr(output, HOST_DIRSEP)) { /* relative path */
+
+ if (!strchr(output_name, HOST_DIRSEP)) { /* relative path */
char *ptr;
if (!getcwd(output_path, GPATH_MAX))
@@ -28,13 +56,13 @@
*(ptr++) = HOST_DIRSEP;
*(ptr) = '\0';
}
- strcat(output_path, output);
+ strcat(output_path, output_name);
G_message(_("Output file: %s"), output_path);
}
else {
- strcpy(output_path, output); /* already full path */
+ strcpy(output_path, output_name); /* already full path */
}
-
+
env_name = NULL;
G_asprintf(&env_name, "MONITOR_%s_MAPFILE", G_store_upper(name));
G_setenv(env_name, output_path);
@@ -157,3 +185,9 @@
return 0;
}
+
+void error_handler(void *p)
+{
+ const char *name = (const char *) p;
+ stop_mon(name);
+}
Modified: grass/branches/releasebranch_7_0/include/defs/display.h
===================================================================
--- grass/branches/releasebranch_7_0/include/defs/display.h 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/include/defs/display.h 2014-12-14 09:58:50 UTC (rev 63533)
@@ -162,4 +162,6 @@
void D_font_list(char ***, int *);
void D_font_info(char ***, int *);
+const char *D_get_file(void);
+
#endif /* GRASS_DISPLAYDEFS_H */
Modified: grass/branches/releasebranch_7_0/lib/cairodriver/cairodriver.h
===================================================================
--- grass/branches/releasebranch_7_0/lib/cairodriver/cairodriver.h 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/cairodriver/cairodriver.h 2014-12-14 09:58:50 UTC (rev 63533)
@@ -84,6 +84,7 @@
extern void Cairo_Client_Close(void);
extern int Cairo_Graph_set(void);
+extern const char *Cairo_Graph_get_file(void);
extern void Cairo_Graph_close(void);
extern void Cairo_Box(double, double, double, double);
extern void Cairo_Set_window(double, double, double, double);
Modified: grass/branches/releasebranch_7_0/lib/cairodriver/driver.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/cairodriver/driver.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/cairodriver/driver.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -3,7 +3,7 @@
\brief GRASS cairo display driver - driver initialization
- (C) 2007-2008, 2011 by Lars Ahlzen and the GRASS Development Team
+ (C) 2007-2014 by Lars Ahlzen and 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.
@@ -31,6 +31,7 @@
drv.Box = Cairo_Box;
drv.Erase = Cairo_Erase;
drv.Graph_set = Cairo_Graph_set;
+ drv.Graph_get_file = Cairo_Graph_get_file;
drv.Graph_close = Cairo_Graph_close;
drv.Line_width = Cairo_Line_width;
drv.Set_window = Cairo_Set_window;
@@ -51,7 +52,7 @@
drv.Set_font = Cairo_set_font;
drv.Font_list = Cairo_font_list;
drv.Font_info = Cairo_font_info;
-
+
initialized = 1;
return &drv;
Modified: grass/branches/releasebranch_7_0/lib/cairodriver/graph.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/cairodriver/graph.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/cairodriver/graph.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -286,6 +286,16 @@
}
/*!
+ \brief Get render file
+
+ \return file name
+*/
+const char *Cairo_Graph_get_file(void)
+{
+ return ca.file_name;
+}
+
+/*!
\brief Close driver
*/
void Cairo_Graph_close(void)
Modified: grass/branches/releasebranch_7_0/lib/display/r_raster.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/display/r_raster.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/display/r_raster.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -135,9 +135,9 @@
}
const struct driver *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() :
+ (p && G_strcasecmp(p, "png") == 0) ? PNG_Driver() :
+ (p && G_strcasecmp(p, "ps") == 0) ? PS_Driver() :
+ (p && G_strcasecmp(p, "html") == 0) ? HTML_Driver() :
#ifdef USE_CAIRO
(p && G_strcasecmp(p, "cairo") == 0) ? Cairo_Driver() :
Cairo_Driver();
Modified: grass/branches/releasebranch_7_0/lib/display/setup.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/display/setup.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/display/setup.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -17,6 +17,8 @@
#include <grass/raster.h>
#include <grass/display.h>
+#include "driver.h"
+
/*!
\brief Graphics frame setup
@@ -118,3 +120,13 @@
if (clear)
D_erase(DEFAULT_BG_COLOR);
}
+
+/*!
+ \brief Get driver output file
+
+ \return file name or NULL if not defined
+*/
+const char *D_get_file(void)
+{
+ return COM_Graph_get_file();
+}
Modified: grass/branches/releasebranch_7_0/lib/driver/driver.h
===================================================================
--- grass/branches/releasebranch_7_0/lib/driver/driver.h 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/driver/driver.h 2014-12-14 09:58:50 UTC (rev 63533)
@@ -22,11 +22,12 @@
struct driver
{
char *name;
-
+
void (*Box)(double, double, double, double);
void (*Erase)(void);
int (*Graph_set)(void);
void (*Graph_close)(void);
+ const char * (*Graph_get_file)(void);
void (*Line_width)(double);
void (*Set_window)(double, double, double, double);
void (*Begin_raster)(int, int[2][2], double[2][2]);
@@ -82,6 +83,7 @@
/* graph.c */
extern int COM_Graph_set(void);
extern void COM_Graph_close(void);
+extern const char *COM_Graph_get_file(void);
/* line_width.c */
extern void COM_Line_width(double);
Modified: grass/branches/releasebranch_7_0/lib/driver/graph.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/driver/graph.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/driver/graph.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include "driver.h"
#include "driverlib.h"
@@ -13,3 +14,11 @@
if (driver->Graph_close)
(*driver->Graph_close) ();
}
+
+const char *COM_Graph_get_file(void)
+{
+ if (driver->Graph_get_file)
+ return (*driver->Graph_get_file) ();
+
+ return NULL;
+}
Modified: grass/branches/releasebranch_7_0/lib/htmldriver/driver.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/htmldriver/driver.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/htmldriver/driver.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -30,6 +30,7 @@
drv.Erase = NULL;
drv.Graph_set = HTML_Graph_set;
drv.Graph_close = HTML_Graph_close;
+ drv.Graph_get_file = NULL;
drv.Line_width = NULL;
drv.Set_window = NULL;
drv.Begin_raster = NULL;
Modified: grass/branches/releasebranch_7_0/lib/pngdriver/driver.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/pngdriver/driver.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/pngdriver/driver.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -3,7 +3,7 @@
\brief GRASS png display driver - driver initialization
- (C) 2007 by Glynn Clements and the GRASS Development Team
+ (C) 2007-2014 by Glynn Clements and 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.
@@ -31,6 +31,7 @@
drv.Erase = PNG_Erase;
drv.Graph_set = PNG_Graph_set;
drv.Graph_close = PNG_Graph_close;
+ drv.Graph_get_file = PNG_Graph_get_file;
drv.Line_width = PNG_Line_width;
drv.Set_window = PNG_Set_window;
drv.Begin_raster = PNG_begin_raster;
Modified: grass/branches/releasebranch_7_0/lib/pngdriver/graph_set.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/pngdriver/graph_set.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/pngdriver/graph_set.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -171,3 +171,13 @@
return 0;
}
+
+/*!
+ \brief Get render file
+
+ \return file name
+*/
+const char *PNG_Graph_get_file(void)
+{
+ return png.file_name;
+}
Modified: grass/branches/releasebranch_7_0/lib/pngdriver/pngdriver.h
===================================================================
--- grass/branches/releasebranch_7_0/lib/pngdriver/pngdriver.h 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/pngdriver/pngdriver.h 2014-12-14 09:58:50 UTC (rev 63533)
@@ -76,6 +76,7 @@
extern void PNG_Erase(void);
extern void PNG_Graph_close(void);
extern int PNG_Graph_set(void);
+extern const char *PNG_Graph_get_file(void);
extern void PNG_Line_width(double);
extern void PNG_begin_raster(int, int[2][2], double[2][2]);
extern int PNG_raster(int, int, const unsigned char *,
Modified: grass/branches/releasebranch_7_0/lib/psdriver/driver.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/psdriver/driver.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/psdriver/driver.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -32,6 +32,7 @@
drv.Erase = PS_Erase;
drv.Graph_set = PS_Graph_set;
drv.Graph_close = PS_Graph_close;
+ drv.Graph_get_file = PS_Graph_get_file;
drv.Line_width = PS_Line_width;
drv.Set_window = PS_Set_window;
drv.Begin_raster = PS_begin_raster;
Modified: grass/branches/releasebranch_7_0/lib/psdriver/graph_set.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/psdriver/graph_set.c 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/psdriver/graph_set.c 2014-12-14 09:58:50 UTC (rev 63533)
@@ -220,6 +220,16 @@
return 0;
}
+/*!
+ \brief Get render file
+
+ \return file name
+*/
+const char *PS_Graph_get_file(void)
+{
+ return file_name;
+}
+
void output(const char *fmt, ...)
{
va_list va;
Modified: grass/branches/releasebranch_7_0/lib/psdriver/psdriver.h
===================================================================
--- grass/branches/releasebranch_7_0/lib/psdriver/psdriver.h 2014-12-13 23:40:06 UTC (rev 63532)
+++ grass/branches/releasebranch_7_0/lib/psdriver/psdriver.h 2014-12-14 09:58:50 UTC (rev 63533)
@@ -31,6 +31,7 @@
extern void PS_Erase(void);
extern void PS_Graph_close(void);
extern int PS_Graph_set(void);
+extern const char *PS_Graph_get_file(void);
extern void PS_Line_width(double);
extern void PS_Set_window(double, double, double, double);
extern void PS_Color(int, int, int);
More information about the grass-commit
mailing list