Browse Source

displaylib: add D_get_file (https://trac.osgeo.org/grass/ticket/2509)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@63464 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 years ago
parent
commit
7dd693b6ae

+ 2 - 0
include/defs/display.h

@@ -166,4 +166,6 @@ void D_get_frame(double *, double *, double *, double *);
 void D_set_clip_window_to_map_window(void);
 void D_set_clip_window_to_screen_window(void);
 
+const char *D_get_file(void);
+
 #endif /* GRASS_DISPLAYDEFS_H */

+ 1 - 0
lib/cairodriver/cairodriver.h

@@ -84,6 +84,7 @@ extern const struct driver *Cairo_Driver(void);
 
 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);

+ 3 - 2
lib/cairodriver/driver.c

@@ -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 @@ const struct driver *Cairo_Driver(void)
     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 @@ const struct driver *Cairo_Driver(void)
     drv.Set_font = Cairo_set_font;
     drv.Font_list = Cairo_font_list;
     drv.Font_info = Cairo_font_info;
-
+      
     initialized = 1;
 
     return &drv;

+ 10 - 0
lib/cairodriver/graph.c

@@ -279,6 +279,16 @@ int Cairo_Graph_set(void)
 }
 
 /*!
+  \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)

+ 12 - 0
lib/display/setup.c

@@ -17,6 +17,8 @@
 #include <grass/raster.h>
 #include <grass/display.h>
 
+#include "driver.h"
+
 /*!
   \brief Graphics frame setup
 
@@ -130,3 +132,13 @@ void D_setup2(int clear, int fit, double st, double sb, double sl, double sr)
 
     D_set_clip_window_to_map_window();
 }
+
+/*!
+  \brief Get driver output file
+
+  \return file name or NULL if not defined
+*/
+const char *D_get_file(void)
+{
+    return COM_Graph_get_file();
+}

+ 3 - 1
lib/driver/driver.h

@@ -22,11 +22,12 @@ extern struct GFONT_CAP *ftcap;
 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 @@ extern void COM_Get_text_box(const char *, double *, double *, double *, double
 /* 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);

+ 9 - 0
lib/driver/graph.c

@@ -1,3 +1,4 @@
+#include <stdlib.h>
 #include "driver.h"
 #include "driverlib.h"
 
@@ -13,3 +14,11 @@ void COM_Graph_close(void)
     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;
+}

+ 1 - 0
lib/htmldriver/driver.c

@@ -30,6 +30,7 @@ const struct driver *HTML_Driver(void)
     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;

+ 2 - 1
lib/pngdriver/driver.c

@@ -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 @@ const struct driver *PNG_Driver(void)
     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;

+ 10 - 0
lib/pngdriver/graph_set.c

@@ -171,3 +171,13 @@ int PNG_Graph_set(void)
 
     return 0;
 }
+
+/*!
+  \brief Get render file
+
+  \return file name
+*/
+const char *PNG_Graph_get_file(void)
+{
+    return png.file_name;
+}

+ 1 - 0
lib/pngdriver/pngdriver.h

@@ -76,6 +76,7 @@ extern void PNG_Client_Close(void);
 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 *,

+ 1 - 0
lib/psdriver/driver.c

@@ -32,6 +32,7 @@ const struct driver *PS_Driver(void)
     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;

+ 10 - 0
lib/psdriver/graph_set.c

@@ -220,6 +220,16 @@ int PS_Graph_set(void)
     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;

+ 1 - 0
lib/psdriver/psdriver.h

@@ -31,6 +31,7 @@ extern void PS_Client_Close(void);
 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);