~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to display/d.rast.edit/cell.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdlib.h>
2
 
#include <grass/display.h>
3
 
#include <grass/raster.h>
4
 
#include <grass/gis.h>
5
 
#include <grass/glocale.h>
6
 
#include "edit.h"
7
 
 
8
 
static int cell_draw(char *, char *, struct Colors *, int);
9
 
 
10
 
 
11
 
/*!
12
 
 * \brief 
13
 
 *
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>.
18
 
 *
19
 
 *  \param name
20
 
 *  \param mapset
21
 
 *  \param overlay
22
 
 *  \return int
23
 
 */
24
 
 
25
 
int Dcell(char *name, char *mapset, int overlay)
26
 
{
27
 
    struct Cell_head wind;
28
 
    struct Colors colors;
29
 
    char buff[128];
30
 
    int offset;
31
 
 
32
 
    G_get_set_window(&wind);
33
 
 
34
 
    if (D_check_map_window(&wind))
35
 
        G_fatal_error(_("Setting map window"));
36
 
 
37
 
    if (G_set_window(&wind) == -1)
38
 
        G_fatal_error(_("Current window not settable"));
39
 
 
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"));
44
 
 
45
 
    /* Save the current map window with the graphics window */
46
 
    D_check_map_window(&wind);
47
 
    G_set_window(&wind);
48
 
 
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);
52
 
 
53
 
    /* Go draw the cell file */
54
 
    cell_draw(name, mapset, &colors, overlay);
55
 
 
56
 
    /* release the colors now */
57
 
    G_free_colors(&colors);
58
 
 
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 */
62
 
    if (overlay) {
63
 
        sprintf(buff, "d.rast -o map=%s",
64
 
                G_fully_qualified_name(name, mapset));
65
 
        D_add_to_list(buff);
66
 
    }
67
 
    else {
68
 
        D_set_cell_name(G_fully_qualified_name(name, mapset));
69
 
    }
70
 
 
71
 
    return 0;
72
 
}
73
 
 
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,
76
 
                     int overlay)
77
 
{
78
 
    int cellfile;
79
 
    DCELL *xarray;
80
 
    int cur_A_row;
81
 
    int t, b, l, r;
82
 
 
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"));
87
 
 
88
 
    D_set_overlay_mode(overlay);
89
 
 
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);
93
 
 
94
 
    /* Allocate space for cell buffer */
95
 
    xarray = G_allocate_d_raster_buf();
96
 
 
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);
101
 
 
102
 
        /* Draw the cell row, and get the next row number */
103
 
        cur_A_row = D_draw_d_raster(cur_A_row, xarray, colors);
104
 
    }
105
 
    R_flush();
106
 
 
107
 
    /* Wrap up and return */
108
 
    G_close_cell(cellfile);
109
 
    G_free(xarray);
110
 
 
111
 
    return (0);
112
 
}