unused i.points + i.vpoints removed: replaced by g.gui.gcp

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@62555 15284696-431f-4ddb-bdfa-cd5b030d7da7
py3
neteler 2014-11-02 20:52:19 +00:00
parent 9496ca651f
commit 32d4854939
93 changed files with 81 additions and 10494 deletions

8
TODO
View File

@ -26,8 +26,9 @@ Imagery
- lib/image3/: never finished improvement which integrated the standard lib and
the ortho lib. Seems to provide also ortho rectification for
satellite data (i.points3, i.rectify3)
- See
http://grasswiki.osgeo.org/wiki/Image_processing#Ideas_collection_for_improving_GRASS.27_Image_processing_capabilities
- image modules:
- merge of i.points, i.vpoints, i.points3
- merge of i.rectify and i.rectify3
- addition of new resampling algorithms such as bilinear, cubic convolution
(take from r.proj?)
@ -35,3 +36,8 @@ Imagery
- implement/finish linewise ortho-rectification of satellite data
- Add support for > 8bit colors (only 0-255 supported currently)
-----------------
See also
http://trac.osgeo.org/grass/wiki/Grass7Planning

View File

@ -23,7 +23,7 @@ location (or another XY location), a forward transformation is performed.
The unreferenced map is geocoded within the XY location by defining
four corner points or by seeking several ground control points
(<a href="i.group.html">i.group</a>, <a href="i.target.html">i.target</a>,
<a href="i.points.html">i.points</a>) and then transformed into the
<a href="g.gui.gcp.html">g.gui.gcp</a>) and then transformed into the
target location (<a href="i.rectify.html">i.rectify</a>). Polynomial
transformation of 1st, 2nd and 3rd order are supported.
<p>

View File

@ -299,8 +299,9 @@ error is displayed.
<p>
<em>
<a href="i.rectify.html">i.rectify</a>,
<a href="m.transform.html">m.transform</a>
<a href="i.rectify.html">i.rectify</a>,
<a href="m.transform.html">m.transform</a>,
<a href="v.rectify.html">v.rectify</a>
</em>
<p>

View File

