GRASS GIS 7 Programmer's Manual  7.8.3(2020)-exported
cairodriver/graph.c
Go to the documentation of this file.
1 /*!
2  \file lib/cairodriver/graph.c
3 
4  \brief GRASS cairo display driver - driver settings
5 
6  (C) 2007-2008, 2011 by Lars Ahlzen and the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Lars Ahlzen <lars ahlzen.com> (original contibutor)
12  \author Glynn Clements
13 */
14 
15 #include "cairodriver.h"
16 
17 #if CAIRO_HAS_PS_SURFACE
18 #include <cairo-ps.h>
19 #endif
20 #if CAIRO_HAS_PDF_SURFACE
21 #include <cairo-pdf.h>
22 #endif
23 #if CAIRO_HAS_SVG_SURFACE
24 #include <cairo-svg.h>
25 #endif
26 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
27 #include <cairo-xlib.h>
28 #include <cairo-xlib-xrender.h>
29 #endif
30 
31 #include <unistd.h>
32 #ifndef __MINGW32__
33 #include <fcntl.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <sys/mman.h>
37 #endif
38 
39 #include <grass/colors.h>
40 #include <grass/glocale.h>
41 
42 struct cairo_state ca;
43 
44 /* cairo objects */
45 cairo_surface_t *surface;
46 cairo_t *cairo;
47 
48 static void init_cairo(void);
49 static int ends_with(const char *string, const char *suffix);
50 static void map_file(void);
51 
52 static void init_xlib(void)
53 {
54 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
55  char *p;
56  unsigned long xid;
57  XVisualInfo templ;
58  XVisualInfo *vinfo;
59  int count;
60  Visual *visual;
61  int scrn;
62  Pixmap pix;
63  cairo_surface_t *s1, *s2;
64 
65  ca.dpy = XOpenDisplay(NULL);
66  if (!ca.dpy)
67  G_fatal_error(_("Unable to open display"));
68 
69  p = getenv("GRASS_RENDER_CAIRO_SCREEN");
70  if (!p || sscanf(p, "%i", &scrn) != 1) {
71  G_debug(1, "cairo: GRASS_RENDER_CAIRO_SCREEN=%s", p);
72  scrn = DefaultScreen(ca.dpy);
73  }
74 
75  p = getenv("GRASS_RENDER_CAIRO_VISUAL");
76  if (!p || sscanf(p, "%li", &xid) != 1) {
77  G_debug(1, "cairo: GRASS_RENDER_CAIRO_VISUAL=%s", p);
78  xid = DefaultVisual(ca.dpy, scrn)->visualid;
79  }
80  templ.visualid = xid;
81  templ.screen = scrn;
82 
83  vinfo = XGetVisualInfo(ca.dpy, VisualIDMask|VisualScreenMask, &templ, &count);
84  if (!vinfo || !count)
85  G_fatal_error(_("Unable to obtain visual"));
86  visual = vinfo[0].visual;
87 
88  ca.screen = ScreenOfDisplay(ca.dpy, scrn);
89  pix = XCreatePixmap(ca.dpy, RootWindow(ca.dpy, scrn), 1, 1, vinfo[0].depth);
90  s1 = cairo_xlib_surface_create(ca.dpy, pix, visual, 1, 1);
91  s2 = cairo_surface_create_similar(s1, CAIRO_CONTENT_COLOR_ALPHA, 1, 1);
92  ca.format = cairo_xlib_surface_get_xrender_format(s2);
93  ca.depth = cairo_xlib_surface_get_depth(s2);
94  cairo_surface_destroy(s2);
95  cairo_surface_destroy(s1);
96  XFreePixmap(ca.dpy, pix);
97 
98  if (!ca.win)
99  ca.win = XCreatePixmap(
100  ca.dpy, RootWindow(ca.dpy, scrn),
101  ca.width, ca.height, ca.depth);
102 #endif
103 }
104 
105 static void fini_xlib(void)
106 {
107 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
108  XSetCloseDownMode(ca.dpy, RetainTemporary);
109  XCloseDisplay(ca.dpy);
110 #endif
111 }
112 
113 static void init_file(void)
114 {
115  int is_vector = 0;
116  int is_xlib = 0;
117  int do_read = 0;
118  int do_map = 0;
119  char *p;
120 
121  /* set image properties */
124  ca.stride = ca.width * 4;
125 
126  /* get file name */
127  p = getenv("GRASS_RENDER_FILE");
128  if (!p || strlen(p) == 0)
129  p = DEFAULT_FILE_NAME;
130  G_debug(1, "cairo: GRASS_RENDER_FILE=%s", p);
131 
132  ca.file_name = p;
133 
134  /* get file type (from extension) */
135  if (ends_with(ca.file_name, ".ppm"))
137  else if (ends_with(ca.file_name, ".bmp"))
139 #if CAIRO_HAS_PNG_FUNCTIONS
140  else if (ends_with(ca.file_name, ".png"))
142 #endif
143 #if CAIRO_HAS_PDF_SURFACE
144  else if (ends_with(ca.file_name, ".pdf"))
146 #endif
147 #if CAIRO_HAS_PS_SURFACE
148  else if (ends_with(ca.file_name, ".ps"))
150 #endif
151 #if CAIRO_HAS_SVG_SURFACE
152  else if (ends_with(ca.file_name, ".svg"))
154 #endif
155 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
156  else if (ends_with(ca.file_name, ".xid"))
158 #endif
159  else
160  G_fatal_error(_("Unknown file extension: %s"), p);
161  G_debug(1, "cairo: file type=%d", ca.file_type);
162 
163  switch (ca.file_type) {
164  case FTYPE_PDF:
165  case FTYPE_PS:
166  case FTYPE_SVG:
167  is_vector = 1;
168  break;
169  case FTYPE_X11:
170  is_xlib = 1;
171  break;
172  }
173 
174  p = getenv("GRASS_RENDER_FILE_MAPPED");
175  do_map = p && strcmp(p, "TRUE") == 0 && ends_with(ca.file_name, ".bmp");
176  G_debug(1, "cairo: GRASS_RENDER_FILE_MAPPED=%d", do_map);
177 
178  p = getenv("GRASS_RENDER_FILE_READ");
179  do_read = p && strcmp(p, "TRUE") == 0;
180  G_debug(1, "cairo: GRASS_RENDER_FILE_READ=%d", do_read);
181 
182  if (is_vector) {
183  do_read = do_map = 0;
184  ca.bgcolor_a = 1.0;
185  }
186 
187  if (do_read && access(ca.file_name, 0) != 0)
188  do_read = 0;
189 
190  G_verbose_message(_("cairo: collecting to file '%s'"),
191  ca.file_name);
192  G_verbose_message(_("cairo: image size %dx%d"),
193  ca.width, ca.height);
194 
195  if (do_read && do_map)
196  map_file();
197 
198 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
199  if (is_xlib) {
200  if (do_read)
201  cairo_read_xid();
202  else
203  ca.win = 0;
204  init_xlib();
205  ca.mapped = 1;
206  }
207 #endif
208 
209  if (!ca.mapped && !is_vector)
210  ca.grid = G_malloc(ca.height * ca.stride);
211 
212  init_cairo();
213 
214  if (!do_read && !is_vector) {
215  Cairo_Erase();
216  ca.modified = 1;
217  }
218 
219  if (do_read && !ca.mapped)
221 
222  if (do_map && !ca.mapped) {
224  map_file();
225  init_cairo();
226  }
227 }
228 
229 /*!
230  \brief Initialize driver
231 
232  Set background color, transparency, drawable, antialias mode, etc.
233 
234  \return 0
235 */
237 {
238  cairo_antialias_t antialias;
239  char *p;
240 
241  G_gisinit("Cairo driver");
242 
243  /* get background color */
244  p = getenv("GRASS_RENDER_BACKGROUNDCOLOR");
245  if (p && *p) {
246  unsigned int red, green, blue;
247 
248  if (sscanf(p, "%02x%02x%02x", &red, &green, &blue) == 3 ||
249  G_str_to_color(p, (int *)&red, (int *)&green, (int *)&blue) == 1) {
250  ca.bgcolor_r = CAIROCOLOR(red);
251  ca.bgcolor_g = CAIROCOLOR(green);
252  ca.bgcolor_b = CAIROCOLOR(blue);
253  }
254  else
255  G_fatal_error("Unknown background color: %s", p);
256  G_debug(1, "cairo: GRASS_RENDER_BACKGROUNDCOLOR=%s", p);
257  }
258  else
259  ca.bgcolor_r = ca.bgcolor_g = ca.bgcolor_b = 1.0;
260 
261  /* get background transparency setting */
262  p = getenv("GRASS_RENDER_TRANSPARENT");
263  if (p && strcmp(p, "TRUE") == 0)
264  ca.bgcolor_a = 0.0;
265  else
266  ca.bgcolor_a = 1.0;
267  G_debug(1, "cairo: GRASS_RENDER_TRANSPARENT=%s", p ? p : "FALSE");
268 
269  antialias = CAIRO_ANTIALIAS_DEFAULT;
270  p = getenv("GRASS_RENDER_ANTIALIAS");
271  if (p && G_strcasecmp(p, "default") == 0)
272  antialias = CAIRO_ANTIALIAS_DEFAULT;
273  if (p && G_strcasecmp(p, "none") == 0)
274  antialias = CAIRO_ANTIALIAS_NONE;
275  if (p && G_strcasecmp(p, "gray") == 0)
276  antialias = CAIRO_ANTIALIAS_GRAY;
277  if (p && G_strcasecmp(p, "subpixel") == 0)
278  antialias = CAIRO_ANTIALIAS_SUBPIXEL;
279  G_debug(1, "cairo: GRASS_RENDER_ANTIALIAS=%s", p ? p : "FALSE");
280 
281  init_file();
282 
283  cairo_set_antialias(cairo, antialias);
284 
285  return 0;
286 }
287 
288 /*!
289  \brief Get render file
290 
291  \return file name
292 */
293 const char *Cairo_Graph_get_file(void)
294 {
295  return ca.file_name;
296 }
297 
298 /*!
299  \brief Close driver
300 */
302 {
303  G_debug(1, "Cairo_Graph_close");
304 
305 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
306  if (ca.file_type == FTYPE_X11) {
307  XFlush(cairo_xlib_surface_get_display(surface));
308  ca.mapped = 0;
309  }
310 #endif
311 
313 
314  if (cairo) {
315  cairo_destroy(cairo);
316  cairo = NULL;
317  }
318  if (surface) {
319  cairo_surface_destroy(surface);
320  surface = NULL;
321  }
322 
323 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
324  if (ca.file_type == FTYPE_X11)
325  fini_xlib();
326 #endif
327 }
328 
329 static void init_cairo(void)
330 {
331  G_debug(1, "init_cairo");
332 
333  /* create cairo surface */
334  switch (ca.file_type) {
335  case FTYPE_PPM:
336  case FTYPE_BMP:
337  case FTYPE_PNG:
338  surface =
339  (cairo_surface_t *) cairo_image_surface_create_for_data(
340  ca.grid, CAIRO_FORMAT_ARGB32, ca.width, ca.height, ca.stride);
341  break;
342 #if CAIRO_HAS_PDF_SURFACE
343  case FTYPE_PDF:
344  surface =
345  (cairo_surface_t *) cairo_pdf_surface_create(
346  ca.file_name, (double) ca.width, (double) ca.height);
347  break;
348 #endif
349 #if CAIRO_HAS_PS_SURFACE
350  case FTYPE_PS:
351  surface =
352  (cairo_surface_t *) cairo_ps_surface_create(
353  ca.file_name, (double) ca.width, (double) ca.height);
354  break;
355 #endif
356 #if CAIRO_HAS_SVG_SURFACE
357  case FTYPE_SVG:
358  surface =
359  (cairo_surface_t *) cairo_svg_surface_create(
360  ca.file_name, (double) ca.width, (double) ca.height);
361  break;
362 #endif
363 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
364  case FTYPE_X11:
365  surface =
366  (cairo_surface_t *) cairo_xlib_surface_create_with_xrender_format(
367  ca.dpy, ca.win, ca.screen, ca.format, ca.width, ca.height);
368  break;
369 #endif
370  default:
371  G_fatal_error(_("Unknown Cairo surface type"));
372  break;
373  }
374 
375  if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS)
376  G_fatal_error(_("Failed to initialize Cairo surface"));
377 
378  cairo = cairo_create(surface);
379 }
380 
381 /* Returns TRUE if string ends with suffix (case insensitive) */
382 static int ends_with(const char *string, const char *suffix)
383 {
384  if (strlen(string) < strlen(suffix))
385  return FALSE;
386 
387  return G_strcasecmp(suffix,
388  string + strlen(string) - strlen(suffix)) == 0;
389 }
390 
391 static void map_file(void)
392 {
393 #ifndef __MINGW32__
394  size_t size = HEADER_SIZE + ca.width * ca.height * sizeof(unsigned int);
395  void *ptr;
396  int fd;
397 
398  fd = open(ca.file_name, O_RDWR);
399  if (fd < 0)
400  return;
401 
402  ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t) 0);
403  if (ptr == MAP_FAILED)
404  return;
405 
406  if (ca.grid) {
407  cairo_destroy(cairo);
408  cairo_surface_destroy(surface);
409  G_free(ca.grid);
410  }
411  ca.grid = (unsigned char *) ptr + HEADER_SIZE;
412 
413  close(fd);
414 
415  ca.mapped = 1;
416 #endif
417 }
418 
N_read_rast_to_array_2d
N_array_2d * N_read_rast_to_array_2d(char *name, N_array_2d *array)
Read a raster map into a N_array_2d structure.
Definition: n_arrays_io.c:47
N_get_array_2d_f_value
FCELL N_get_array_2d_f_value(N_array_2d *data, int col, int row)
Returns the value of type FCELL at position col, row.
Definition: n_arrays.c:346
N_put_array_3d_d_value
void N_put_array_3d_d_value(N_array_3d *data, int col, int row, int depth, double value)
Writes a double value to the N_array_3d struct at position col, row, depth.
Definition: n_arrays.c:1175
N_print_array_2d
void N_print_array_2d(N_array_2d *data)
Write info and content of the N_array_2d struct to stdout.
Definition: n_arrays.c:637
N_math_array_2d
N_array_2d * N_math_array_2d(N_array_2d *a, N_array_2d *b, N_array_2d *result, int type)
Perform calculations with two input arrays, the result is written to a third array.
Definition: n_arrays_calc.c:308
N_create_5star
N_data_star * N_create_5star(double C, double W, double E, double N, double S, double V)
allocate and initialize a 5 point star data structure
Definition: n_les_assemble.c:126
Cairo_Erase
void Cairo_Erase(void)
Erase screen.
Definition: cairodriver/erase.c:20
NE
#define NE
Definition: dataquad.h:30
FTYPE_PDF
#define FTYPE_PDF
Definition: cairodriver.h:56
N_geom_data
Geometric information about the structured grid.
Definition: N_pde.h:103
G_strcasecmp
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
Definition: strings.c:46
FALSE
#define FALSE
Definition: dbfopen.c:182
N_alloc_7star
N_data_star * N_alloc_7star(void)
allocate a 7 point star data structure
Definition: n_les_assemble.c:63
G_verbose_message
void G_verbose_message(const char *msg,...)
Print a message to stderr but only if module is in verbose mode.
Definition: gis/error.c:109
DEFAULT_FILE_NAME
#define DEFAULT_FILE_NAME
Definition: cairodriver.h:43
N_alloc_les_callback_2d
N_les_callback_2d * N_alloc_les_callback_2d(void)
Allocate the structure holding the callback function.
Definition: n_les_assemble.c:397
N_put_array_3d_value
void N_put_array_3d_value(N_array_3d *data, int col, int row, int depth, char *value)
This function writes a value to the N_array_3d data at position col, row, depth.
Definition: n_arrays.c:1021
N_alloc_5star
N_data_star * N_alloc_5star(void)
allocate a 5 point star data structure
Definition: n_les_assemble.c:46
N_les_callback_2d
callback structure for 2d matrix assembling
Definition: N_pde.h:294
cairo_state::modified
int modified
Definition: cairodriver.h:70
N_create_9star
N_data_star * N_create_9star(double C, double W, double E, double N, double S, double NW, double SW, double NE, double SE, double V)
allocate and initialize a 9 point star data structure
Definition: n_les_assemble.c:202
N_convert_array_3d_null_to_zero
int N_convert_array_3d_null_to_zero(N_array_3d *a)
Convert all null values to zero values.
Definition: n_arrays_calc.c:852
N_free_array_2d
void N_free_array_2d(N_array_2d *data)
Release the memory of a N_array_2d structure.
Definition: n_arrays.c:130
cairo_state
Definition: cairodriver.h:64
cairo_state::mapped
int mapped
Definition: cairodriver.h:71
cairo_state::grid
unsigned char * grid
Definition: cairodriver.h:68
SW
#define SW
Definition: dataquad.h:31
cairo
cairo_t * cairo
Definition: cairodriver/graph.c:46
N_put_array_2d_c_value
void N_put_array_2d_c_value(N_array_2d *data, int col, int row, CELL value)
Writes a CELL value to the N_array_2d struct at position col, row.
Definition: n_arrays.c:524
N_gwflow_data2d::r
N_array_2d * r
Definition: N_gwflow.h:74
ca
struct cairo_state ca
Definition: cairodriver/graph.c:42
N_norm_array_2d
double N_norm_array_2d(N_array_2d *a, N_array_2d *b, int type)
Calculate the norm of the two input arrays.
Definition: n_arrays_calc.c:148
N_gwflow_data2d::phead
N_array_2d * phead
Definition: N_gwflow.h:69
N_gwflow_data2d::q
N_array_2d * q
Definition: N_gwflow.h:73
N_gwflow_data2d::s
N_array_2d * s
Definition: N_gwflow.h:75
G_fatal_error
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Definition: gis/error.c:160
N_copy_array_3d
void N_copy_array_3d(N_array_3d *source, N_array_3d *target)
Copy the source N_array_3d struct to the target N_array_3d struct.
Definition: n_arrays_calc.c:500
N_array_2d
Definition: N_pde.h:131
cairo_state::file_type
int file_type
Definition: cairodriver.h:66
N_alloc_les_callback_3d
N_les_callback_3d * N_alloc_les_callback_3d(void)
Allocate the structure holding the callback function.
Definition: n_les_assemble.c:376
G_str_to_color
int G_str_to_color(const char *str, int *red, int *grn, int *blu)
Parse color string and set red,green,blue.
Definition: color_str.c:112
Cairo_Graph_close
void Cairo_Graph_close(void)
Close driver.
Definition: cairodriver/graph.c:301
x
#define x
N_init_geom_data_2d
N_geom_data * N_init_geom_data_2d(struct Cell_head *region, N_geom_data *geodata)
Initiate a pde geometry data structure with a 2d region.
Definition: n_geom.c:114
N_print_array_3d
void N_print_array_3d(N_array_3d *data)
Write info and content of the array data to stdout.
Definition: n_arrays.c:1223
cairo_state::bgcolor_g
double bgcolor_g
Definition: cairodriver.h:69
N_copy_array_2d
void N_copy_array_2d(N_array_2d *source, N_array_2d *target)
Copy the source N_array_2d struct to the target N_array_2d struct.
Definition: n_arrays_calc.c:45
N_assemble_les_3d
N_les * N_assemble_les_3d(int les_type, N_geom_data *geom, N_array_3d *status, N_array_3d *start_val, void *data, N_les_callback_3d *call)
Assemble a linear equation system (les) based on 3d location data (g3d) active cells.
Definition: n_les_assemble.c:949
b
double b
Definition: driver/set_window.c:5
name
const char * name
Definition: named_colr.c:7
N_free_array_3d
void N_free_array_3d(N_array_3d *data)
Release the memory of a N_array_3d.
Definition: n_arrays.c:780
count
int count
N_get_array_3d_type
int N_get_array_3d_type(N_array_3d *array)
Return the data type of the N_array_3d.
Definition: n_arrays.c:809
cairo_state::bgcolor_r
double bgcolor_r
Definition: cairodriver.h:69
N_get_array_3d_f_value
float N_get_array_3d_f_value(N_array_3d *data, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
Definition: n_arrays.c:961
N_put_array_2d_f_value
void N_put_array_2d_f_value(N_array_2d *data, int col, int row, FCELL value)
Writes a FCELL value to the N_array_2d struct at position col, row.
Definition: n_arrays.c:554
NW
#define NW
Definition: dataquad.h:29
N_get_array_3d_d_value
double N_get_array_3d_d_value(N_array_3d *data, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
Definition: n_arrays.c:990
N_math_array_3d
N_array_3d * N_math_array_3d(N_array_3d *a, N_array_3d *b, N_array_3d *result, int type)
Perform calculations with two input arrays, the result is written to a third array.
Definition: n_arrays_calc.c:739
N_set_les_callback_2d_func
void N_set_les_callback_2d_func(N_les_callback_2d *data, N_data_star *(*callback_func_2d)())
Set the callback function which is called while assembling the les in 2d.
Definition: n_les_assemble.c:359
N_gwflow_data2d::hc_x
N_array_2d * hc_x
Definition: N_gwflow.h:71
cairo_state::width
int width
Definition: cairodriver.h:67
N_get_array_3d_value
void N_get_array_3d_value(N_array_3d *data, int col, int row, int depth, void *value)
This function writes the value of N_array_3d data at position col, row, depth to the variable value.
Definition: n_arrays.c:829
N_create_7star
N_data_star * N_create_7star(double C, double W, double E, double N, double S, double T, double B, double V)
allocate and initialize a 7 point star data structure
Definition: n_les_assemble.c:161
SE
#define SE
Definition: dataquad.h:32
N_put_array_3d_f_value
void N_put_array_3d_f_value(N_array_3d *data, int col, int row, int depth, float value)
This function writes a float value to the N_array_3d data at position col, row, depth.
Definition: n_arrays.c:1148
screen_height
int screen_height
Definition: driver/init.c:30
G_free
void G_free(void *buf)
Free allocated memory.
Definition: alloc.c:149
cairo_read_xid
void cairo_read_xid(void)
Definition: read_xid.c:5
N_gwflow_data2d
This data structure contains all data needed to compute the groundwater mass balance in two dimension...
Definition: N_gwflow.h:67
N_convert_array_2d_null_to_zero
int N_convert_array_2d_null_to_zero(N_array_2d *a)
Convert all null values to zero values.
Definition: n_arrays_calc.c:434
cairo_state::height
int height
Definition: cairodriver.h:67
NULL
#define NULL
Definition: ccmath.h:32
N_callback_template_3d
N_data_star * N_callback_template_3d(void *data, N_geom_data *geom, int col, int row, int depth)
A callback template creates a 7 point star structure.
Definition: n_les_assemble.c:424
cairo_state::file_name
char * file_name
Definition: cairodriver.h:65
cairo_state::bgcolor_a
double bgcolor_a
Definition: cairodriver.h:69
N_alloc_9star
N_data_star * N_alloc_9star(void)
allocate a 9 point star data structure
Definition: n_les_assemble.c:83
FTYPE_SVG
#define FTYPE_SVG
Definition: cairodriver.h:58
N_data_star
Matrix entries for a mass balance 5/7/9 star system.
Definition: N_pde.h:272
source
const char * source
Definition: lz4.h:575
N_gwflow_data2d::bottom
N_array_2d * bottom
Definition: N_gwflow.h:89
N_get_array_2d_c_value
CELL N_get_array_2d_c_value(N_array_2d *data, int col, int row)
Returns the value of type CELL at position col, row.
Definition: n_arrays.c:314
main
int main(int argc, char *argv[])
Definition: main.c:27
cairo_read_image
void cairo_read_image(void)
Definition: cairodriver/read.c:17
N_write_array_2d_to_rast
void N_write_array_2d_to_rast(N_array_2d *array, char *name)
Write a N_array_2d struct to a raster map.
Definition: n_arrays_io.c:173
CAIROCOLOR
#define CAIROCOLOR(a)
Definition: cairodriver.h:49
FTYPE_PNG
#define FTYPE_PNG
Definition: cairodriver.h:55
N_norm_array_3d
double N_norm_array_3d(N_array_3d *a, N_array_3d *b, int type)
Calculate the norm of the two input arrays.
Definition: n_arrays_calc.c:576
N_set_les_callback_3d_func
void N_set_les_callback_3d_func(N_les_callback_3d *data, N_data_star *(*callback_func_3d)())
Set the callback function which is called while assembling the les in 3d.
Definition: n_les_assemble.c:342
N_les_callback_3d
callback structure for 3d matrix assembling
Definition: N_pde.h:286
N_callback_gwflow_2d
N_data_star * N_callback_gwflow_2d(void *gwdata, N_geom_data *geom, int col, int row)
This callback function creates the mass balance of a 5 point star.
Definition: n_gwflow.c:464
G_get_set_window
void G_get_set_window(struct Cell_head *window)
Get the current working window (region)
Definition: gis/set_window.c:35
N_gwflow_data2d::top
N_array_2d * top
Definition: N_gwflow.h:88
cairodriver.h
GRASS cairo display driver - header file.
N_array_3d
Definition: N_pde.h:165
cairo_write_image
void cairo_write_image(void)
Definition: cairodriver/write.c:17
FTYPE_PPM
#define FTYPE_PPM
Definition: cairodriver.h:53
N_read_rast3d_to_array_3d
N_array_3d * N_read_rast3d_to_array_3d(char *name, N_array_3d *array, int mask)
Read a volume map into a N_array_3d structure.
Definition: n_arrays_io.c:253
G_debug
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
N_get_array_2d_type
int N_get_array_2d_type(N_array_2d *array)
Return the data type of the N_array_2d struct.
Definition: n_arrays.c:164
N_put_array_2d_value
void N_put_array_2d_value(N_array_2d *data, int col, int row, char *value)
Writes a value to the N_array_2d struct at position col, row.
Definition: n_arrays.c:411
N_les::x
double * x
Definition: N_pde.h:74
FTYPE_X11
#define FTYPE_X11
Definition: cairodriver.h:59
surface
cairo_surface_t * surface
Definition: cairodriver/graph.c:45
N_free_geom_data
void N_free_geom_data(N_geom_data *geom)
Release memory of a pde geometry data structure.
Definition: n_geom.c:50
N_alloc_gwflow_data2d
N_gwflow_data2d * N_alloc_gwflow_data2d(int cols, int rows, int river, int drain)
Alllocate memory for the groundwater calculation data structure in 2 dimensions.
Definition: n_gwflow.c:148
N_write_array_3d_to_rast3d
void N_write_array_3d_to_rast3d(N_array_3d *array, char *name, int mask)
Write a N_array_3d struct to a volume map.
Definition: n_arrays_io.c:385
N_geom_data::cols
int cols
Definition: N_pde.h:117
N_callback_template_2d
N_data_star * N_callback_template_2d(void *data, N_geom_data *geom, int col, int row)
A callback template creates a 9 point star structure.
Definition: n_les_assemble.c:463
N_alloc_array_3d
N_array_3d * N_alloc_array_3d(int cols, int rows, int depths, int offset, int type)
Allocate memory for a N_array_3d data structure.
Definition: n_arrays.c:726
cairo_state::stride
int stride
Definition: cairodriver.h:67
N_gwflow_data2d::status
N_array_2d * status
Definition: N_gwflow.h:91
N_free_les
void N_free_les(N_les *les)
Release the memory of the linear equation system.
Definition: n_les.c:304
N_free_gwflow_data2d
void N_free_gwflow_data2d(N_gwflow_data2d *data)
Release the memory of the groundwater flow data structure in two dimensions.
Definition: n_gwflow.c:200
Cairo_Graph_set
int Cairo_Graph_set(void)
Initialize driver.
Definition: cairodriver/graph.c:236
N_alloc_array_2d
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
Definition: n_arrays.c:72
N_put_array_2d_d_value
void N_put_array_2d_d_value(N_array_2d *data, int col, int row, DCELL value)
Writes a DCELL value to the N_array_2d struct at position col, row.
Definition: n_arrays.c:584
N_les
The linear equation system (les) structure.
Definition: N_pde.h:72
cairo_state::bgcolor_b
double bgcolor_b
Definition: cairodriver.h:69
N_SPARSE_LES
#define N_SPARSE_LES
Definition: N_pde.h:27
FTYPE_BMP
#define FTYPE_BMP
Definition: cairodriver.h:54
N_assemble_les_2d
N_les * N_assemble_les_2d(int les_type, N_geom_data *geom, N_array_2d *status, N_array_2d *start_val, void *data, N_les_callback_2d *call)
Assemble a linear equation system (les) based on 2d location data (raster) and active cells.
Definition: n_les_assemble.c:493
r
double r
Definition: driver/set_window.c:5
N_CELL_INACTIVE
#define N_CELL_INACTIVE
Definition: N_pde.h:31
N_gwflow_data2d::hc_y
N_array_2d * hc_y
Definition: N_gwflow.h:72
N_gwflow_data2d::phead_start
N_array_2d * phead_start
Definition: N_gwflow.h:70
screen_width
int screen_width
Definition: driver/init.c:29
N_geom_data::rows
int rows
Definition: N_pde.h:116
N_get_array_2d_d_value
DCELL N_get_array_2d_d_value(N_array_2d *data, int col, int row)
Returns the value of type DCELL at position col, row.
Definition: n_arrays.c:378
N_get_array_2d_value
void N_get_array_2d_value(N_array_2d *data, int col, int row, void *value)
Write the value of the N_array_2d struct at position col, row to value.
Definition: n_arrays.c:181
HEADER_SIZE
#define HEADER_SIZE
Definition: cairodriver.h:45
FTYPE_PS
#define FTYPE_PS
Definition: cairodriver.h:57
Cairo_Graph_get_file
const char * Cairo_Graph_get_file(void)
Get render file.
Definition: cairodriver/graph.c:293