~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/i.photo.2target/drawcell.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

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 "globals.h"
 
5
#include "local_proto.h"
 
6
 
 
7
int drawcell(View * view)
 
8
{
 
9
    int fd;
 
10
    int left, top;
 
11
    int ncols, nrows;
 
12
    int row;
 
13
    CELL *cell;
 
14
    struct Colors *colors;
 
15
    int read_colors;
 
16
    char msg[100];
 
17
 
 
18
 
 
19
    if (!view->cell.configured)
 
20
        return 0;
 
21
    if (view == VIEW_MAP1 || view == VIEW_MAP1_ZOOM) {
 
22
        colors = &VIEW_MAP1->cell.colors;
 
23
        read_colors = view == VIEW_MAP1;
 
24
    }
 
25
    else {
 
26
        colors = &VIEW_MAP2->cell.colors;
 
27
        read_colors = view == VIEW_MAP2;
 
28
    }
 
29
    if (read_colors) {
 
30
        G_free_colors(colors);
 
31
        if (G_read_colors(view->cell.name, view->cell.mapset, colors) < 0)
 
32
            return 0;
 
33
    }
 
34
 
 
35
 
 
36
    display_title(view);
 
37
 
 
38
    set_colors(colors);
 
39
 
 
40
    G_set_window(&view->cell.head);
 
41
    nrows = G_window_rows();
 
42
    ncols = G_window_cols();
 
43
 
 
44
    left = view->cell.left;
 
45
    top = view->cell.top;
 
46
 
 
47
    R_standard_color(BLUE);
 
48
    Outline_box(top, top + nrows - 1, left, left + ncols - 1);
 
49
 
 
50
    if (getenv("NO_DRAW"))
 
51
        return 1;
 
52
 
 
53
    fd = G_open_cell_old(view->cell.name, view->cell.mapset);
 
54
    if (fd < 0)
 
55
        return 0;
 
56
    cell = G_allocate_cell_buf();
 
57
 
 
58
 
 
59
    sprintf(msg, "Plotting %s ...", view->cell.name);
 
60
    Menu_msg(msg);
 
61
 
 
62
    D_cell_draw_setup(top, top + nrows, left, left + ncols);
 
63
    for (row = 0; row < nrows; row++) {
 
64
        if (G_get_map_row_nomask(fd, cell, row) < 0)
 
65
            break;
 
66
        D_draw_c_raster(row, cell, colors);
 
67
    }
 
68
    D_cell_draw_end();
 
69
    G_close_cell(fd);
 
70
    G_free(cell);
 
71
 
 
72
    if (colors != &VIEW_MAP1->cell.colors)
 
73
        set_colors(&VIEW_MAP1->cell.colors);
 
74
 
 
75
    return row == nrows;
 
76
}