Go to the documentation of this file.00001
00017 #include <grass/gis.h>
00018 #include <grass/glocale.h>
00019 #include "G.h"
00020
00030 int G_get_set_window(struct Cell_head *window)
00031 {
00032 G__init_window();
00033 G_copy((char *)window, (char *)&G__.window, sizeof(*window));
00034
00035 return 1;
00036 }
00037
00038
00049 int G_set_window(struct Cell_head *window)
00050 {
00051 int i;
00052 int maskfd;
00053 char *err;
00054
00055
00056
00057
00058
00059
00060
00061 if ((err = G_adjust_Cell_head(window, 0, 0))) {
00062 G_warning("G_set_window(): %s", err);
00063 return -1;
00064 }
00065
00066
00067
00068
00069 maskfd = G__.auto_mask > 0 ? G__.mask_fd : -1;
00070 for (i = 0; i < G__.fileinfo_count; i++) {
00071 if (G__.fileinfo[i].open_mode == OPEN_OLD) {
00072 if (G__.fileinfo[i].cellhd.zone == window->zone &&
00073 G__.fileinfo[i].cellhd.proj == window->proj)
00074 continue;
00075 if (i != maskfd) {
00076 G_warning(_("G_set_window(): projection/zone differs from that of "
00077 "currently open raster maps"));
00078 return -1;
00079 }
00080 }
00081 }
00082
00083
00084 if (G__.auto_mask > 0) {
00085 G_close_cell(maskfd);
00086
00087 G__.mask_fd = -1;
00088 G__.auto_mask = -1;
00089 }
00090
00091
00092 G_copy((char *)&G__.window, (char *)window, sizeof(*window));
00093
00094 G__.window_set = 1;
00095
00096
00097
00098
00099
00100
00101 for (i = 0; i < G__.fileinfo_count; i++) {
00102 if (G__.fileinfo[i].open_mode != OPEN_OLD &&
00103 G__.fileinfo[i].open_mode != OPEN_NEW_UNCOMPRESSED &&
00104 G__.fileinfo[i].open_mode != OPEN_NEW_COMPRESSED &&
00105 G__.fileinfo[i].open_mode != OPEN_NEW_RANDOM)
00106 continue;
00107
00108 if (G__.fileinfo[i].open_mode == OPEN_OLD)
00109 G__create_window_mapping(i);
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 }
00138
00139
00140 G__check_for_auto_masking();
00141
00142
00143 G__reallocate_null_buf();
00144 G__reallocate_mask_buf();
00145 G__reallocate_temp_buf();
00146 G__reallocate_work_buf(sizeof(DCELL));
00147 G__reallocate_work_buf(XDR_DOUBLE_NBYTES);
00148
00149
00150
00151 return 1;
00152 }