2
#include <grass/display.h>
3
#include <grass/raster.h>
5
#include <grass/glocale.h>
8
static int cell_draw(char *, char *, struct Colors *, int);
14
* If the map is a floating-point map, read the map using
15
* <tt>G_get_d_raster_row()</tt> and plot using <tt>D_draw_d_cell()</tt>. If the
16
* map is an integer map, read the map using <tt>G_get_c_raster_row()</tt> and
17
* plot using <tt>D_draw_cell()</tt>.
25
int Dcell(char *name, char *mapset, int overlay)
27
struct Cell_head wind;
32
G_get_set_window(&wind);
34
if (D_check_map_window(&wind))
35
G_fatal_error(_("Setting map window"));
37
if (G_set_window(&wind) == -1)
38
G_fatal_error(_("Current window not settable"));
40
/* Get existing map window for this graphics window, or save window */
41
/* cell maps wipe out a picture, so we clear info on the window too */
42
if (!overlay && D_clear_window())
43
G_fatal_error(_("Can't clear current graphics window"));
45
/* Save the current map window with the graphics window */
46
D_check_map_window(&wind);
49
/* Set the colors for the display */
50
if (G_read_colors(name, mapset, &colors) == -1)
51
G_fatal_error(_("Color file for <%s> not available"), name);
53
/* Go draw the cell file */
54
cell_draw(name, mapset, &colors, overlay);
56
/* release the colors now */
57
G_free_colors(&colors);
59
/* record the cell file */
60
/* If overlay add it to the list instead of setting the cell name */
61
/* added 6/91 DBS @ CWU */
63
sprintf(buff, "d.rast -o map=%s",
64
G_fully_qualified_name(name, mapset));
68
D_set_cell_name(G_fully_qualified_name(name, mapset));
74
/* I modified this function to read and draw raster cell as doubles */
75
static int cell_draw(char *name, char *mapset, struct Colors *colors,
83
/* Set up the screen, conversions, and graphics */
84
D_get_screen_window(&t, &b, &l, &r);
85
if (D_cell_draw_setup(t, b, l, r))
86
G_fatal_error(_("Cannot use current window"));
88
D_set_overlay_mode(overlay);
90
/* Make sure map is available */
91
if ((cellfile = G_open_cell_old(name, mapset)) == -1)
92
G_fatal_error(_("Unable to open raster map <%s>"), name);
94
/* Allocate space for cell buffer */
95
xarray = G_allocate_d_raster_buf();
97
/* loop for array rows */
98
for (cur_A_row = 0; cur_A_row != -1;) {
99
/* Get window (array) row currently required */
100
G_get_d_raster_row(cellfile, xarray, cur_A_row);
102
/* Draw the cell row, and get the next row number */
103
cur_A_row = D_draw_d_raster(cur_A_row, xarray, colors);
107
/* Wrap up and return */
108
G_close_cell(cellfile);