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

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/i.photo.2target/cell.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 <unistd.h>
 
2
#include "globals.h"
 
3
#include "local_proto.h"
 
4
 
 
5
static int use = 1;
 
6
static int cancel(void);
 
7
static int plot(int, int);
 
8
static int choose_cellfile(char *, char *);
 
9
 
 
10
int plotcell(int x, int y)
 
11
{
 
12
    static Objects objects[] = {
 
13
        MENU("CANCEL", cancel, &use),
 
14
        INFO("Indicate which side should be plotted", &use),
 
15
        OTHER(plot, &use),
 
16
        {0}
 
17
    };
 
18
    /*
 
19
     * if the target raster map list is ready, ask the user which side
 
20
     * should be plotted, otherwise can only plot group files
 
21
     */
 
22
    if (access(cell_list, 0) == 0)
 
23
        Input_pointer(objects);
 
24
    else
 
25
        plot(VIEW_MAP1->left + 1, 0);
 
26
    return 0;
 
27
}
 
28
 
 
29
static int cancel(void)
 
30
{
 
31
    return 1;
 
32
}
 
33
 
 
34
 
 
35
static int plot(int x, int y)
 
36
{
 
37
    char name[40], mapset[40];
 
38
    struct Cell_head cellhd;
 
39
 
 
40
    if (x > VIEW_MAP1->left && x < VIEW_MAP1->right) {
 
41
        /* must close and reopen elev layer buffer */
 
42
        /*      G_close_cell (elev); */
 
43
 
 
44
        select_current_env();
 
45
        if (!choose_groupfile(name, mapset))
 
46
            return 1;
 
47
        if (G_get_cellhd(name, mapset, &cellhd) < 0)
 
48
            return 1;
 
49
 
 
50
        Erase_view(VIEW_MAP1_ZOOM);
 
51
        Erase_view(VIEW_TITLE1_ZOOM);
 
52
        VIEW_MAP1_ZOOM->cell.configured = 0;
 
53
 
 
54
        G_adjust_window_to_box(&cellhd, &VIEW_MAP1->cell.head,
 
55
                               VIEW_MAP1->nrows, VIEW_MAP1->ncols);
 
56
        Configure_view(VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res);
 
57
        drawcell(VIEW_MAP1);
 
58
 
 
59
    }
 
60
    else if (x > VIEW_MAP2->left && x < VIEW_MAP2->right) {
 
61
        /* must close and reopen elev layer buffer */
 
62
        /*      G_close_cell (elev); */
 
63
 
 
64
        select_target_env();
 
65
        if (!choose_cellfile(name, mapset))
 
66
            return 1;
 
67
 
 
68
        if (G_get_cellhd(name, mapset, &cellhd) < 0) {
 
69
            select_current_env();
 
70
            return 1;
 
71
        }
 
72
 
 
73
        Erase_view(VIEW_MAP2_ZOOM);
 
74
        Erase_view(VIEW_TITLE2_ZOOM);
 
75
        VIEW_MAP2_ZOOM->cell.configured = 0;
 
76
 
 
77
        G_adjust_window_to_box(&cellhd, &VIEW_MAP2->cell.head,
 
78
                               VIEW_MAP2->nrows, VIEW_MAP2->ncols);
 
79
        Configure_view(VIEW_MAP2, name, mapset, cellhd.ns_res, cellhd.ew_res);
 
80
        select_target_env();
 
81
        drawcell(VIEW_MAP2);
 
82
 
 
83
        select_current_env();
 
84
        if (from_screen < 0) {
 
85
            from_flag = 1;
 
86
            from_screen = 0;
 
87
            if (from_keyboard < 0) {
 
88
                from_keyboard = 0;
 
89
                from_screen = 1;
 
90
            }
 
91
        }
 
92
    }
 
93
    else
 
94
        return 0;               /* ignore mouse click */
 
95
 
 
96
    display_conz_points(1);
 
97
    return 1;
 
98
}
 
99
 
 
100
static int choose_cellfile(char *name, char *mapset)
 
101
{
 
102
    return ask_gis_files("cell", cell_list, name, mapset, 1);
 
103
}