@ -24,6 +24,7 @@
#% keywords: general
#% keywords: GUI
#% keywords: georectification
#% keywords: GCP
#%end
"""

View File

@ -5,7 +5,7 @@ group by assigning them to user-named subgroups or other groups. This
enables the user to run analyses on any combination of the raster map layers
in a group. The user creates the groups and subgroups and selects the
raster map layers that are to reside in them. Imagery analysis programs like
<em><a href="i.points.html">i.points</a></em>,
<em><a href="g.gui.gcp.html">g.gui.gcp</a></em>,
<em><a href="i.rectify.html">i.rectify</a></em>,
<em><a href="i.ortho.photo.html">i.ortho.photo</a></em> and
others ask the user for the name of an imagery group whose data are to be
@ -30,9 +30,9 @@ The GRASS 4 <em>
Processing manual</a></em>
<p><em>
<a href="g.gui.gcp.html">g.gui.gcp</a>,
<a href="i.cluster.html">i.cluster</a>,
<a href="i.maxlik.html">i.maxlik</a>,
<a href="i.points.html">i.points</a>,
<a href="i.rectify.html">i.rectify</a>,
<a href="i.ortho.photo.html">i.ortho.photo</a>
</em>

View File

@ -6,6 +6,7 @@ Subject: Re: Re: i.ortho.photo
>From grass64/TODO:
- merge of image libraries:
A)
- lib/imagery/: standard lib, in use (i.* except for i.points3, i.rectify3)
- imagery/i.ortho.photo/libes/: standard lib, in use (i.ortho.photo, photo.*)
@ -16,3 +17,17 @@ Subject: Re: Re: i.ortho.photo
Possibly a lot is already done in lib/image3/ ?
- See
http://grasswiki.osgeo.org/wiki/Image_processing#Ideas_collection_for_improving_GRASS.27_Image_processing_capabilities
- image modules:
- merge of i.rectify and i.rectify3
- addition of new resampling algorithms such as bilinear, cubic convolution
(take from r.proj?)
- add other warping methods (maybe thin splines from GDAL?)
- implement/finish linewise ortho-rectification of satellite data
- Add support for > 8bit colors (only 0-255 supported currently)
-----------------
See also
http://trac.osgeo.org/grass/wiki/Grass7Planning

View File

@ -1,10 +0,0 @@
MODULE_TOPDIR = ../..
PGM = i.points
LIBES = $(IMAGERYLIB) $(DISPLAYLIB) $(GMATHLIB) $(GISLIB) $(CURSES)
DEPENDENCIES= $(IMAGERYDEP) $(DISPLAYDEP) $(GMATHDEP) $(GISDEP)
include $(MODULE_TOPDIR)/include/Make/Module.make
default: cmd

View File

@ -1,568 +0,0 @@
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/display.h>
#include "globals.h"
#include "local_proto.h"
#define NLINES 18
struct box
{
int top, bottom, left, right;
};
static int uparrow(struct box *, int);
static int downarrow(struct box *, int);
static int pick(int, int);
static int done(void);
static int cancel_which(void);
static int inbox(struct box *, int, int);
static int dotext(char *, int, int, int, int, int, int);
static int compute_transformation(void);
static int to_file(void);
static int askfile(void);
static int to_printer(void);
static int do_report(FILE *);
static int printcentered(FILE *, char *, int);
static int show_point(int, int);
static int which;
static struct box more, less, report;
static int height, size, edge, nlines;
static int curp, first_point;
static double rms;
static double *xres, *yres, *gnd;
static int pager;
static int xmax, ymax, gmax;
static char buf[300];
#define FMT0(buf,n) \
sprintf (buf, "%3d ", n)
#define FMT1(buf,xres,yres,gnd) \
sprintf (buf, "%5.1f %5.1f %6.1f ", xres,yres,gnd)
#define LHEAD1 " error "
#define LHEAD2 " # col row target"
#define FMT2(buf,e1,n1,e2,n2) \
sprintf (buf, "%9.1f %9.1f %9.1f %9.1f ", e1,n1,e2,n2)
#define RHEAD1 " image target"
#define RHEAD2 " east north east north"
#define BACKGROUND GREY
int analyze(void)
{
static int use = 1;
static Objects objects[] = {
MENU("DONE", done, &use),
MENU("PRINT", to_printer, &use),
MENU("FILE", to_file, &use),
INFO(" Double click on point to be included/excluded ", &use),
OTHER(pick, &use),
{0}
};
int color;
int tsize;
int cury;
int len;
int line;
int top, bottom, left, right, width, middle, nums;
/* to give user a response of some sort */
Menu_msg("Preparing analysis ...");
/*
* build a popup window at center of the screen.
* 35% the height and wide enough to hold the report
*
*/
/* height of 1 line, based on NLINES taking up 35% vertical space */
height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP)) / NLINES + 1;
/* size of text, 80% of line height */
tsize = .8 * height;
size = tsize - 2; /* fudge for computing pixels width of text */
/* indent for the text */
edge = .1 * height + 1;
/* determine the length, in chars, of printed line */
FMT0(buf, 0);
nums = strlen(buf) * size;
FMT1(buf, 0.0, 0.0, 0.0);
len = strlen(buf);
middle = len * size;
FMT2(buf, 0.0, 0.0, 0.0, 0.0);
len += strlen(buf);
/* width is for max chars plus sidecar for more/less */
width = len * size + nums + 2 * height;
if ((SCREEN_RIGHT - SCREEN_LEFT) < width)
width = SCREEN_RIGHT - SCREEN_LEFT;
/* define the window */
bottom = VIEW_MENU->top - 1;
top = bottom - height * NLINES;
left = SCREEN_LEFT;
right = left + width;
middle += left + nums;
nums += left;
/* save what is under this area, so it can be restored */
R_panel_save(tempfile1, top, bottom + 1, left, right + 1);
/* fill it with white */
R_standard_color(BACKGROUND);
R_box_abs(left, top, right, bottom);
right -= 2 * height; /* reduce it to exclude sidecar */
/* print messages in message area */
R_text_size(tsize, tsize);
/* setup the more/less boxes in the sidecar */
R_standard_color(BLACK);
less.top = top;
less.bottom = top + 2 * height;
less.left = right;
less.right = right + 2 * height;
Outline_box(less.top, less.bottom, less.left, less.right);
more.top = bottom - 2 * height;
more.bottom = bottom;
more.left = right;
more.right = right + 2 * height;
Outline_box(more.top, more.bottom, more.left, more.right);
/*
* top two lines are for column labels
* last two line is for overall rms error.
*/
nlines = NLINES - 3;
first_point = 0;
/* allocate predicted values */
xres = (double *)G_calloc(group.points.count, sizeof(double));
yres = (double *)G_calloc(group.points.count, sizeof(double));
gnd = (double *)G_calloc(group.points.count, sizeof(double));
/* compute transformation for the first time */
compute_transformation();
/* put head on the report */
cury = top;
dotext(LHEAD1, cury, cury + height, left, middle, 0, BLACK);
dotext(RHEAD1, cury, cury + height, middle, right - 1, 0, BLACK);
cury += height;
dotext(LHEAD2, cury, cury + height, left, middle, 0, BLACK);
dotext(RHEAD2, cury, cury + height, middle, right - 1, 0, BLACK);
cury += height;
R_move_abs(left, cury - 1);
R_cont_abs(right, cury - 1);
/* isolate the sidecar */
R_move_abs(right, top);
R_cont_abs(right, bottom);
/* define report box */
report.top = cury;
report.left = left;
report.right = right;
/* lets do it */
pager = 1;
while (1) {
R_text_size(tsize, tsize);
line = 0;
curp = first_point;
cury = top + 2 * height;
while (1) {
if (line >= nlines || curp >= group.points.count)
break;
line++;
if (group.equation_stat > 0 && group.points.status[curp] > 0) {
color = BLACK;
FMT1(buf, xres[curp], yres[curp], gnd[curp]);
if (curp == xmax || curp == ymax || curp == gmax)
color = RED;
dotext(buf, cury, cury + height, nums, middle, 0, color);
}
else if (group.points.status[curp] > 0)
dotext("?", cury, cury + height, nums, middle, 1, BLACK);
else
dotext("not used", cury, cury + height, nums, middle, 1,
BLACK);
if (pager) {
FMT0(buf, curp + 1);
dotext(buf, cury, cury + height, left, nums, 0, BLACK);
FMT2(buf,
group.points.e1[curp],
group.points.n1[curp],
group.points.e2[curp], group.points.n2[curp]);
dotext(buf, cury, cury + height, middle, right - 1, 0, BLACK);
}
cury += height;
curp++;
}
report.bottom = cury;
downarrow(&more, curp < group.points.count ? BLACK : BACKGROUND);
uparrow(&less, first_point > 0 ? BLACK : BACKGROUND);
R_standard_color(BACKGROUND);
R_box_abs(left, cury, right - 1, bottom);
if (group.equation_stat < 0) {
color = RED;
strcpy(buf, "Poorly placed control points");
}
else if (group.equation_stat == 0) {
color = RED;
strcpy(buf, "No active control points");
}
else {
color = BLACK;
sprintf(buf, "Overall rms error: %.2f", rms);
}
dotext(buf, bottom - height, bottom, left, right - 1, 0, color);
R_standard_color(BLACK);
R_move_abs(left, bottom - height);
R_cont_abs(right - 1, bottom - height);
pager = 0;
which = -1;
if (Input_pointer(objects) < 0)
break;
}
/* all done. restore what was under the window */
right += 2 * height; /* move it back over the sidecar */
R_standard_color(BACKGROUND);
R_box_abs(left, top, right, bottom);
R_panel_restore(tempfile1);
R_panel_delete(tempfile1);
R_flush();
G_free(xres);
G_free(yres);
G_free(gnd);
I_put_control_points(group.name, &group.points);
display_points(1);
return 0; /* return but don't QUIT */
}
static int uparrow(struct box *box, int color)
{
R_standard_color(color);
Uparrow(box->top + edge, box->bottom - edge, box->left + edge,
box->right - edge);
return 0;
}
static int downarrow(struct box *box, int color)
{
R_standard_color(color);
Downarrow(box->top + edge, box->bottom - edge, box->left + edge,
box->right - edge);
return 0;
}
static int pick(int x, int y)
{
int n;
int cur;
cur = which;
cancel_which();
if (inbox(&more, x, y)) {
if (curp >= group.points.count)
return 0;
first_point = curp;
pager = 1;
return 1;
}
if (inbox(&less, x, y)) {
if (first_point == 0)
return 0;
first_point -= nlines;
if (first_point < 0)
first_point = 0;
pager = 1;
return 1;
}
if (!inbox(&report, x, y)) {
return 0;
}
n = (y - report.top) / height;
if (n == cur) { /* second click! */
group.points.status[first_point + n] =
!group.points.status[first_point + n];
compute_transformation();
show_point(first_point + n, 1);
return 1;
}
/* first click */
which = n;
show_point(first_point + n, 0);
R_standard_color(RED);
Outline_box((report.top + n * height) + 1, report.top + (n + 1) * height,
report.left, report.right - 1);
R_flush();
return 0; /* ignore first click */
}
static int done(void)
{
cancel_which();
return -1;
}
static int cancel_which(void)
{
if (which >= 0) {
R_standard_color(BACKGROUND);
Outline_box((report.top + which * height) + 1,
report.top + (which + 1) * height, report.left,
report.right - 1);
show_point(first_point + which, 1);
}
which = -1;
return 0;
}
static int inbox(struct box *box, int x, int y)
{
return (x > box->left && x < box->right && y > box->top &&
y < box->bottom);
}
static int dotext(char *text,
int top, int bottom, int left, int right, int centered,
int color)
{
R_standard_color(BACKGROUND);
R_box_abs(left, top, right, bottom);
R_standard_color(color);
R_move_abs(left + 1 + edge, bottom - 1 - edge);
if (centered)
R_move_rel((right - left - strlen(text) * size) / 2, 0);
R_set_window(top, bottom, left, right); /* for text clipping */
R_text(text);
R_set_window(SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
return 0;
}
static int compute_transformation(void)
{
int n, count;
double d, d1, d2, sum;
double e1, e2, n1, n2;
double xval, yval, gval;
xmax = ymax = gmax = 0;
xval = yval = gval = 0.0;
Compute_equation();
if (group.equation_stat <= 0)
return 1;
/* compute the row,col error plus ground error
* keep track of largest and second largest error
*/
sum = 0.0;
rms = 0.0;
count = 0;
for (n = 0; n < group.points.count; n++) {
if (group.points.status[n] <= 0)
continue;
count++;
I_georef(group.points.e2[n], group.points.n2[n], &e1, &n1, group.E21,
group.N21);
I_georef(group.points.e1[n], group.points.n1[n], &e2, &n2, group.E12,
group.N12);
if ((d = xres[n] = e1 - group.points.e1[n]) < 0)
d = -d;
if (d > xval) {
xmax = n;
xval = d;
}
if ((d = yres[n] = n1 - group.points.n1[n]) < 0)
d = -d;
if (d > yval) {
ymax = n;
yval = d;
}
/* compute ground error (ie along diagonal) */
d1 = e2 - group.points.e2[n];
d2 = n2 - group.points.n2[n];
d = d1 * d1 + d2 * d2;
sum += d; /* add it to rms sum, before taking sqrt */
d = sqrt(d);
gnd[n] = d;
if (d > gval) { /* is this one the max? */
gmax = n;
gval = d;
}
}
/* compute overall rms error */
if (count)
rms = sqrt(sum / count);
return 0;
}
static int to_file(void)
{
FILE *fd;
char msg[1024];
cancel_which();
if (Input_other(askfile, "Keyboard") < 0) {
return 0;
}
fd = fopen(buf, "w");
if (fd == NULL) {
sprintf(msg, "** Unable to create file %s\n", buf);
Beep();
Curses_write_window(PROMPT_WINDOW, 2, 1, msg);
}
else {
do_report(fd);
fclose(fd);
sprintf(msg, "Report saved in file %s\n", buf);
Curses_write_window(PROMPT_WINDOW, 2, 1, msg);
}
return 0;
}
static int askfile(void)
{
char file[GNAME_MAX];
while (1) {
Curses_prompt_gets("Enter file to hold report: ", file);
G_strip(file);
if (*file == 0)
return -1;
if (G_index(file, '/'))
strcpy(buf, file);
else
sprintf(buf, "%s/%s", G_home(), file);
if (access(buf, 0) != 0)
return 1;
sprintf(buf, "** %s already exists. choose another file", file);
Beep();
Curses_write_window(PROMPT_WINDOW, 2, 1, buf);
}
return 0;
}
static int to_printer(void)
{
FILE *fd;
cancel_which();
Menu_msg("sending report to printer ...");
fd = popen("lpr", "w");
do_report(fd);
pclose(fd);
return 0;
}
static int do_report(FILE * fd)
{
char buf[GNAME_MAX];
int n;
int width;
fprintf(fd, "LOCATION: %-20s GROUP: %-20s MAPSET: %s\n\n",
G_location(), group.name, G_mapset());
fprintf(fd, "%15sAnalysis of control point registration\n\n", "");
fprintf(fd, "%s %s\n", LHEAD1, RHEAD1);
fprintf(fd, "%s %s\n", LHEAD2, RHEAD2);
FMT1(buf, 0.0, 0.0, 0.0);
width = strlen(buf);
for (n = 0; n < group.points.count; n++) {
FMT0(buf, n + 1);
fprintf(fd, "%s", buf);
if (group.equation_stat > 0 && group.points.status[n] > 0) {
FMT1(buf, xres[n], yres[n], gnd[n]);
fprintf(fd, "%s", buf);
}
else if (group.points.status[n] > 0)
printcentered(fd, "?", width);
else
printcentered(fd, "not used", width);
FMT2(buf,
group.points.e1[n],
group.points.n1[n], group.points.e2[n], group.points.n2[n]);
fprintf(fd, " %s\n", buf);
}
fprintf(fd, "\n");
if (group.equation_stat < 0)
fprintf(fd, "Poorly place control points\n");
else if (group.equation_stat == 0)
fprintf(fd, "No active control points\n");
else
fprintf(fd, "Overall rms error: %.2f\n", rms);
return 0;
}
static int printcentered(FILE * fd, char *buf, int width)
{
int len;
int n;
int i;
len = strlen(buf);
n = (width - len) / 2;
for (i = 0; i < n; i++)
fprintf(fd, " ");
fprintf(fd, "%s", buf);
i += len;
while (i++ < width)
fprintf(fd, " ");
return 0;
}
static int show_point(int n, int true_color)
{
if (!true_color)
R_standard_color(ORANGE);
else if (group.points.status[n])
R_standard_color(GREEN);
else
R_standard_color(RED);
display_one_point(VIEW_MAP1, group.points.e1[n], group.points.n1[n]);
return 0;
}

View File

@ -1,389 +0,0 @@
#include <string.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/display.h>
#include "globals.h"
#include "local_proto.h"
#define NLINES 18
struct box
{
int top, bottom, left, right;
};
static int pick(int, int, int);
static int downarrow(struct box *, int);
static int uparrow(struct box *, int);
static int dobox(struct box *, char *, int, int, int, int, int);
static int dotext(char *, int, int, int, int, int);
static int inbox(struct box *, int, int);
static int cancel_which(void);
static int text_size;
static int which;
static struct box cancel, more, less;
static int height, size, edge, count;
static int page, npages;
static struct
{
char name[GNAME_MAX], mapset[GMAPSET_MAX];
struct box box;
} list[NLINES * 2];
int
ask_gis_files(char *type, char *file, char *xname, char *xmapset,
int position)
{
static int use = 1;
static Objects objects[] = {
OTHER(pick, &use),
{0}
};
char msg[100];
FILE *fd;
int width;
int len1, len2, len;
long offset;
long *page_offset;
int col, nlist;
int line;
int stat;
char buf[100];
int top, bottom, left, right, center;
int topx, bottomx, leftx, rightx, widthx;
char name[GNAME_MAX], mapset[GMAPSET_MAX], cur_mapset[GMAPSET_MAX];
int new_mapset;
Menu_msg("");
fd = fopen(file, "r");
if (fd == NULL)
G_fatal_error("ask_gis_files: can't read tempfile");
if (fread(&len1, sizeof(len1), 1, fd) != 1
|| fread(&len2, sizeof(len2), 1, fd) != 1 || len1 <= 0 || len2 <= 0) {
fclose(fd);
return 0;
}
sprintf(msg, "Double click on %s file to be plotted", type);
/*
* build a popup window at center of the screen.
* 35% the height and wide enough to hold 2 columms of file names
*
* the window is for choosing file names and will be laid out in 2 columns
*
* ------------------------------------------
* | CANCEL | (MORE) | (LESS) |
* ------------------------------------------
* | mapset |
* ------------------------------------------
* | name1 | name2 |
* ------------------------------------------
* | name3 | name4 |
* ------------------------------------------
* | name5 | name6 |
* | . |
* | . |
* | . |
* ------------------------------------------
*/
/* height of 1 line, based on NLINES taking up 35% vertical space */
height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP)) / NLINES + 1;
/* size of text, 80% of line height */
text_size = .8 * height;
size = text_size - 1; /* fudge for computing pixels width of text */
/* indent for the text */
edge = .1 * height + 1;
/* this is a fudge to determine the length of the largest text */
len1 = 2 * len1; /* name in 2 columns */
len2 += strlen("mapset ");
len = (len1 > len2 ? len1 : len2);
/* width is for max chars plus sidecar for more/less */
width = len * size + height;
widthx = strlen(msg) * size;
if (widthx < width)
widthx = width;
/* define the window */
top = (SCREEN_TOP + SCREEN_BOTTOM - height * NLINES) / 2;
bottom = top + height * NLINES;
center = (SCREEN_LEFT + SCREEN_RIGHT) / 2;
if (position > 0) {
right = (center + SCREEN_RIGHT + width) / 2;
if (right >= SCREEN_RIGHT)
right = SCREEN_RIGHT - 1;
left = right - width;
}
else if (position < 0) {
left = (center + SCREEN_LEFT - width) / 2;
if (left <= SCREEN_LEFT)
left = SCREEN_LEFT + 1;
right = left + width;
}
else {
left = center + width / 2;
right = left + width;
}
topx = top - 3 * height;
bottomx = topx + 2 * height;
leftx = (left + right - widthx) / 2;
if (leftx < SCREEN_LEFT)
leftx = SCREEN_LEFT;
rightx = leftx + widthx;
/* save what is under these areas, so they can be restored */
R_panel_save(tempfile1, top, bottom + 1, left, right + 1);
R_panel_save(tempfile2, topx, bottomx + 1, leftx, rightx + 1);
/* fill it top with GREY, pick area with white */
R_standard_color(WHITE);
R_box_abs(left, top, right, bottom);
R_standard_color(GREY);
R_box_abs(leftx, topx, rightx, bottomx);
R_standard_color(BLACK);
Outline_box(top, bottom, left, right);
right -= height; /* reduce it to exclude sidecar */
Outline_box(top, bottom, left, right);
/* print messages above the files */
dotext(msg, topx, topx + height, leftx, rightx, 1);
dotext("Double click here to cancel", topx + height, bottomx, leftx,
rightx, 1);
cancel.top = topx;
cancel.bottom = bottomx;
cancel.left = leftx;
cancel.right = rightx;
/* start the mouse in the cancel box */
Set_mouse_xy((leftx + rightx) / 2, (topx + bottomx) / 2);
dobox(&less, "", WHITE, top, right, right + height, 0);
dobox(&more, "", WHITE, bottom - height, right, right + height, 0);
/* as we read the file of names, keep track of pages so we can
* page backward
*/
page = 0;
page_offset = (long *)G_calloc(npages = 1, sizeof(long));
*page_offset = G_ftell(fd);
nlist = sizeof(list) / sizeof(list[0]);
for (stat = -1; stat < 0;) {
line = 0;
count = 0;
*cur_mapset = 0;
col = 0;
while (1) {
offset = G_ftell(fd);
if (fgets(buf, sizeof buf, fd) == NULL
|| sscanf(buf, "%s %s", name, mapset) != 2)
break;
if (new_mapset = (strcmp(cur_mapset, mapset) != 0)) {
if (line)
line++;
if (col)
line++;
col = 0;
}
if (count >= nlist || line + new_mapset >= NLINES) {
if (page + 1 == npages) {
npages++;
page_offset =
(long *)G_realloc(page_offset, npages * sizeof(long));
page_offset[npages - 1] = offset;
}
break;
}
if (new_mapset) {
struct box dummy;
char label[GMAPSET_MAX + 7];
strcpy(cur_mapset, mapset);
sprintf(label, "Mapset %s", mapset);
dobox(&dummy, label, WHITE, top + line * height, left, right,
0);
line++;
}
if (col) {
dobox(&list[count].box, name, GREY, top + line * height,
left + width / 2, right, 0);
line++;
col = 0;
}
else {
dobox(&list[count].box, name, GREY, top + line * height, left,
left + width / 2, 0);
col = 1;
}
strcpy(list[count].name, name);
strcpy(list[count].mapset, mapset);
count++;
}
downarrow(&more, page + 1 < npages ? BLACK : WHITE);
uparrow(&less, page > 0 ? BLACK : WHITE);
which = -1;
switch (Input_pointer(objects)) {
case -1: /* more or less */
break;
case -2: /* cancel */
stat = 0;
continue;
default: /* file picked */
strcpy(xname, list[which].name);
strcpy(xmapset, list[which].mapset);
stat = 1;
continue;
}
G_fseek(fd, page_offset[page], 0);
R_standard_color(WHITE);
R_box_abs(left + 1, top + 1, right - 1, bottom - 1);
}
/* all done. restore what was under the window */
right += height; /* move it back over the sidecar */
R_standard_color(WHITE);
R_box_abs(left, top, right, bottom);
R_panel_restore(tempfile1);
R_panel_restore(tempfile2);
R_panel_delete(tempfile1);
R_panel_delete(tempfile2);
R_flush();
G_free(page_offset);
return stat;
}
static int dobox(struct box *box, char *text, int color, int top, int left,
int right, int centered)
{
int bottom;
bottom = top + height;
/* fill inside of box with color */
R_standard_color(color);
R_box_abs(left + 1, top + 1, right - 1, bottom - 1);
/* draw box outline and text in black */
R_standard_color(BLACK);
Outline_box(top, bottom, left, right);
dotext(text, top, bottom, left, right, centered);
R_flush();
box->top = top;
box->bottom = bottom;
box->left = left;
box->right = right;
return 0;
}
static int uparrow(struct box *box, int color)
{
R_standard_color(color);
Uparrow(box->top + edge, box->bottom - edge, box->left + edge,
box->right - edge);
return 0;
}
static int downarrow(struct box *box, int color)
{
R_standard_color(color);
Downarrow(box->top + edge, box->bottom - edge, box->left + edge,
box->right - edge);
return 0;
}
static int pick(int x, int y, int button)
{
int n;
if (inbox(&more, x, y)) {
cancel_which();
if (page + 1 >= npages)
return 0;
page++;
return -1;
}
if (inbox(&less, x, y)) {
cancel_which();
if (page == 0)
return 0;
page--;
return -1;
}
if (inbox(&cancel, x, y)) {
if (which == -2)
return -2;
cancel_which();
which = -2;
R_standard_color(RED);
Outline_box(cancel.top, cancel.bottom, cancel.left, cancel.right);
R_flush();
return 0;
}
/* search name list. handle double click */
for (n = 0; n < count; n++)
if (inbox(&list[n].box, x, y)) {
if (n == which) /* second click! */
return 1;
cancel_which();
which = n;
R_standard_color(RED);
Outline_box(list[n].box.top, list[n].box.bottom,
list[n].box.left, list[n].box.right);
R_flush();
return 0; /* ignore first click */
}
cancel_which();
return 0;
}
static int cancel_which(void)
{
if (which == -2) {
R_standard_color(BLACK);
Outline_box(cancel.top, cancel.bottom, cancel.left, cancel.right);
}
else if (which >= 0) {
R_standard_color(BLACK);
Outline_box(list[which].box.top, list[which].box.bottom,
list[which].box.left, list[which].box.right);
}
which = -1;
R_flush();
return 0;
}
static int inbox(struct box *box, int x, int y)
{
return (x > box->left && x < box->right && y > box->top &&
y < box->bottom);
}
static int dotext(char *text, int top, int bottom, int left, int right,
int centered)
{
R_text_size(text_size, text_size);
R_move_abs(left + 1 + edge, bottom - 1 - edge);
if (centered)
R_move_rel((right - left - strlen(text) * size) / 2, 0);
R_set_window(top, bottom, left, right); /* for text clipping */
R_text(text);
R_set_window(SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
return 0;
}

View File

@ -1,164 +0,0 @@
#include "globals.h"
#include "local_proto.h"
#include <grass/display.h>
struct box
{
int top, bottom, left, right;
};
static struct box plus, minus, value;
static struct box cancel, accept;
static int mag;
static int inbox(struct box *, int, int);
static int dotext(char *, int, int, int, int, int);
static int incr(int, int);
int ask_magnification(int *magnification)
{
static int use = 1;
int x, y;
int height;
int stat;
int width;
int top, bottom, left, right;
static Objects objects[] = {
OTHER(incr, &use),
{0}
};
Menu_msg("");
mag = *magnification;
if (mag < 1)
mag = 1;
height = VIEW_MENU->nrows;
R_text_size(height - 4, height - 4);
Get_mouse_xy(&x, &y);
top = y - height / 2;
if (top < SCREEN_TOP)
top = SCREEN_TOP;
bottom = top + 4 * height;
if (bottom >= VIEW_MENU->top) {
top -= bottom - (VIEW_MENU->top - 1);
bottom = VIEW_MENU->top - 1;
}
width = Text_width("MAGNIFICATION") + 4;
left = x - width / 2;
if (left < SCREEN_LEFT)
left = SCREEN_LEFT;
right = left + width;
if (right > SCREEN_RIGHT) {
left -= right - SCREEN_RIGHT;
right = SCREEN_RIGHT;
}
R_panel_save(tempfile1, top, bottom, left, right);
R_standard_color(WHITE);
R_box_abs(left, top, right, bottom);
R_standard_color(BLACK);
Outline_box(top, bottom, left, right);
plus.top = top + height;
plus.bottom = plus.top + height;
plus.left = left;
plus.right = plus.left + Text_width("++") + 4;
Outline_box(plus.top, plus.bottom, plus.left, plus.right);
minus.top = top + height;
minus.bottom = minus.top + height;
minus.right = right;
minus.left = minus.right - Text_width("--") - 4;
Outline_box(minus.top, minus.bottom, minus.left, minus.right);
value.top = top + height;
value.bottom = value.top + height;
value.left = plus.right;
value.right = minus.left;
Outline_box(value.top, value.bottom, value.left, value.right);
accept.top = value.bottom;
accept.bottom = accept.top + height;
accept.left = left;
accept.right = right;
Outline_box(accept.top, accept.bottom, accept.left, accept.right);
cancel.top = accept.bottom;
cancel.bottom = cancel.top + height;
cancel.left = left;
cancel.right = right;
Outline_box(cancel.top, cancel.bottom, cancel.left, cancel.right);
dotext("MAGNIFICATION", top, top + height, left, right, WHITE);
dotext("+", plus.top, plus.bottom, plus.left, plus.right, GREY);
dotext("-", minus.top, minus.bottom, minus.left, minus.right, GREY);
dotext("ACCEPT", accept.top, accept.bottom, accept.left, accept.right,
GREY);
dotext("CANCEL", cancel.top, cancel.bottom, cancel.left, cancel.right,
GREY);
draw_mag();
stat = Input_pointer(objects);
/* to respond to user */
R_standard_color(WHITE);
R_box_abs(left, top, right, bottom);
R_flush();
R_panel_restore(tempfile1);
R_panel_delete(tempfile1);
*magnification = mag;
return stat > 0;
}
int draw_mag(void)
{
char buf[10];
sprintf(buf, "%d", mag);
dotext(buf, value.top, value.bottom, value.left, value.right, WHITE);
return 0;
}
static int incr(int x, int y)
{
if (inbox(&accept, x, y))
return 1;
if (inbox(&cancel, x, y))
return -1;
if (inbox(&plus, x, y)) {
mag++;
draw_mag();
}
else if (inbox(&minus, x, y) && mag > 1) {
mag--;
draw_mag();
}
return 0;
}
static int dotext(char *text, int top, int bottom, int left, int right,
int background)
{
R_standard_color(background);
R_box_abs(left + 1, top + 1, right - 1, bottom - 1);
R_standard_color(BLACK);
/* center the text */
left = (left + right - Text_width(text)) / 2;
Text(text, top, bottom, left, right, 2);
R_flush();
return 0;
}
static int inbox(struct box *box, int x, int y)
{
return (x > box->left && x < box->right && y > box->top &&
y < box->bottom);
}

View File

@ -1,57 +0,0 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#ifdef __MINGW32__
#include <process.h>
#else
#include <sys/wait.h>
#endif
#include "globals.h"
#include "local_proto.h"
#include <grass/display.h>
/*
* call a subroutine, but as a child process
* allowing interrupts for the child
*/
#include <signal.h>
int call(int (*function) (), char *msg)
{
int pid;
int w, status;
char i_msg[80];
/*
* build interrupt msg
*/
sprintf(i_msg, "Hit %s %s\n", G_unctrl(interrupt_char), msg);
/*
* make sure all graphics have gotten to the monitor
*/
R_stabilize();
/* fork to create child */
pid = fork();
if (pid < 0) {
End_curses();
perror("Can't fork");
exit(1);
}
/* parent just waits for child */
Curses_allow_interrupts(1);
if (pid) {
Curses_write_window(PROMPT_WINDOW, 1, 1, i_msg);
while ((w = wait(&status)) != pid && w != -1) ;
Curses_allow_interrupts(0);
Curses_write_window(PROMPT_WINDOW, 1, 1, "\n");
}
/* child turns on interrupts and calls the function */
else {
signal(SIGINT, SIG_DFL);
(*function) ();
exit(0);
}
return 0;
}

View File

@ -1,89 +0,0 @@
#include <unistd.h>
#include <grass/gis.h>
#include "globals.h"
#include "local_proto.h"
static int use = 1;
static int choose_cellfile(char *, char *);
static int plot(int, int);
static int cancel(void);
int plotcell(int x, int y)
{
static Objects objects[] = {
MENU("CANCEL", cancel, &use),
INFO("Indicate which side should be plotted", &use),
OTHER(plot, &use),
{0}
};
/*
* if the target raster map list is ready, ask the user which side
* should be plotted, otherwise can only plot group files
*/
if (access(cell_list, 0) == 0)
Input_pointer(objects);
else
plot(VIEW_MAP1->left + 1, 0);
return 0;
}
static int cancel(void)
{
return 1;
}
static int plot(int x, int y)
{
char name[GNAME_MAX], mapset[GMAPSET_MAX];
struct Cell_head cellhd;
if (x > VIEW_MAP1->left && x < VIEW_MAP1->right) {
if (!choose_groupfile(name, mapset))
return 1;
Rast_get_cellhd(name, mapset, &cellhd);
Erase_view(VIEW_MAP1_ZOOM);
VIEW_MAP1_ZOOM->cell.configured = 0;
G_adjust_window_to_box(&cellhd, &VIEW_MAP1->cell.head,
VIEW_MAP1->nrows, VIEW_MAP1->ncols);
Configure_view(VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res);
drawcell(VIEW_MAP1);
}
else if (x > VIEW_MAP2->left && x < VIEW_MAP2->right) {
if (!choose_cellfile(name, mapset))
return 1;
select_target_env();
Rast_get_cellhd(name, mapset, &cellhd);
Erase_view(VIEW_MAP2_ZOOM);
VIEW_MAP2_ZOOM->cell.configured = 0;
G_adjust_window_to_box(&cellhd, &VIEW_MAP2->cell.head,
VIEW_MAP2->nrows, VIEW_MAP2->ncols);
Configure_view(VIEW_MAP2, name, mapset, cellhd.ns_res, cellhd.ew_res);
select_target_env();
drawcell(VIEW_MAP2);
select_current_env();
if (from_screen < 0) {
from_flag = 1;
from_screen = 0;
if (from_keyboard < 0) {
from_keyboard = 0;
from_screen = 1;
}
}
}
else
return 0; /* ignore mouse click */
display_points(1);
return 1;
}
static int choose_cellfile(char *name, char *mapset)
{
return ask_gis_files("raster", cell_list, name, mapset, 1);
}

View File

@ -1,23 +0,0 @@
#include "globals.h"
#include "local_proto.h"
int Outline_cellhd(View * view, struct Cell_head *cellhd)
{
int row, col;
int top, bottom, left, right;
row = northing_to_row(&view->cell.head, cellhd->north) + .5;
top = row_to_view(view, row);
col = easting_to_col(&view->cell.head, cellhd->west) + .5;
left = col_to_view(view, col);
row = northing_to_row(&view->cell.head, cellhd->south) + .5;
bottom = row_to_view(view, row);
col = easting_to_col(&view->cell.head, cellhd->east) + .5;
right = col_to_view(view, col);
Outline_box(top, bottom, left, right);
return 0;
}