[GRASS-SVN] r41382 - in grass-addons/imagery: . i.linespoints

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 11 15:15:14 EST 2010


Author: neteler
Date: 2010-03-11 15:15:13 -0500 (Thu, 11 Mar 2010)
New Revision: 41382

Added:
   grass-addons/imagery/i.linespoints/
   grass-addons/imagery/i.linespoints/Gmakefile
   grass-addons/imagery/i.linespoints/Makefile
   grass-addons/imagery/i.linespoints/analyze.c
   grass-addons/imagery/i.linespoints/ask.c
   grass-addons/imagery/i.linespoints/ask_mag.c
   grass-addons/imagery/i.linespoints/call.c
   grass-addons/imagery/i.linespoints/cell.c
   grass-addons/imagery/i.linespoints/cellhd.c
   grass-addons/imagery/i.linespoints/colors.c
   grass-addons/imagery/i.linespoints/conv.c
   grass-addons/imagery/i.linespoints/curses.c
   grass-addons/imagery/i.linespoints/debug.c
   grass-addons/imagery/i.linespoints/defs.h
   grass-addons/imagery/i.linespoints/digit.c
   grass-addons/imagery/i.linespoints/dot.c
   grass-addons/imagery/i.linespoints/drawcell.c
   grass-addons/imagery/i.linespoints/driver.c
   grass-addons/imagery/i.linespoints/equ.c
   grass-addons/imagery/i.linespoints/find.c
   grass-addons/imagery/i.linespoints/georef.c
   grass-addons/imagery/i.linespoints/globals.h
   grass-addons/imagery/i.linespoints/graphics.c
   grass-addons/imagery/i.linespoints/group.c
   grass-addons/imagery/i.linespoints/i.linespoints_sceenshot.png
   grass-addons/imagery/i.linespoints/input.c
   grass-addons/imagery/i.linespoints/line.c
   grass-addons/imagery/i.linespoints/local_proto.h
   grass-addons/imagery/i.linespoints/main.c
   grass-addons/imagery/i.linespoints/mark.c
   grass-addons/imagery/i.linespoints/mouse.c
   grass-addons/imagery/i.linespoints/points.c
   grass-addons/imagery/i.linespoints/target.c
   grass-addons/imagery/i.linespoints/title.c
   grass-addons/imagery/i.linespoints/view.c
   grass-addons/imagery/i.linespoints/where.c
   grass-addons/imagery/i.linespoints/write_line.c
   grass-addons/imagery/i.linespoints/zoom.c
   grass-addons/imagery/i.linespoints/zoom_box.c
   grass-addons/imagery/i.linespoints/zoom_pnt.c
Log:
added (needs update to GRASS 6)

Added: grass-addons/imagery/i.linespoints/Gmakefile
===================================================================
--- grass-addons/imagery/i.linespoints/Gmakefile	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/Gmakefile	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,45 @@
+PGM=i.linespoints
+
+LIST=main.o\
+	ask.o\
+	ask_mag.o\
+	analyze.o\
+	call.o\
+	cell.o\
+	cellhd.o\
+	conv.o\
+	colors.o\
+	curses.o\
+	debug.o\
+	digit.o\
+	dot.o\
+	drawcell.o\
+	driver.o\
+	equ.o\
+	find.o\
+	georef.o\
+	graphics.o\
+	group.o\
+	input.o\
+	line.o\
+	mark.o\
+	mouse.o\
+	points.o\
+	target.o\
+	title.o\
+	view.o\
+	where.o\
+	write_line.o\
+	zoom.o\
+	zoom_box.o\
+	zoom_pnt.o
+
+LIBES = $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) 
+DEPLIBS= $(DEPIMAGERYLIB) $(DEPD_LIB) $(DEPDISPLAYLIB) $(DEPRASTERLIB) $(DEPGISLIB) 
+
+$(BIN_INTER)/$(PGM): $(LIST) $(DEPLIBS)
+	$(CC) $(LDFLAGS) -o $@ $(LIST) $(LIBES) $(CURSES) $(MATHLIB) $(XDRLIB)
+
+$(LIST): globals.h defs.h
+
+$(DEPLIBS): #

Added: grass-addons/imagery/i.linespoints/Makefile
===================================================================
--- grass-addons/imagery/i.linespoints/Makefile	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/Makefile	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,15 @@
+MODULE_TOPDIR = ../..
+
+PGM = i.linespoints
+
+# grass5
+#LIBES     = $(IMAGERYLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(VASKLIB) $(CURSES) $(GMATHLIB)
+#DEPENDENCIES= $(IMAGERYDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(VASKDEP) $(GMATHDEP)
+#default: inter
+
+LIBES     = $(IMAGERYLIB) $(GMATHLIB) $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(VASKLIB) $(CURSES) $(FFTWLIB)
+DEPENDENCIES= $(IMAGERYDEP) $(GMATHDEP) $(D_DEP) $(DISPLAYDEP) $(RASTERDEP) $(GISDEP) $(VASKDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd


Property changes on: grass-addons/imagery/i.linespoints/Makefile
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/analyze.c
===================================================================
--- grass-addons/imagery/i.linespoints/analyze.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/analyze.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,887 @@
+#include <string.h>
+#include <unistd.h>
+#include <math.h>
+#include <stdlib.h>
+#include "raster.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 offsetx, offsety;
+static int n_old;
+static int which;
+static struct box more, less, report,box_lines, box_points;
+static int height, size, edge, nlines;
+static int curp, first_point;
+static double rms,l_rms;
+static double *xres, *yres, *gnd, *tres, *ures, *lgnd;
+static int pager;
+static int xmax, ymax, gmax;
+static int tmax, umax, lgmax;
+static char buf[300];
+int new_control_line (Lines *ln,double t1,double u1,double t2,double u2,int status);
+Lines lines;               /* contiene t ed u delle rette inserite */
+int  use_points=1;
+int top, bottom, left, right, width, middle, nums;
+int count =0, first_line=0;
+#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 LLINEHEAD2 "  #   dt    du   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 RLINEHEAD2 "    t1       u1         t2       u2  "
+
+#define BACKGROUND GREY
+
+int
+analyze (void)
+{
+
+    double t_temp1,u_temp1, t_temp2, u_temp2;
+
+    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 i;
+/* to give user a response of some sort */
+    if (group.points.count ==0)
+    return 0;
+
+
+    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;
+    use_points=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, left, right);
+
+
+/* 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 - 4;
+    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));
+
+
+   i=0;
+  while(group.points.status[i]!=1 && i < group.points.count)
+        i++;
+  if(i >=group.points.count && group.points.status[i]!=1)
+        i=0;
+offsetx = group.points.e2[i] - group.points.e1[i];
+offsety = group.points.n2[i] - group.points.n1[i];
+
+
+lines.count=0;
+for (i=0; i < group.points.count; i++)
+      { if (group.points.status[i] == 2 || group.points.status[i] == -2)
+        { points_to_line (group.points.e1[i], group.points.n1[i],group.points.e1[i+1], group.points.n1[i+1],&t_temp1,&u_temp1);
+          points_to_line (group.points.e2[i]- offsetx, group.points.n2[i]-offsety,group.points.e2[i+1]-offsetx, group.points.n2[i+1]-offsety,&t_temp2,&u_temp2);
+
+                  sprintf (buf, "t2[0] e u2[0]....   %f  %f   \n",10000*t_temp2,10000*u_temp2 );
+	Curses_write_window (INFO_WINDOW, 3+ i, 2, buf);
+
+
+          new_control_line ( &lines,10000*t_temp1,10000*u_temp1,10000*t_temp2,10000*u_temp2,group.points.status[i]);
+         }
+      }
+
+   tres = (double *) G_calloc (lines.count, sizeof (double));
+   ures = (double *) G_calloc (lines.count, sizeof (double));
+   lgnd = (double *) G_calloc (lines.count, sizeof (double));
+
+/* compute transformation for the first time */
+    compute_transformation();
+
+
+/* put head on the report */
+
+    box_points.top=top;
+    box_points.bottom=top+height-1;
+    box_points.left= left;
+    box_points.right=(right-left)/2;
+    dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, RED);
+    Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
+
+    box_lines.top=top;
+    box_lines.bottom=top+height-1;
+    box_lines.left= ((right- left)/2)+1;
+    box_lines.right=right;
+    dotext ("        ANALYZE -> LINES",top, top+height, ((right-left)/2)+1, right, 0, BLACK);
+   Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
+
+    cury=top;
+    cury = top+height;
+    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;
+    count = 0;
+    first_line = 0;
+
+/* lets do it */
+    pager = 1;
+    while(1)
+    {
+                 R_text_size (tsize, tsize);
+	line = 0;
+	curp = first_point;
+	cury = top + 3*height;
+                 count=0;
+	while(1)
+	{
+	    if (line >= nlines || curp >= group.points.count)
+		break;
+	    if(group.equation_stat > 0 && group.points.status[curp]==1)
+	    {
+                                   if(use_points){
+                                        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);
+                                        line++;
+                                        cury += height;
+                                        }
+	    }
+                   else if(group.points.status[curp] ==2)
+	    {
+                                  /* if(group.points.status[curp+1]!=3)
+                                        break;*/
+                                   if(!use_points)
+                                   {
+                                        color = BLUE;
+                                         if (count+first_line == tmax || count+first_line == umax || count+first_line == lgmax)
+		                color = RED;
+                                        sprintf (buf, "%5.1f %5.1f %5.1f ", tres[count+ first_line],ures[count+first_line],lgnd[count+first_line]);
+                                        dotext (buf, cury, cury+height, nums, middle, 0, color);
+                                        line++;
+                                        cury += height;
+                                   }
+
+                                   curp++;
+	    }
+	    else if (group.points.status[curp] > 0) {
+                                    FMT0 (buf, curp+1-count);
+		        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);
+		dotext ("?", cury, cury+height, nums, middle, 1, BLACK);
+                                   line++;
+                                   cury += height;
+                                   }
+
+                     else if (group.points.status[curp] == -2 ){
+                                 if(group.points.status[curp+1]!=-3)
+                                        break;
+                                if (!use_points) {
+                                        dotext ("not used", cury, cury+height, nums, middle, 1, BLUE);
+                                        line++;
+                                        cury += height;
+                                        }
+                                curp++;
+                                }
+                      else  if (use_points) {
+		dotext ("not used", cury, cury+height, nums, middle, 1, BLACK);
+                                   line++;
+                                   cury += height;
+                                   }
+     if (pager)
+	    {
+                                   if(use_points &&( group.points.status[curp]==1 || group.points.status[curp]==0))
+                                   {
+
+                                        FMT0 (buf, curp+1-2*(first_line+count));
+		        dotext (buf, cury-height, cury, 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-height, cury, middle, right-1, 0, BLACK);
+                                  }
+                                  if(!use_points &&( group.points.status[curp]>1 ||  group.points.status[curp]<-1))
+                                  {
+                                          FMT0 (buf, first_line + count);
+		        dotext (buf, cury-height, cury, left, nums, 0, BLACK);
+		        sprintf (buf, "%9.1f %9.1f %9.1f %9.1f ",
+		            lines.t1[first_line+count],
+		            lines.u1[first_line+count],
+		            lines.t2[first_line+count],
+		            lines.u2[first_line+count]);
+		        dotext (buf, cury-height, cury, middle, right-1, 0, BLACK);
+
+                                      }
+	    }
+                      if( group.points.status[curp]>1 ||  group.points.status[curp]<-1)
+                                  count++;
+	    curp++;
+	}
+	report.bottom = cury;
+                  if(use_points) {
+	        downarrow (&more,  ((group.points.count-curp)-2*(lines.count-(count+first_line)))>0 ? BLACK : BACKGROUND);
+	        uparrow   (&less, first_point > 0  ? BLACK : BACKGROUND);
+                  }
+                  if(!use_points) {
+	        downarrow (&more,  (lines.count-(count+first_line))>0 ? BLACK : BACKGROUND);
+	        uparrow   (&less, first_point > 0  ? BLACK : BACKGROUND);
+                  }
+
+	R_standard_color (BACKGROUND);
+	R_box_abs (left, cury, right-1, bottom);
+                  if(use_points) {
+                        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);
+	        }
+                }
+                else {
+                         if (lines.line_stat < 0)
+	        {
+	        color = RED;
+	        strcpy (buf, "Poorly placed control points");
+	        }
+	        else if (lines.line_stat == 0)
+	        {
+	        color = RED;
+	        strcpy (buf, "No active control points");
+	        }
+	        else
+	        {
+	         color = BLACK;
+	        sprintf (buf, "Overall rms error: %.2f", l_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();
+
+    free (xres); free (yres); free (gnd);
+    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;
+    int i;
+
+    cur = which;
+    cancel_which();
+    if (inbox(&more,x,y))
+    {
+	if (use_points && ((group.points.count-curp)-2*(lines.count-(count+first_line)))<=0)
+	    return 0;
+                  if(!use_points && (lines.count-(count+first_line))<=0)
+                      return 0;
+	first_point = curp;
+                 first_line +=count;
+        	pager = 1;
+	return 1;
+    }
+    if (inbox(&box_points,x,y))
+    {
+                 R_text_size (.8*height, .8*height);
+                 use_points=1;
+                 dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, RED);
+                 dotext ("        ANALYZE -> LINES",top, top+height,((right-left)/2)+1, right, 0, BLACK);
+                 Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
+                 Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
+                 dotext (LHEAD2, top+2*height, top+3*height, left, middle, 0, BLACK);
+                 dotext (RHEAD2, top+2*height, top+3*height, middle, right-1, 0, BLACK);
+                 first_point = 0;
+                 first_line = 0;
+                 pager = 1;
+	return 1;
+    }
+    if (inbox(&box_lines,x,y))
+    {
+                 R_text_size (.8*height, .8*height);
+                 use_points=0;
+                 dotext ("        ANALYZE -> LINES",top, top+height, ((right-left)/2)+1, right, 0, RED);
+                 dotext ("        ANALYZE -> POINTS",top, top+height, left, (right-left)/2, 0, BLACK);
+                 Outline_box (box_points.top, box_points.bottom, box_points.left, box_points.right);
+                 Outline_box (box_lines.top, box_lines.bottom, box_lines.left, box_lines.right);
+                 dotext (LLINEHEAD2, top+2*height, top+3*height, left, middle, 0, BLACK);
+                 dotext (RLINEHEAD2, top+2*height, top+3*height, middle, right-1, 0, BLACK);
+                 first_point = 0;
+                 first_line = 0;
+                 pager = 1;
+	return 1;
+    }
+    if (inbox(&less,x,y))
+    {
+	if (first_point == 0)
+	    return 0;
+	first_point = 0;
+                 first_line = 0;
+	pager = 1;
+	return 1;
+    }
+    if (!inbox (&report,x,y))
+    {
+      return 0;
+    }
+
+   n_old = n = (y - report.top)/height;
+    i=0;
+    if(use_points){
+        for (i; i<=n;  i++)
+                if (group.points.status[first_point + i]==2||group.points.status[first_point + i]==-2) n+=2;
+        }
+    else { while (n>=0) {
+                        if (group.points.status[first_point + i]==2||group.points.status[first_point + i]==-2)  {
+                                                                          n--;
+                                                                          i++;
+                                                                          }
+                          i++;
+                                    }
+              n=i-2;
+              }
+    if (n == cur) /* second click! */
+    {
+                 if  (group.points.status[first_point +n]==2||group.points.status[first_point +n]==-2) {
+                         group.points.status[first_point+n] = -group.points.status[first_point+n];
+                         group.points.status[first_point+(n+1)] = -group.points.status[first_point+(n+1)];
+                         lines.status[first_line + n_old] = - lines.status[first_line + n_old];
+                                                 }
+
+                   else
+                         group.points.status[first_point+n] = !group.points.status[first_point+n];
+                 compute_transformation();
+	show_point (first_point+n, 1);
+
+
+           return 1;
+    }
+    which = n;
+    show_point (first_point+n, 0);
+    R_standard_color (RED);
+    Outline_box (report.top + n*height, report.top +(n+1)*height,
+		         report.left, report.right-1);
+    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, 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 t1, t2, u1, u2;
+    double xval, yval, gval;
+    double tval, uval, lgval;
+
+    xmax = ymax = gmax = 0;
+    xval = yval = gval = 0.0;
+
+    Compute_equation();     /*trova gli A,B,C che legano punti dell'image a punti del ltarget  */
+     lines.line_stat = compute_georef_equations_lp(&lines);
+
+    if (group.equation_stat <= 0 && lines.line_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 && group.equation_stat>0; n++)
+    {
+	if (group.points.status[n] !=1) continue;
+	count++;
+	georef (group.points.e2[n], group.points.n2[n], &e1, &n1, group.E21, group.N21);
+	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);
+
+     count =0;
+     tmax = umax = lgmax = 0;
+     tval = uval = lgval = 0.0;
+     sum = 0.0;
+    l_rms = 0.0;
+    for (n = 0; n < lines.count && lines.line_stat>0 ; n++)
+    {
+	if (lines.status[n] !=2) continue;
+	count++;
+	georef (lines.t2[n], lines.u2[n], &t1, &u1, lines.E21, lines.N21);
+	georef (lines.t1[n], lines.u1[n], &t2, &u2, lines.E12, lines.N12);
+	if((d = tres[n] = t1- lines.t1[n]) < 0)
+	    d = -d;
+	if (d > tval)
+	{
+	    tmax = n;
+	    tval = d;
+	}
+
+	if ((d = ures[n] = u1- lines.u1[n]) < 0)
+	    d = -d;
+	if (d > uval)
+	{
+	    umax = n;
+	    uval = d;
+	}
+
+/* compute ground error (ie along diagonal) */
+	d1 = t2 - lines.t2[n];
+	d2 = u2 - lines.u2[n];
+	d = d1*d1 + d2*d2;
+	sum += d;                 /* add it to rms sum, before taking sqrt */
+	d = sqrt(d);
+	lgnd[n] = d;
+	if (d > lgval)             /* is this one the max? */
+	{
+	    lgmax = n;
+	    lgval = d;
+	}
+
+    }
+     if (count)
+	l_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[100];
+
+    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[100];
+    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)
+{
+   int  x_temp[2], y_temp[2];
+   int row,col;
+
+    if (!true_color)
+	R_standard_color (ORANGE);
+    else if(group.points.status[n]>0)
+	R_standard_color (GREEN);
+    else
+	R_standard_color (RED);
+     if (group.points.status[n]==0 || group.points.status[n] == 1 )
+                display_one_point (VIEW_MAP1, group.points.e1[n], group.points.n1[n]);
+     else {
+                 display_one_point (VIEW_MAP1, group.points.e1[n], group.points.n1[n]);
+                 display_one_point (VIEW_MAP1, group.points.e1[n+1], group.points.n1[n+1]);
+                 row = northing_to_row (&VIEW_MAP1->cell.head, group.points.n1[n]) + .5;
+                 col = easting_to_col  (&VIEW_MAP1->cell.head, group.points.e1[n]) + .5;
+                 y_temp[0] = row_to_view (VIEW_MAP1, row);
+                 x_temp[0] = col_to_view (VIEW_MAP1, col);
+
+                 row = northing_to_row (&VIEW_MAP1->cell.head, group.points.n1[n+1]) + .5;
+                 col = easting_to_col  (&VIEW_MAP1->cell.head,group.points.e1[n+1]) + .5;
+                 y_temp[1] = row_to_view (VIEW_MAP1, row);
+                 x_temp[1] = col_to_view (VIEW_MAP1, col);
+
+                 R_polyline_abs (x_temp,y_temp,2);
+                 R_flush();
+
+     }
+    return 0;
+}
+
+
+int points_to_line (double e1, double n1, double e2, double n2, double *t, double *u)
+{
+        double a,b,c;
+        a=-(n2 - n1);
+        b= (e2 - e1);
+        c= (n2*e1 - n1*e2);
+        *t= a/c;
+        *u=b/c;
+  }
+
+int new_control_line ( Lines *ln,
+    double t1,double u1,double t2,double u2,int status)
+{
+    int i;
+    unsigned int size;
+
+    i = (ln->count)++ ;
+    size =  ln->count * sizeof(double) ;
+    ln->t1 = (double *) G_realloc (ln->t1, size);
+    ln->t2 = (double *) G_realloc (ln->t2, size);
+    ln->u1 = (double *) G_realloc (ln->u1, size);
+    ln->u2 = (double *) G_realloc (ln->u2, size);
+    size =  ln->count * sizeof(int) ;
+    ln->status = (int *) G_realloc (ln->status, size);
+
+    ln->t1[i] = t1;
+    ln->t2[i] = t2;
+    ln->u1[i] = u1;
+    ln->u2[i] = u2;
+    ln->status[i] = status;
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/analyze.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/ask.c
===================================================================
--- grass-addons/imagery/i.linespoints/ask.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/ask.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,394 @@
+#include <string.h>
+#include <stdlib.h>
+#include "raster.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();
+
+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[100], mapset[100];
+    struct box box;
+} list[NLINES*2];
+
+int 
+ask_gis_files (char *type, char *file, char *xname, char *xmapset, int position)
+{
+    static int use = 1;
+    int pick();
+    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[100], mapset[100], cur_mapset[100];
+    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, left, right);
+    R_panel_save (tempfile2, topx, bottomx, leftx, rightx);
+
+/* 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 = 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 = 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[100];
+
+		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;
+	}
+	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();
+
+    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);
+
+    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);
+	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);
+	    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;
+
+    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;
+}


Property changes on: grass-addons/imagery/i.linespoints/ask.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/ask_mag.c
===================================================================
--- grass-addons/imagery/i.linespoints/ask_mag.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/ask_mag.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,168 @@
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.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 incr();
+    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);
+}


Property changes on: grass-addons/imagery/i.linespoints/ask_mag.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/call.c
===================================================================
--- grass-addons/imagery/i.linespoints/call.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/call.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,56 @@
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.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;
+}


Property changes on: grass-addons/imagery/i.linespoints/call.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/cell.c
===================================================================
--- grass-addons/imagery/i.linespoints/cell.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/cell.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,100 @@
+#include "globals.h"
+#include "local_proto.h"
+#include <unistd.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)
+{
+    int cancel();
+    int plot();
+    static Objects objects[] =
+    {
+	MENU("CANCEL", cancel, &use),
+	INFO("Indicate which side should be plotted", &use),
+	OTHER(plot, &use),
+	{0}
+    };
+/*
+ * if the target cell file 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[100], mapset[100];
+    struct Cell_head cellhd;
+
+    if (x > VIEW_MAP1->left && x < VIEW_MAP1->right)
+    {
+	if (!choose_groupfile(name,mapset))
+	    return 1;
+	if(G_get_cellhd(name, mapset, &cellhd) < 0)
+	    return 1;
+
+	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();
+
+	if(G_get_cellhd(name, mapset, &cellhd) < 0)
+	{
+	    select_current_env();
+	    return 1;
+	}
+
+	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);
+}


Property changes on: grass-addons/imagery/i.linespoints/cell.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/cellhd.c
===================================================================
--- grass-addons/imagery/i.linespoints/cellhd.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/cellhd.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,24 @@
+#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;
+}


Property changes on: grass-addons/imagery/i.linespoints/cellhd.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/colors.c
===================================================================
--- grass-addons/imagery/i.linespoints/colors.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/colors.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,10 @@
+#include "gis.h"
+#include "display.h"
+#include "D.h"
+int 
+set_colors (struct Colors *colors)
+{
+    D_set_colors (colors);
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/colors.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/conv.c
===================================================================
--- grass-addons/imagery/i.linespoints/conv.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/conv.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,58 @@
+#include "globals.h"
+/* conversion routines to convert from view x,y to cell col,row
+ * as well as cell col,row to cell east,north
+ */
+int 
+view_to_col (View *view, int x)
+{
+    return x - view->cell.left;
+}
+
+int 
+view_to_row (View *view, int y)
+{
+    return y - view->cell.top;
+}
+
+int 
+col_to_view (View *view, int col)
+{
+    return view->cell.left + col;
+}
+
+int 
+row_to_view (View *view, int row)
+{
+    return view->cell.top + row;
+}
+
+/* in these next 2 routines, location determines if we are
+ * converting from center of the cell (location == .5)
+ * top or left edge (location == 0.0)
+ * bottom or right edge (location == 1.0)
+ */
+
+double 
+row_to_northing (struct Cell_head *cellhd, int row, double location)
+{
+    return cellhd->north - (row + location) * cellhd->ns_res;
+}
+
+double 
+col_to_easting (struct Cell_head *cellhd, int col, double location)
+{
+    return cellhd->west + (col + location) * cellhd->ew_res;
+}
+
+double 
+northing_to_row (struct Cell_head *cellhd, double north)
+{
+    return  (cellhd->north - north) / cellhd->ns_res;
+}
+
+double 
+easting_to_col (struct Cell_head *cellhd, double east)
+{
+    return  (east - cellhd->west) / cellhd->ew_res;
+}
+


Property changes on: grass-addons/imagery/i.linespoints/conv.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/curses.c
===================================================================
--- grass-addons/imagery/i.linespoints/curses.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/curses.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,282 @@
+#include <stdlib.h>
+#include "globals.h"
+#include "local_proto.h"
+#include <unistd.h>
+
+static int inited = 0;
+
+static WINDOW *save;
+WINDOW *newwin();
+
+static Window *make_window (int top, int bottom, int left, int right)
+{
+    Window *window;
+
+    if (top < 0 || bottom >= LINES || left < 0 || right >= COLS
+    ||	bottom-top <= 1 || right-left <= 1)
+    {
+	End_curses();
+	fprintf (stderr, "make_window(%d,%d,%d,%d): illegal screen values\n",
+		top, bottom, left, right);
+	sleep(3);
+	exit(1);
+    }
+    window = (Window *) G_malloc (sizeof(Window));
+    window->top    = top;
+    window->bottom = bottom;
+    window->left   = left;
+    window->right  = right;
+    Curses_clear_window (window);
+    return window;
+}
+
+int Begin_curses (void)
+{
+/* should only be called once at program outset */
+
+    initscr () ;       /* initialize curses standard screens   */
+    raw() ;            /* set tty modes via curses calls       */
+    noecho() ;
+    nonl()   ;
+
+    inited = 1;
+
+/* make a window to save stdscr */
+    save = newwin(LINES,COLS,0,0);
+
+/* make_window (nrows, ncols, start_row, start_col) */
+    INFO_WINDOW   = make_window (0, LINES-4, COLS/2, COLS-1);
+    MENU_WINDOW   = make_window (0, LINES-4, 0, COLS/2);
+    PROMPT_WINDOW = make_window (LINES-4, LINES-1, 0, COLS-1);
+    refresh();
+
+
+    return 0;
+}
+
+int End_curses (void)
+{
+/* should only be called upon program exit */
+
+    clear() ;       /* clear the screen */
+    refresh() ;
+    endwin() ;      /* let curses reset the tty now */
+
+    return 0;
+}
+
+int Suspend_curses (void)
+{
+    overwrite (stdscr, save);
+    clear();
+    refresh();
+    endwin();
+
+    return 0;
+}
+
+int Resume_curses (void)
+{
+    clear();
+    refresh();
+    overwrite (save, stdscr);
+    refresh();
+
+    return 0;
+}
+
+int Curses_allow_interrupts (int ok)
+{
+    refresh();
+    if (ok)
+	noraw();
+    else
+	raw();
+
+    return 0;
+}
+
+int Curses_clear_window (Window *window)
+{
+    int y,x;
+
+if (!inited) return 1;
+    for (y = window->top+1; y < window->bottom; y++)
+    {
+	move (y, x=window->left+1);
+	while (x++ < window->right)
+	    addch (' ');
+    }
+    Curses_outline_window (window);
+    refresh();
+
+    return 0;
+}
+
+int Curses_outline_window (Window *window)
+{
+    int x, y;
+
+    move (window->top, x=window->left+1);
+    while (x++ < window->right)
+	addch ('-');
+    move (window->bottom, x=window->left+1);
+    while (x++ < window->right)
+	addch ('-');
+    for (y=window->top+1; y < window->bottom; y++)
+    {
+	move (y, window->left);
+	addch ('|');
+	move (y, window->right);
+	addch ('|');
+    }
+    move (window->top, window->left);
+    addch ('+');
+    move (window->top, window->right);
+    addch ('+');
+    move (window->bottom, window->left);
+    addch ('+');
+    if (window->bottom < LINES-1 || window->right < COLS-1)
+    {
+	move (window->bottom, window->right);
+	addch ('+');
+    }
+
+    return 0;
+}
+
+int Curses_write_window (Window *window, int line, int col, char *message)
+{
+    int y,x,i;
+
+if (!inited)
+{
+	fprintf (stderr, "%s\n", message);
+	return 1;
+}
+    if (line <= 0 || line >= window->bottom-window->top)
+	return 1;
+    if (col <= 0 || col >= window->right-window->left)
+	return 1;
+    move(y=window->top+line, x=window->left+col);
+    while (*message != 0 && *message != '\n' && x < window->right)
+    {
+	addch (*message);
+	message++;
+	x++;
+    }
+    if (*message == '\n')
+	for (i = x; i < window->right; i++)
+	    addch (' ');
+    move (y, x);
+    refresh();
+
+    return 0;
+}
+
+
+int 
+Curses_replot_screen (void) 
+{
+    int x,y;
+    getyx (stdscr, y, x);
+    wrefresh(curscr) ;
+    move (y, x);
+    refresh();
+
+    return 0;
+}
+
+int Curses_prompt_gets (char *prompt, char *answer)
+{
+    char c ;
+    int n;
+    int y,x;
+
+    *answer = 0;
+    n = 0;
+
+    Curses_write_window (PROMPT_WINDOW, 1, 1, "\n");
+    Curses_write_window (PROMPT_WINDOW, 1, 1, prompt);
+
+    for(;;)
+    {
+	refresh ();
+	c = Curses_getch(0) ;
+	if (c == '\n' || c == '\r')
+	    break;
+
+	getyx (stdscr, y, x);
+	if (c > 037 && c < 0177)
+	{
+	    if (x < PROMPT_WINDOW->right)
+	    {
+		*answer++ = c ;
+		*answer = 0 ;
+		addch(c) ;
+		n++;
+	    }
+	    continue;
+	}
+	if (c == '\b')
+	{
+	    if (n > 0)
+	    {
+		answer--;
+		*answer = 0;
+		move (y, x-1);
+		addch (' ');
+		move (y, x-1);
+		n--;
+	    }
+	    continue;
+	}
+	Beep();
+    }
+
+    return 0;
+}
+
+int 
+Beep (void)
+{
+    putchar ('\7');
+    fflush (stdout);
+
+    return 0;
+}
+
+int 
+Curses_getch (int with_echo)
+{
+    char achar;
+    int c;
+    int kill;
+
+if (!inited) return 0;
+    kill = 0;
+    while(1)
+    {
+	c = getch() & 0177;
+	if (c == interrupt_char)
+	{
+	    if (kill++ >= 3)
+	    {
+		End_curses();
+		exit(0);
+	    }
+	    continue;
+	}
+	kill = 0;
+	if (c != 18)
+	    break;
+	Curses_replot_screen();
+    }
+    if (with_echo)
+    {
+	achar = c;
+	addch(achar);
+	refresh();
+    }
+    return c;
+}


Property changes on: grass-addons/imagery/i.linespoints/curses.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/debug.c
===================================================================
--- grass-addons/imagery/i.linespoints/debug.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/debug.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,13 @@
+
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.h"
+int 
+debug (char *msg)
+{
+    R_stabilize();
+    Curses_write_window (PROMPT_WINDOW, 1, 1, msg);
+    Curses_getch(0);
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/debug.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/defs.h
===================================================================
--- grass-addons/imagery/i.linespoints/defs.h	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/defs.h	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,72 @@
+#include "imagery.h"
+#include <curses.h>
+
+/* this is a curses structure */
+typedef struct
+{
+    int top, left, bottom, right;
+} Window;
+
+/* this is a graphics structure */
+typedef struct
+{
+    int top, bottom ,left, right;
+    int nrows, ncols;
+    struct
+    {
+	int configured;
+	struct Cell_head head;
+	struct Colors colors;
+	char name[100];
+	char mapset[100];
+	int top, bottom ,left, right;
+	double ew_res, ns_res;	/* original map resolution */
+    } cell;
+} View;
+
+
+typedef struct
+{
+    char name[100];
+    struct Ref ref;
+    struct Control_Points points;
+    double E12[3], N12[3], E21[3], N21[3];
+    int equation_stat;
+} Group;
+
+typedef struct
+{
+    int   type;         /* object type */
+    int (*handler)();	/* routine to handle the event */
+    char *label;	/* label to display if MENU or OPTION */
+    int   binding;      /* OPTION bindings */
+    int  *status;	/* MENU,OPTION status */
+    int top,bottom,left,right;
+} Objects;
+
+#define MENU_OBJECT 1
+#define OPTION_OBJECT 2
+#define INFO_OBJECT 3
+#define OTHER_OBJECT 4
+
+
+#define MENU(label,handler,status) \
+	{MENU_OBJECT,handler,label,0,status,0,0,0,0}
+#define OPTION(label,binding,status) \
+	{OPTION_OBJECT,NULL,label,binding,status,0,0,0,0}
+#define INFO(label,status) \
+	{INFO_OBJECT,NULL,label,0,status,0,0,0,0}
+#define OTHER(handler,status) \
+	{OTHER_OBJECT,handler,NULL,0,status,0,0,0,0}
+
+typedef struct
+{
+      double *t1;
+      double *u1;
+      double *t2;
+      double *u2;
+      int *status;
+     double E12[3], N12[3], E21[3], N21[3];
+      int count;
+      int line_stat;
+} Lines;


Property changes on: grass-addons/imagery/i.linespoints/defs.h
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/digit.c
===================================================================
--- grass-addons/imagery/i.linespoints/digit.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/digit.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,129 @@
+#include "globals.h"
+#include "local_proto.h"
+#include <unistd.h>
+#include <stdlib.h>
+
+static int setup(void);
+static int oops(void);
+static int yes(void);
+static int no(void);
+
+int 
+setup_digitizer (void)
+{
+    static int use = 1;
+    int setup(), no(), yes();
+    static Objects objects[]=
+    {
+	INFO("Do you wish to use the digitizer?  ", &use),
+	MENU("YES", yes, &use),
+	MENU("NO", no, &use),
+	{0}
+    };
+    char command[1024];
+
+    use_digitizer = 0;
+/*
+ * test to see if we have a digitizer (geo.quest)
+ * make sure this program has execute permission first.
+ * then run the program and check its exit status
+ *  0 means can use digitizer, other means can't
+ */
+    sprintf (command, "%s/etc/geo.quest", G_gisbase());
+    if (access (command, 1) != 0)
+	return 0;
+    if (system(command))
+	return 0;
+
+
+/*
+ * ask the user if he/she wishes to use it
+ */
+    Start_mouse_in_menu();
+    Input_pointer (objects);
+    if (use_digitizer)
+	Input_other (setup, "Keyboard");
+
+    return 0;
+}
+
+static int 
+setup (void)
+{
+    char command[1024];
+/*
+ * setup the digitizer. system() call must exit with 0 to indicate
+ * everything went fine
+ */
+    sprintf (command, "%s/etc/geo.reg %s %d",
+	G_gisbase(), digit_points, getpid());
+    Suspend_curses();
+    if (system (command))
+    {
+	use_digitizer = 0;
+	sleep(3);
+    }
+    Resume_curses();
+
+    return 0;
+}
+
+int 
+digitizer_point (double *east, double *north)
+{
+    char command[1024];
+    FILE *fd;
+    int stat;
+
+/* make sure digitzer is to be used */
+    if (!use_digitizer)
+	return 0;
+
+    sprintf (command, "%s/etc/geo.point %s %s",
+	G_gisbase(), digit_points, digit_results);
+
+    Suspend_curses();
+    if(system (command))
+    {
+	sleep(3);
+	Resume_curses();
+	oops();
+	return 0;
+    }
+    Resume_curses();
+    fd = fopen (digit_results, "r");
+    if (fd == NULL)
+    {
+	oops();
+	return 0;
+    }
+    stat = (fscanf (fd, "%lf %lf", east, north) == 2);
+    fclose (fd);
+
+    if (stat == 0)
+	oops();
+    return stat;
+}
+
+static int 
+oops (void)
+{
+    Curses_clear_window (MENU_WINDOW);
+    Curses_write_window (MENU_WINDOW, 3,2,"Can't get data from digitizer");
+
+    return 0;
+}
+
+static int 
+no (void)
+{
+    use_digitizer = 0;
+    return 1;
+}
+
+static int 
+yes (void)
+{
+    use_digitizer = 1;
+    return 1;
+}


Property changes on: grass-addons/imagery/i.linespoints/digit.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/dot.c
===================================================================
--- grass-addons/imagery/i.linespoints/dot.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/dot.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,54 @@
+#include "globals.h"
+#include "raster.h"
+int 
+dot (int x, int y)
+{
+    int vx[5], vy[5];
+
+    vx[0] = x;           vy[0] = y - dotsize;
+    vx[1] = x - dotsize; vy[1] = y;
+    vx[2] = x;           vy[2] = y + dotsize;
+    vx[3] = x + dotsize; vy[3] = y;
+    vx[4] = x;           vy[4] = y - dotsize;
+
+    R_polygon_abs (vx, vy, 5);
+/*
+    int i;
+
+    for (i = 0; i < dotsize; i++)
+    {
+	R_move_abs (x-i, y+i-dotsize);
+	R_cont_rel (i+i,0);
+	R_move_abs (x-i, y+dotsize-i);
+	R_cont_rel (i+i,0);
+    }
+    R_move_abs (x-dotsize, y);
+    R_cont_rel (dotsize+dotsize, 0);
+*/
+
+    return 0;
+}
+
+int 
+save_under_dot (int x, int y)
+{
+    R_panel_save (tempfile1, y-dotsize, y+dotsize, x-dotsize, x+dotsize);
+
+    return 0;
+}
+
+int 
+restore_under_dot (void)
+{
+    R_panel_restore (tempfile1);
+
+    return 0;
+}
+
+int 
+release_under_dot (void)
+{
+    R_panel_delete (tempfile1);
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/dot.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/drawcell.c
===================================================================
--- grass-addons/imagery/i.linespoints/drawcell.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/drawcell.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,81 @@
+#include <stdlib.h>
+#include "globals.h"
+#include "display.h"
+#include "raster.h"
+#include "local_proto.h"
+
+int drawcell(View *view)
+{
+    int fd;
+    int left, top;
+    int ncols, nrows;
+    int row;
+    DCELL *dcell;
+    int repeat;
+    struct Colors *colors;
+    int read_colors;
+    char msg[100];
+
+
+    if (!view->cell.configured) return 0;
+    if (view == VIEW_MAP1 || view == VIEW_MAP1_ZOOM)
+    {
+	colors = &VIEW_MAP1->cell.colors;
+	read_colors = view == VIEW_MAP1;
+    }
+    else
+    {
+	colors = &VIEW_MAP2->cell.colors;
+	read_colors = view == VIEW_MAP2;
+    }
+    if (read_colors)
+    {
+	G_free_colors (colors);
+	if(G_read_colors (view->cell.name, view->cell.mapset, colors) < 0)
+	    return 0;
+    }
+
+    display_title (view);
+
+    set_colors (colors);
+
+    /*G_setup_plot(view->cell.top, view->cell.bottom,  view->cell.left, view->cell.right,D_move_abs,D_cont_abs);*/
+    D_cell_draw_setup(view->top, view->bottom,  view->left, view->right);
+    D_set_clip_window(view->top, view->bottom,  view->left, view->right);
+
+    G_set_window (&view->cell.head);
+    nrows = G_window_rows();
+    ncols = G_window_cols();
+
+    left = view->cell.left;
+    top = view->cell.top;
+
+    R_standard_color (BLUE);
+    Outline_box (top, top+nrows-1, left, left+ncols-1);
+
+    if (getenv("NO_DRAW"))
+        return 1;
+
+    fd = G_open_cell_old (view->cell.name, view->cell.mapset);
+    if (fd < 0)
+	return 0;
+    dcell = G_allocate_d_raster_buf();
+
+    sprintf (msg, "Plotting %s ...", view->cell.name);
+    Menu_msg(msg);
+
+    for (row = 0; row < nrows; row += repeat)
+    {
+	R_move_abs (left, top+row);
+	if(G_get_d_raster_row_nomask(fd, dcell, row) < 0)
+	    break;
+	repeat = G_row_repeat_nomask (fd, row);
+	D_d_raster (dcell, ncols, repeat, colors);
+    }
+    G_close_cell (fd);
+    free (dcell);
+    if(colors != &VIEW_MAP1->cell.colors)
+	set_colors(&VIEW_MAP1->cell.colors);
+
+    return row==nrows;
+}


Property changes on: grass-addons/imagery/i.linespoints/drawcell.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/driver.c
===================================================================
--- grass-addons/imagery/i.linespoints/driver.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/driver.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,58 @@
+#include "globals.h"
+#include "local_proto.h"
+
+static int use = 1;
+static int stop(void);
+static int dont_stop(void);
+static int really_quit(void);
+
+int
+driver (void)
+{
+    static Objects objects[] =
+    {
+	MENU("QUIT",really_quit,&use),
+	MENU("ZOOM",zoom,&use),
+	MENU("PLOT RASTER",plotcell,&use),
+                 MENU("LINE",line,&use), 
+                 MENU("ANALYZE",analyze,&use),
+	INFO("  Input method -> ", &from_flag),
+/*	OPTION("DIGITIZER",2,&from_digitizer),
+	OPTION("KEYBOARD",2,&from_keyboard), */
+	OPTION("SCREEN",2,&from_screen),
+	OTHER(mark, &use),
+	{0}
+    };
+
+    Input_pointer (objects);
+    Menu_msg ("");
+
+    return 0;
+}
+
+static int 
+really_quit (void)
+{
+    static Objects objects[] =
+    {
+	INFO("really quit? ",&use),
+	MENU("NO",dont_stop,&use),
+	MENU("YES",stop,&use),
+	{0}
+    };
+    if (Input_pointer (objects) < 0)
+	return -1;
+    return 0; /* don't quit */
+}
+
+static int 
+dont_stop (void)
+{
+    return 1;
+}
+
+static int 
+stop (void)
+{
+    return -1;
+}


Property changes on: grass-addons/imagery/i.linespoints/driver.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/equ.c
===================================================================
--- grass-addons/imagery/i.linespoints/equ.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/equ.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,11 @@
+#include "globals.h"
+#include "local_proto.h"
+
+int 
+Compute_equation (void)
+{
+    group.equation_stat = compute_georef_equations(&group.points,
+	group.E12, group.N12, group.E21, group.N21);
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/equ.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/find.c
===================================================================
--- grass-addons/imagery/i.linespoints/find.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/find.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include "globals.h"
+#include "local_proto.h"
+
+/*
+ * run etc/i.find command find all cell, vect files
+ * in the target location.
+ */
+int find_target_files (void)
+{
+    char command[1024];
+
+    select_target_env();
+    sprintf (command, "%s/etc/i.find %s %s cell %s dig %s",
+	G_gisbase(), G_location(), G_mapset(), cell_list, vect_list);
+    select_current_env();
+
+    system(command);
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/find.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/georef.c
===================================================================
--- grass-addons/imagery/i.linespoints/georef.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/georef.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,325 @@
+#include <signal.h>
+#include "globals.h"
+
+static int floating_exception;
+static void catch(int);
+static double determinant(double,double,
+                double,double,double,double,double,double,double);
+void (*sigfpe)();
+
+/* find coefficients A,B,C for e2 = A + B*e1 + C*n1
+ * also compute the reverse equations
+ *
+ * return 0 if no points
+ *       -1 if not solvable
+ *        1 if ok
+ *
+ * method is least squares.
+ * the least squares problem reduces to solving the following
+ * system of equations for A,B,C
+ *
+ *   s0*A + s1*B + s2*C = x0
+ *   s1*A + s3*B + s4*C = x1
+ *   s2*A + s4*B + s5*C = x2
+ *
+ * use Cramer's rule
+ *
+ *     | x0 s1 s2 |      | s0 x0 s2 |      | s0 s1 x0 |
+ *     | x1 s3 s4 |      | s1 x1 s4 |      | s1 s3 x1 |
+ *     | x2 s4 s5 |      | s2 x2 s5 |      | s2 s4 x2 |
+ * A = ------------  B = ------------  C = ------------
+ *     | s0 s1 s2 |      | s0 s1 s2 |      | s0 s1 s2 |
+ *     | s1 s3 s4 |      | s1 s3 s4 |      | s1 s3 s4 |
+ *     | s2 s4 s5 |      | s2 s4 s5 |      | s2 s4 s5 |
+ *
+ */
+
+int compute_georef_equations(
+    struct Control_Points *cp,
+    double E12[3], double N12[3], double E21[3], double N21[3])
+{
+    double s0,s1,s2,s3,s4,s5;
+    double x0,x1,x2;
+    double det;
+    int i;
+
+
+    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
+    for (i = 0; i < cp->count; i++)
+    {
+	if (cp->status[i] != 1)
+	    continue;
+	s0 += 1.0;
+	s1 += cp->e1[i];
+	s2 += cp->n1[i];
+	s3 += cp->e1[i] * cp->e1[i];
+	s4 += cp->e1[i] * cp->n1[i];
+	s5 += cp->n1[i] * cp->n1[i];
+    }
+    if (s0 < 0.5) return 0;
+
+    floating_exception = 0;
+    sigfpe = signal (SIGFPE, catch);
+
+/* eastings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < cp->count; i++)
+    {
+	if (cp->status[i] != 1)
+	    continue;
+	x0 += cp->e2[i];
+	x1 += cp->e1[i] * cp->e2[i];
+	x2 += cp->n1[i] * cp->e2[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    E12[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    E12[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    E12[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+/* northings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < cp->count; i++)
+    {
+	if (cp->status[i] != 1)
+	    continue;
+	x0 += cp->n2[i];
+	x1 += cp->e1[i] * cp->n2[i];
+	x2 += cp->n1[i] * cp->n2[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    N12[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    N12[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    N12[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+/* the inverse equations */
+
+    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
+    for (i = 0; i < cp->count; i++)
+    {
+	if (cp->status[i] != 1)
+	    continue;
+	s0 += 1.0;
+	s1 += cp->e2[i];
+	s2 += cp->n2[i];
+	s3 += cp->e2[i] * cp->e2[i];
+	s4 += cp->e2[i] * cp->n2[i];
+	s5 += cp->n2[i] * cp->n2[i];
+    }
+
+/* eastings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < cp->count; i++)
+    {
+	if (cp->status[i] != 1)
+	    continue;
+	x0 += cp->e1[i];
+	x1 += cp->e2[i] * cp->e1[i];
+	x2 += cp->n2[i] * cp->e1[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    E21[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    E21[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    E21[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+/* northings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < cp->count; i++)
+    {
+	if (cp->status[i] != 1)
+	    continue;
+	x0 += cp->n1[i];
+	x1 += cp->e2[i] * cp->n1[i];
+	x2 += cp->n2[i] * cp->n1[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    N21[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    N21[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    N21[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+    signal (SIGFPE, sigfpe);
+    return floating_exception ? -1 : 1;
+}
+
+
+int compute_georef_equations_lp (Lines *ln)
+{
+    double s0,s1,s2,s3,s4,s5;
+    double x0,x1,x2;
+    double det;
+    int i;
+
+
+    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	s0 += 1.0;
+	s1 += ln->t1[i];
+	s2 += ln->u1[i];
+	s3 += ln->t1[i] * ln->t1[i];
+	s4 += ln->t1[i] * ln->u1[i];
+	s5 += ln->u1[i] * ln->u1[i];
+    }
+    if (s0 < 0.5) return 0;
+
+    floating_exception = 0;
+    sigfpe = signal (SIGFPE, catch);
+
+/* eastings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	x0 += ln->t2[i];
+	x1 += ln->t1[i] * ln->t2[i];
+	x2 += ln->u1[i] * ln->t2[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    ln->E12[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    ln->E12[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    ln->E12[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+/* northings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	x0 += ln->u2[i];
+	x1 += ln->t1[i] * ln->u2[i];
+	x2 += ln->u1[i] * ln->u2[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    ln->N12[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    ln->N12[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    ln->N12[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+/* the inverse equations */
+
+    s0 = s1 = s2 = s3 = s4 = s5 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	s0 += 1.0;
+	s1 += ln->t2[i];
+	s2 += ln->u2[i];
+	s3 += ln->t2[i] * ln->t2[i];
+	s4 += ln->t2[i] * ln->u2[i];
+	s5 += ln->u2[i] * ln->u2[i];
+    }
+
+/* eastings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	x0 += ln->t1[i];
+	x1 += ln->t2[i] * ln->t1[i];
+	x2 += ln->u2[i] * ln->t1[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    ln->E21[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    ln->E21[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    ln->E21[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+/* northings */
+    x0 = x1 = x2 = 0.0;
+    for (i = 0; i < ln->count; i++)
+    {
+	if (ln->status[i] != 2)
+	    continue;
+	x0 += ln->u1[i];
+	x1 += ln->t2[i] * ln->u1[i];
+	x2 += ln->u2[i] * ln->u1[i];
+    }
+
+    det = determinant (s0,s1,s2,s1,s3,s4,s2,s4,s5);
+    if (det == 0.0)
+    {
+	signal (SIGFPE, sigfpe);
+	return -1;
+    }
+    ln->N21[0] = determinant (x0,s1,s2,x1,s3,s4,x2,s4,s5)/det;
+    ln->N21[1] = determinant (s0,x0,s2,s1,x1,s4,s2,x2,s5)/det;
+    ln->N21[2] = determinant (s0,s1,x0,s1,s3,x1,s2,s4,x2)/det;
+
+    signal (SIGFPE, sigfpe);
+    return floating_exception ? -1 : 1;
+}
+
+
+
+static double determinant (
+    double a, double b, double c, double d, double e,
+    double f, double g, double h, double i)
+{
+/* compute determinant of 3x3 matrix
+ *     | a b c |
+ *     | d e f |
+ *     | g h i |
+ */
+    return a * (e*i - f*h) - b * (d*i - f*g) + c * (d*h - e*g) ;
+}
+
+static void catch(int n)
+{
+    floating_exception = 1;
+    signal (n, catch);
+}
+
+int georef (
+    double e1,double n1,
+    double *e2,double *n2,
+    double E[3],double N[3])
+{
+    *e2 = E[0] + E[1] * e1 + E[2] * n1;
+    *n2 = N[0] + N[1] * e1 + N[2] * n1;
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/georef.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/globals.h
===================================================================
--- grass-addons/imagery/i.linespoints/globals.h	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/globals.h	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,74 @@
+#include "defs.h"
+
+#ifndef GLOBAL
+#  define GLOBAL extern
+#  define INIT(x)
+#else
+#  define INIT(x) = x
+#endif
+
+GLOBAL int G_get_color();
+
+GLOBAL int SCREEN_TOP;
+GLOBAL int SCREEN_BOTTOM;
+GLOBAL int SCREEN_LEFT;
+GLOBAL int SCREEN_RIGHT;
+
+GLOBAL Window *INFO_WINDOW;
+GLOBAL Window *MENU_WINDOW;
+GLOBAL Window *PROMPT_WINDOW;
+
+GLOBAL View *VIEW_MAP1;
+GLOBAL View *VIEW_TITLE1;
+GLOBAL View *VIEW_MAP1_ZOOM;
+GLOBAL View *VIEW_TITLE1_ZOOM;
+
+GLOBAL View *VIEW_MAP2;
+GLOBAL View *VIEW_TITLE2;
+GLOBAL View *VIEW_MAP2_ZOOM;
+GLOBAL View *VIEW_TITLE2_ZOOM;
+
+GLOBAL View *VIEW_MENU;
+
+GLOBAL Group group;
+
+GLOBAL char interrupt_char;
+GLOBAL char *tempfile1;
+GLOBAL char *tempfile2;
+GLOBAL char *tempfile3;
+GLOBAL char *digit_points;            /* digitizer control points */
+GLOBAL char *digit_results;           /* digitizer results */
+GLOBAL int  use_digitizer INIT(0);    /* is there a digitizer out there? */
+
+/* group file list, target cell,vector files */
+GLOBAL char *group_list INIT(NULL);
+GLOBAL char *cell_list INIT(NULL);
+GLOBAL char *vect_list INIT(NULL);
+
+GLOBAL int  from_keyboard  INIT(-1);   /* input method */
+GLOBAL int  from_digitizer INIT(-1);
+GLOBAL int  from_screen    INIT(-1);
+GLOBAL int  from_flag      INIT(0);
+
+GLOBAL int  dotsize INIT(4);
+
+
+GLOBAL int THE_COLORS[10];
+#define BLACK	THE_COLORS[0]
+#define BLUE	THE_COLORS[1]
+#define BROWN	THE_COLORS[2]
+#define GREEN	THE_COLORS[3]
+#define GREY	THE_COLORS[4]
+#define ORANGE	THE_COLORS[5]
+#define PURPLE	THE_COLORS[6]
+#define RED	THE_COLORS[7]
+#define WHITE	THE_COLORS[8]
+#define YELLOW	THE_COLORS[9]
+
+double row_to_northing();
+double col_to_easting();
+double northing_to_row();
+double easting_to_col();
+
+#undef INIT
+


Property changes on: grass-addons/imagery/i.linespoints/globals.h
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/graphics.c
===================================================================
--- grass-addons/imagery/i.linespoints/graphics.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/graphics.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,150 @@
+#include "globals.h"
+#include "local_proto.h"
+#include "display.h"
+#include "D.h"
+#include "raster.h"
+
+static View *
+makeview (double bottom, double top, double left, double right)
+{
+    View *view;
+
+    view = (View *) G_malloc (sizeof (View));
+
+    top = 100-top;
+    bottom = 100-bottom;
+
+    view->top    = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * top / 100.0 ;
+    view->bottom = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP) * bottom / 100.0 ;
+    view->left   = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * left / 100.0 ;
+    view->right  = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT) * right / 100.0 ;
+
+    if (view->top < SCREEN_TOP)
+	view->top = SCREEN_TOP;
+    if (view->bottom > SCREEN_BOTTOM)
+	view->bottom = SCREEN_BOTTOM;
+    if (view->left < SCREEN_LEFT)
+	view->left = SCREEN_LEFT;
+    if (view->right > SCREEN_RIGHT)
+	view->right = SCREEN_RIGHT;
+
+    Outline_box (view->top, view->bottom, view->left, view->right);
+
+    view->top++;
+    view->bottom--;
+    view->left++;
+    view->right--;
+
+    view->nrows = view->bottom - view->top + 1;
+    view->ncols = view->right - view->left + 1;
+    view->cell.configured = 0;
+
+    return view;
+}
+
+int 
+Init_graphics (void)
+{
+    /*
+    R_color_table_fixed();
+    */
+    R_color_offset (0);
+
+    Dscreen();
+
+
+    SCREEN_TOP    = R_screen_top();
+    SCREEN_BOTTOM = R_screen_bot();
+    SCREEN_LEFT   = R_screen_left();
+    SCREEN_RIGHT  = R_screen_rite();
+
+
+    BLACK  = D_translate_color ("black");
+    BLUE   = D_translate_color ("blue");
+    BROWN  = D_translate_color ("brown");
+    GREEN  = D_translate_color ("green");
+    GREY   = D_translate_color ("grey");
+    ORANGE = D_translate_color ("orange");
+    PURPLE = D_translate_color ("purple");
+    RED    = D_translate_color ("red");
+    WHITE  = D_translate_color ("white");
+    YELLOW = D_translate_color ("yellow");
+
+    R_standard_color (WHITE);
+
+    VIEW_TITLE1      = makeview (97.5, 100.0,  0.0,  50.0);
+    VIEW_TITLE2      = makeview (97.5, 100.0, 50.0, 100.0);
+    VIEW_MAP1        = makeview (51.0,  97.5,  0.0,  50.0);
+    VIEW_MAP2        = makeview (51.0,  97.5, 50.0, 100.0);
+    VIEW_TITLE1_ZOOM = makeview (47.5,  51.0,  0.0,  50.0);
+    VIEW_TITLE2_ZOOM = makeview (47.5,  51.0, 50.0, 100.0);
+    VIEW_MAP1_ZOOM   = makeview (2.5,   47.5,  0.0,  50.0);
+    VIEW_MAP2_ZOOM   = makeview (2.5,   47.5, 50.0, 100.0);
+    VIEW_MENU        = makeview (0.0,    2.5,  0.0, 100.0);
+
+    G_init_colors (&VIEW_MAP1->cell.colors);
+    G_init_colors (&VIEW_MAP2->cell.colors);
+
+    return 0;
+}
+
+int 
+Outline_box (int top, int bottom, int left, int right)
+{
+    R_move_abs (left,  top);
+    R_cont_abs (left,  bottom);
+    R_cont_abs (right, bottom);
+    R_cont_abs (right, top);
+    R_cont_abs (left,  top);
+
+    return 0;
+}
+
+
+int 
+Text_width (char *text)
+{
+    int top, bottom, left, right;
+
+    R_get_text_box (text, &top, &bottom, &left, &right);
+
+    if (right > left)
+	return right-left+1;
+    else
+	return left-right+1;
+}
+
+int 
+Text (char *text, int top, int bottom, int left, int right, int edge)
+{
+    R_set_window (top, bottom, left, right);
+    R_move_abs (left+edge, bottom-edge);
+    R_text (text);
+    R_set_window (SCREEN_TOP, SCREEN_BOTTOM, SCREEN_LEFT, SCREEN_RIGHT);
+
+    return 0;
+}
+
+int 
+Uparrow (int top, int bottom, int left, int right)
+{
+    R_move_abs ((left+right)/2, bottom);
+    R_cont_abs ((left+right)/2, top);
+    R_cont_rel ((left-right)/2, (bottom-top)/2);
+    R_move_abs ((left+right)/2, top);
+    R_cont_rel ((right-left)/2, (bottom-top)/2);
+
+    return 0;
+}
+
+int 
+Downarrow (int top, int bottom, int left, int right)
+{
+    R_move_abs ((left+right)/2, top);
+    R_cont_abs ((left+right)/2, bottom);
+    R_cont_rel ((left-right)/2, (top-bottom)/2);
+    R_move_abs ((left+right)/2, bottom);
+    R_cont_rel ((right-left)/2, (top-bottom)/2);
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/graphics.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/group.c
===================================================================
--- grass-addons/imagery/i.linespoints/group.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/group.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,69 @@
+#include <string.h>
+#include <stdlib.h>
+#include "globals.h"
+#include "local_proto.h"
+
+static int cmp(const void *, const void *);
+
+int prepare_group_list (void)
+{
+    FILE *fd;
+    int *idx;
+    int n;
+    int len,len1,len2;
+
+/* open file to store group file names */
+    fd = fopen (group_list, "w");
+    if (fd == NULL)
+	G_fatal_error ("Can't open any tempfiles");
+
+/*
+ * build sorted index into group files
+ * so that all cell files for a mapset to appear together
+ */
+    idx = (int *) G_calloc (group.ref.nfiles, sizeof (int));
+    for (n = 0; n < group.ref.nfiles; n++)
+	idx[n] = n;
+    qsort (idx, group.ref.nfiles, sizeof(int), cmp);
+
+/* determine length of longest mapset name, and longest cell file name */
+    len1 = len2 = 0;
+    for (n = 0; n < group.ref.nfiles; n++)
+    {
+	len = strlen (group.ref.file[n].name);
+	if (len > len1)
+	    len1 = len;
+	len = strlen (group.ref.file[n].mapset);
+	if (len > len2)
+	    len2 = len;
+    }
+
+/* write lengths, names to file */
+    fwrite (&len1, sizeof (len1), 1, fd);
+    fwrite (&len2, sizeof (len2), 1, fd);
+    for (n = 0; n < group.ref.nfiles; n++)
+	fprintf (fd, "%s %s\n", group.ref.file[idx[n]].name, group.ref.file[idx[n]].mapset);
+    fclose (fd);
+
+    free (idx);
+
+    return 0;
+}
+
+static int cmp (const void *aa, const void *bb)
+{
+    const int *a = aa, *b = bb;
+    int n;
+
+    if(n = strcmp (group.ref.file[*a].mapset, group.ref.file[*b].mapset))
+	return n;
+    return strcmp (group.ref.file[*a].name, group.ref.file[*b].name);
+}
+
+/* ask the user to pick a file */
+int choose_groupfile (char *name,char *mapset)
+{
+    int stat;
+    stat = ask_gis_files ("raster", group_list, name, mapset, -1);
+    return(stat);
+}


Property changes on: grass-addons/imagery/i.linespoints/group.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/i.linespoints_sceenshot.png
===================================================================
(Binary files differ)


Property changes on: grass-addons/imagery/i.linespoints/i.linespoints_sceenshot.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: grass-addons/imagery/i.linespoints/input.c
===================================================================
--- grass-addons/imagery/i.linespoints/input.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/input.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,287 @@
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.h"
+#include <strings.h>
+
+static int active = 0;
+static int replot;
+static int mouse (Objects *,int,int,int);
+static int use_mouse_msg(void);
+static int draw_objects (Objects *);
+static Objects *find (Objects *,int, int);
+static int select_option (Objects *,Objects *);
+static int draw_option_boxes (Objects *);
+static int visible( Objects *);
+
+#define TEXT_COLOR BLACK
+#define FILL_COLOR GREY
+#define OUTLINE_COLOR WHITE
+
+/* Input: drive mouse. returns status of handler that returns != 0 */
+int Input_pointer (Objects *objects)
+{
+    return mouse (objects,0,0,0);
+}
+
+int Input_box (Objects *objects,int ax,int ay)
+{
+    return mouse (objects,ax,ay,1);
+}
+
+int Input_other (int (*function)(), char *type)
+{
+    int stat;
+    char msg[1024];
+
+    sprintf (msg, "%s input required", type);
+    Menu_msg(msg);
+
+    stat = (*function)();
+    if (active)
+    {
+	use_mouse_msg();
+    }
+
+    Menu_msg("");
+    return stat;
+}
+
+static int mouse (Objects *objects,int ax,int ay,int box)
+{
+    int first;
+    int stat;
+    int x,y,button;
+    Objects *obj;
+    Objects *find();
+
+
+    first = !active;
+    active = 1;
+    if (first)
+	use_mouse_msg();
+
+    if (box)
+    {
+	x = ax + 20;
+	y = ay + 20;
+    }
+    stat = 0;
+    replot = 1;
+    while (stat == 0)
+    {
+	if (replot)
+	{
+	    replot = 0;
+	    draw_objects (objects);
+	}
+	if (box)
+	    Mouse_box_anchored (ax, ay, &x, &y, &button) ;
+	else
+	    Mouse_pointer (&x, &y, &button) ;
+
+	if (!(obj = find (objects, x, y)))
+	    continue;
+
+	switch (obj->type)
+	{
+	case MENU_OBJECT:
+	case OTHER_OBJECT:
+		stat = (*obj->handler)(x,y,button);
+		break;
+	case OPTION_OBJECT:
+		select_option (objects, obj);
+		draw_option_boxes(objects);
+		break;
+	}
+    }
+
+/* if we are first call, mark not active
+ * indicate that objects above use must be replotted.
+ */
+    if (first)
+	active = 0;
+    Menu_msg("");
+
+    return stat;
+}
+
+
+static int
+use_mouse_msg (void)
+{
+    Curses_write_window (PROMPT_WINDOW, 1, 1, "Use mouse now ...\n");
+
+    return 0;
+}
+
+static int draw_objects (Objects *objects)
+{
+    Objects *obj;
+    int top, bottom, left, right;
+    int size, edge;
+
+
+/* erase the menu window */
+    Erase_view (VIEW_MENU);
+    R_flush();
+
+/* determine sizes and text indentation */
+    size = VIEW_MENU->nrows - 4;
+    edge = 2;
+
+    R_text_size (size, size);
+
+    left  = VIEW_MENU->left;
+    top   = VIEW_MENU->top;
+    bottom  = VIEW_MENU->bottom;
+
+
+/* put the (boxed) text on the menu view */
+    for (obj = objects; obj->type; obj++)
+    {
+	if (!visible(obj))
+	    continue;
+	switch (obj->type)
+	{
+	case OPTION_OBJECT:
+	case MENU_OBJECT:
+		right = left + 2*edge + Text_width (obj->label);
+		if(!strcmp(obj->label,"LINE")){
+                                        obj->left = left+1;
+		obj->right = right+1;
+                                    } else {
+                                          obj->left = left;
+		       obj->right = right;
+
+                                        }
+
+		obj->top = top;
+		obj->bottom = bottom;
+
+		R_standard_color (FILL_COLOR);
+		R_box_abs (left, top, right, bottom);
+
+		R_standard_color (TEXT_COLOR);
+		Text (obj->label, top, bottom, left, right, edge);
+
+                                   if(!strcmp(obj->label,"LINE"))
+                                       R_standard_color(BLUE);
+                                   else R_standard_color (OUTLINE_COLOR);
+		Outline_box (top, bottom, left, right);
+
+		left = right;
+		break;
+
+	case INFO_OBJECT:
+		if (*obj->label == 0) break;
+		if (*obj->status < 0) break;
+		right = left + 2*edge + Text_width (obj->label);
+		R_standard_color (WHITE);
+		Text (obj->label, top, bottom, left, right, edge);
+
+		left = right;
+		break;
+	}
+    }
+    draw_option_boxes (objects);
+    R_flush();
+
+    return 0;
+}
+
+static Objects *find (Objects *objects,int x, int y)
+{
+    Objects *other;
+    other = NULL;
+    for (; objects->type; objects++)
+    {
+	if (!visible (objects))
+	    continue;
+	switch (objects->type)
+	{
+	case MENU_OBJECT:
+	case OPTION_OBJECT:
+	    if (x >= objects->left && x <= objects->right
+	    &&  y >= objects->top  && y <= objects->bottom)
+		    return objects;
+	    break;
+	case OTHER_OBJECT:
+	    other = objects;
+	    break;
+	}
+    }
+    return other;
+}
+
+static int select_option (Objects *objects,Objects *obj)
+{
+    while (objects->type)
+    {
+	if (objects->type == OPTION_OBJECT && *objects->status >= 0 &&
+	    objects->binding == obj->binding)
+		*objects->status = 0;
+	objects++;
+    }
+    *obj->status = 1;
+
+    return 0;
+}
+
+static int draw_option_boxes (Objects *objects)
+{
+    Objects *x;
+
+    R_standard_color (OUTLINE_COLOR);
+    for (x = objects; x->type; x++)
+    {
+	if (x->type == OPTION_OBJECT && *x->status == 0)
+	    Outline_box (x->top, x->bottom, x->left, x->right);
+    }
+    R_standard_color (GREEN);
+    for (x = objects; x->type; x++)
+    {
+	if (x->type == OPTION_OBJECT && *x->status > 0)
+	    Outline_box (x->top, x->bottom, x->left, x->right);
+    }
+
+    return 0;
+}
+
+static int visible( Objects *object)
+{
+    if (object->type == OPTION_OBJECT)
+	return (*object->status >= 0);
+    return (*object->status > 0);
+}
+
+int Menu_msg(char *msg)
+{
+    int size, edge;
+
+    size = VIEW_MENU->nrows - 4;
+    edge = 2;
+
+    Erase_view (VIEW_MENU);
+
+    if (*msg)
+    {
+	R_text_size (size, size);
+	R_standard_color (WHITE);
+	Text (msg, VIEW_MENU->top, VIEW_MENU->bottom,
+		   VIEW_MENU->left, VIEW_MENU->right, edge);
+    }
+    R_flush();
+    replot = 1;
+
+    return 0;
+}
+
+int 
+Start_mouse_in_menu (void)
+{
+    Set_mouse_xy (
+	(VIEW_MENU->left+2*VIEW_MENU->right)/3,
+	(VIEW_MENU->top+VIEW_MENU->bottom)/2);
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/input.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/line.c
===================================================================
--- grass-addons/imagery/i.linespoints/line.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/line.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,229 @@
+#include "globals.h"
+#include "local_proto.h"
+
+static int cancel();
+static int select(int x1,int y1,int button);
+
+
+//static int get_point2 (double *,double *, double *,double *);
+//static int screen (int,int,int);
+
+
+double temp_e1,temp_e2,temp_n1,temp_n2;
+static int flag;
+void find_position (int *x1, int *x2,int *y1,int *y2);
+int xtemp[2],ytemp[2], first_linex[2],first_liney[2];
+
+int
+line (void)
+{
+    int stat,row,col,i;
+    static int use = 1;
+    double e1,e2,e3,e4,n1,n2,n3,n4;
+ //   int x1,x2,x3,x4,y1,y2,y3,y4;
+    static Objects objects1[]=
+    {
+	MENU("CANCEL",cancel,&use),
+	INFO("select first line (left side) ",&use),
+                 OTHER(select, &use),
+	{0}
+    };
+
+     static Objects objects2[]=
+    {
+	MENU("CANCEL",cancel,&use),
+	INFO("select second line (right side) ",&use),
+                 OTHER(select, &use),
+	{0}
+    };
+
+
+    flag =0;
+    stat= Input_pointer (objects1);
+    if (stat==-1) return 0;
+
+    e1=temp_e1;
+    e2=temp_e2;
+    n1=temp_n1;
+    n2=temp_n2;
+    flag = 1;
+
+    for (i=0;i<2;i++)
+        {
+         first_linex[i]=xtemp[i];
+         first_liney[i]=ytemp[i];
+          }
+
+    stat=Input_pointer (objects2);
+     if (stat==-1)
+    {
+         R_panel_restore (tempfile2);   /* serve al ripristino del quadrato che contiene la linea collogante i 2 punti */
+         R_panel_restore (tempfile3);    /*  serve al ripristino del secondo punto*/
+         R_panel_restore (tempfile1);    /*  serve al ripristino del primo punto*/
+         R_panel_delete (tempfile1);
+         R_panel_delete (tempfile2);
+         R_panel_delete (tempfile3);
+
+         return 0;
+    }
+
+
+    e3=temp_e1;
+    e4=temp_e2;
+    n3=temp_n1;
+    n4=temp_n2;
+     I_new_control_point (&group.points, e1, n1, e3, n3, 2);
+     put_control_points (group.name, &group.points);
+     Compute_equation();
+     display_points(1) ;
+     I_new_control_point (&group.points, e2, n2, e4, n4, 3);
+     put_control_points (group.name, &group.points);
+     Compute_equation();
+     display_points(1) ;
+     R_standard_color (GREEN);
+     R_polyline_abs (first_linex ,first_liney,2);
+     R_polyline_abs (xtemp ,ytemp,2);
+     R_flush();
+
+    return 0;	/* return, but don't QUIT */
+}
+
+static int select(int x,int y,int button)
+{
+        if (button != 1)
+          return where (x,y);
+
+        if (flag==0) {
+                                         if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
+                                                select_line (VIEW_MAP1, x, y);
+                                        else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
+                                                select_line (VIEW_MAP1_ZOOM, x, y);
+                                        else return 0;
+                                     }
+         if (flag==1) {
+                                        if (VIEW_MAP2->cell.configured && In_view (VIEW_MAP2, x, y))
+                                                select_line (VIEW_MAP2, x, y);
+                                        else if (VIEW_MAP2_ZOOM->cell.configured && In_view (VIEW_MAP2_ZOOM, x, y))
+                                                select_line (VIEW_MAP2_ZOOM, x, y);
+                                         else return 0;
+                                      }
+          return 1 ; /* return but don't quit */
+
+};
+
+int select_line (View *view,int x1, int y1)
+{
+    int col, row;
+    int x2,y2,button=0;
+    char buf[50];
+
+
+
+    col = view_to_col (view, x1);
+    temp_e1 = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y1);
+    temp_n1 = row_to_northing (&view->cell.head, row, 0.5);
+
+    if (flag== 0)
+                {
+                         Curses_clear_window (INFO_WINDOW);
+                         Curses_clear_window (MENU_WINDOW);
+                         sprintf (buf, "Point  %d marked on image at", group.points.count+1);
+                         Curses_write_window (MENU_WINDOW, 1, 1, buf);
+                         sprintf (buf, "East:  %10.2f", temp_e1);
+                         Curses_write_window (MENU_WINDOW, 3, 3, buf);
+                         sprintf (buf, "North: %10.2f", temp_n1);
+                         Curses_write_window (MENU_WINDOW, 4, 3, buf);
+                }
+     else
+              {
+
+                         sprintf (buf, "Point  %d marked on target image at", group.points.count+1);
+                         Curses_write_window (INFO_WINDOW, 1, 1, buf);
+                         sprintf (buf, "East:  %10.2f",temp_e1);
+                         Curses_write_window (INFO_WINDOW, 3, 3, buf);
+                         sprintf (buf, "North: %10.2f", temp_n1);
+                         Curses_write_window (INFO_WINDOW, 4, 3, buf);
+               }
+
+    R_standard_color (ORANGE);
+    R_panel_save (tempfile1, y1-dotsize, y1+dotsize, x1-dotsize, x1+dotsize);
+     dot(x1,y1);
+
+         while (button!=1)
+        {
+        R_get_location_with_line (x1,y1,&x2,&y2,&button);
+        if( button!=1)
+            where (x2,y2);
+         if (!(view->cell.configured && In_view (view, x2, y2)))
+                                  button=0;
+          }
+
+    col = view_to_col (view, x2);
+   temp_e2 = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y2);
+    temp_n2 = row_to_northing (&view->cell.head, row, 0.5);
+
+   if (flag== 0)
+                {
+                         sprintf (buf, "Point  %d marked on image at", group.points.count+2);
+                         Curses_write_window (MENU_WINDOW, 6, 1, buf);
+                         sprintf (buf, "East:  %10.2f", temp_e2);
+                         Curses_write_window (MENU_WINDOW, 8, 3, buf);
+                         sprintf (buf, "North: %10.2f", temp_n2);
+                         Curses_write_window (MENU_WINDOW, 9, 3, buf);
+                  }
+     else
+              {
+                         sprintf (buf, "Point  %d marked on target image at", group.points.count+2);
+                         Curses_write_window (INFO_WINDOW, 6, 1, buf);
+                         sprintf (buf, "East:  %10.2f",temp_e2);
+                         Curses_write_window (INFO_WINDOW, 8, 3, buf);
+                         sprintf (buf, "North: %10.2f", temp_n2);
+                         Curses_write_window (INFO_WINDOW, 9, 3, buf);
+                 }
+
+    R_standard_color (ORANGE);
+    R_panel_save (tempfile3, y2-dotsize, y2+dotsize, x2-dotsize, x2+dotsize);
+     dot(x2,y2);
+
+     xtemp[0]= x1;
+     xtemp[1]= x2;
+     ytemp[0]= y1;
+     ytemp[1]= y2;
+
+    find_position (&x1,&x2,&y1,&y2);
+    R_panel_save (tempfile2, y1, y2, x1, x2);
+    R_polyline_abs (xtemp ,ytemp,2);
+
+    return 1 ;
+
+ }
+
+ void find_position (int *x1, int *x2,int *y1,int *y2)
+  { int temp;
+    if (*y2<*y1) {
+                         temp=*y1;
+                         *y1=*y2;
+                         *y2= temp;
+                         }
+     else if (*y2==*y1) { *y2= *y2+dotsize;
+                                  *y1= *y1 - dotsize ;
+                                  }
+     if (*x2<*x1) {
+                         temp=*x1;
+                         *x1=*x2;
+                         *x2= temp;
+                         }
+     else if (*x2==*x1) { *x2= *x2+dotsize;
+                                  *x1= *x1 - dotsize ;
+                                  }
+ }
+
+
+   static int cancel()
+ {
+    return -1 ;
+}
+
+


Property changes on: grass-addons/imagery/i.linespoints/line.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/local_proto.h
===================================================================
--- grass-addons/imagery/i.linespoints/local_proto.h	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/local_proto.h	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,117 @@
+/* analyze.c */
+int analyze(void);
+/* ask.c */
+int ask_gis_files(char *, char *, char *, char *, int);
+/* ask_mag.c */
+int ask_magnification(int *);
+int draw_mag(void);
+/* call.c */
+int call(int (*)(), char *);
+/* cell.c */
+int plotcell(int, int);
+/* cellhd.c */
+int Outline_cellhd(View *, struct Cell_head *);
+/* colors.c */
+int set_colors(struct Colors *);
+/* conv.c */
+int view_to_col(View *, int);
+int view_to_row(View *, int);
+int col_to_view(View *, int);
+int row_to_view(View *, int);
+double row_to_northing(struct Cell_head *, int, double);
+double col_to_easting(struct Cell_head *, int, double);
+double northing_to_row(struct Cell_head *, double);
+double easting_to_col(struct Cell_head *, double);
+/* curses.c */
+int Begin_curses(void);
+int End_curses(void);
+int Suspend_curses(void);
+int Resume_curses(void);
+int Curses_allow_interrupts(int);
+int Curses_clear_window(Window *);
+int Curses_outline_window(Window *);
+int Curses_write_window(Window *, int, int, char *);
+int Curses_replot_screen(void);
+int Curses_prompt_gets(char *, char *);
+int Beep(void);
+int Curses_getch(int);
+/* debug.c */
+int debug(char *);
+/* digit.c */
+int setup_digitizer(void);
+int digitizer_point(double *, double *);
+/* dot.c */
+int dot(int, int);
+int save_under_dot(int, int);
+int restore_under_dot(void);
+int release_under_dot(void);
+/* drawcell.c */
+int drawcell(View *);
+/* driver.c */
+int driver(void);
+/* equ.c */
+int Compute_equation(void);
+/* find.c */
+int find_target_files(void);
+/*georef.c*/
+int compute_georef_equations(struct Control_Points *cp, double E12[3], double N12[3], double E21[3], double N21[3]);
+int compute_georef_equations_lp (Lines *ln);
+int georef (double e1,double n1,double *e2,double *n2,double E[3],double N[3]);
+/* graphics.c */
+int Init_graphics(void);
+int Outline_box(int, int, int, int);
+int Text_width(char *);
+int Text(char *, int, int, int, int, int);
+int Uparrow(int, int, int, int);
+int Downarrow(int, int, int, int);
+/* group.c */
+int prepare_group_list(void);
+int choose_groupfile(char *, char *);
+/* input.c */
+int Input_pointer(Objects *);
+int Input_box(Objects *, int, int);
+int Input_other(int (*)(), char *);
+int Menu_msg(char *);
+int Start_mouse_in_menu(void);
+/* line.c */
+int line(void);
+/* main.c */
+int quit(int);
+int error(char *, int);
+/* mark.c */
+int mark(int, int, int);
+int mark_point(View *, int, int);
+/* mouse.c */
+int Mouse_pointer(int *, int *, int *);
+int Mouse_box_anchored(int, int, int *, int *, int *);
+int Get_mouse_xy(int *, int *);
+int Set_mouse_xy(int, int);
+/* points.c */
+int display_points(int);
+int display_points_in_view(View *, int, double *, double *, int *, int);
+int display_one_point(View *, double, double);
+/* target.c */
+int get_target(void);
+int select_current_env(void);
+int select_target_env(void);
+/* title.c */
+int display_title(View *);
+/* view.c */
+int Configure_view(View *, char *, char *, double, double);
+int In_view(View *, int, int);
+int Erase_view(View *);
+double magnification(View *);
+/* where.c */
+int where(int, int);
+/*write_line.c*/
+int put_control_points ( char *group, struct Control_Points *cp);
+int read_control_points (FILE *fd, struct Control_Points *cp);
+int new_control_point (struct Control_Points *cp,double e1,double n1,double e2,double n2, int status);
+int write_control_points(FILE *fd, struct Control_Points *cp);
+int get_control_points (char *group, struct Control_Points *cp);
+/* zoom.c */
+int zoom(void);
+/* zoom_box.c */
+int zoom_box(int x,int y);
+/* zoom_pnt.c */
+int zoom_point(int x, int y);


Property changes on: grass-addons/imagery/i.linespoints/local_proto.h
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/main.c
===================================================================
--- grass-addons/imagery/i.linespoints/main.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/main.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,194 @@
+/*
+****************************************************************************
+*
+* MODULE:       i.linespoints 
+* AUTHOR(S):    Daniel Grasso, Bolzano, Italy
+*               based on i.points by Michael Shapiro, U.S.Army CERL
+*
+* PURPOSE:      An imagery function that enables the user to mark coordinate
+*               system points as well as lines on an image to be rectified
+*               and then input the coordinates of each point for creation of
+*               a coordinate transformation matrix. The transformation
+*               matrix is needed as input for the GRASS program i.pr.homolp
+* COPYRIGHT:    (C) 2003 by the GRASS Development Team
+*
+*               This program is free software under the GNU General Public
+*   	    	License (>=v2). Read the file COPYING that comes with GRASS
+*   	    	for details.
+*
+*****************************************************************************/
+
+#define GLOBAL
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.h"
+
+#ifdef __GNUC_MINOR__
+int quit (int) __attribute__ ((__noreturn__));
+#else
+int quit (int);
+#endif
+int error (char *, int);
+int main (int argc, char *argv[])
+{
+    char name[100], mapset[100];
+    struct Cell_head cellhd;
+
+    G_gisinit (argv[0]);
+    G_suppress_masking();	/* need to do this for target location */
+
+    interrupt_char = G_intr_char();
+    tempfile1 = G_tempfile();
+    tempfile2 = G_tempfile();
+    tempfile3 = G_tempfile();
+    cell_list = G_tempfile();
+    vect_list = G_tempfile();
+    group_list = G_tempfile();
+    digit_points = G_tempfile();
+    digit_results = G_tempfile();
+
+   if (R_open_driver() != 0)
+	G_fatal_error ("No graphics device selected");
+
+    if (!I_ask_group_old ("Enter imagery group to be registered", group.name))
+	exit(0);
+    if (!I_get_group_ref (group.name, &group.ref))
+    {
+        fprintf (stderr, "Group [%s] contains no files\n", group.name);
+	exit(1);
+    }
+    if (group.ref.nfiles <= 0)
+    {
+	fprintf (stderr, "Group [%s] contains no files\n", group.name);
+	sleep(3);
+	exit(1);
+    }
+/* write group files to group list file */
+    prepare_group_list();
+
+/* get target info and enviroment */
+    get_target();
+    find_target_files();
+
+/* read group control points, if any */
+    G_suppress_warnings(1);
+    if (!get_control_points (group.name, &group.points))
+	group.points.count = 0;
+    G_suppress_warnings(0);
+
+/* determine tranformation equation */
+    Compute_equation();
+
+
+    signal (SIGINT, SIG_IGN);
+/*  signal (SIGQUIT, SIG_IGN); */
+
+    Init_graphics();
+    display_title (VIEW_MAP1);
+    select_target_env ();
+    display_title (VIEW_MAP2);
+    select_current_env ();
+
+    Begin_curses();
+    G_set_error_routine (error);
+
+/*
+#ifdef SIGTSTP
+    signal (SIGTSTP, SIG_IGN);
+#endif
+*/
+
+
+/* ask user for group file to be displayed */
+    do
+    {
+	if(!choose_groupfile (name, mapset))
+	    quit(0);
+/* display this file in "map1" */
+    }
+    while (G_get_cellhd (name, mapset, &cellhd) < 0);
+    G_adjust_window_to_box (&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols);
+    R_standard_color (BLACK);
+    Configure_view (VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res);
+
+    drawcell(VIEW_MAP1);
+    display_points(1);
+    R_flush();
+
+    Curses_clear_window (PROMPT_WINDOW);
+
+    /* control if the image in the left side is in xy projection */
+
+    if ((G_projection() != PROJECTION_XY))
+    {
+         char msg[256];
+         sprintf(msg,"this raster is already georeferenced!\n (not in xy-projection)");
+         G_fatal_error (msg);
+         exit(1);
+    }
+/* determine initial input method. */
+    setup_digitizer();
+    if (use_digitizer)
+    {
+	from_digitizer = 1;
+	from_keyboard  = 0;
+	from_flag = 1;
+    }
+
+/* go do the work */
+    driver();
+
+    quit(0);
+}
+
+int quit (int n)
+{
+    char command[1024];
+
+    End_curses();
+    R_close_driver();
+    if (use_digitizer)
+    {
+	sprintf (command, "%s/etc/geo.unlock %s",
+	    G_gisbase(), digit_points);
+	system (command);
+    }
+    unlink (tempfile1);
+    unlink (tempfile2);
+    unlink (tempfile3);
+    unlink (cell_list);
+    unlink (group_list);
+    unlink (vect_list);
+    unlink (digit_points);
+    unlink (digit_results);
+    exit(n);
+}
+
+int error (char *msg, int fatal)
+{
+    char buf[200];
+    int x,y,button;
+
+Curses_clear_window (PROMPT_WINDOW);
+Curses_write_window (PROMPT_WINDOW,1,1, "LOCATION:\n");
+Curses_write_window (PROMPT_WINDOW,1,12,G_location());
+Curses_write_window (PROMPT_WINDOW,2,1, "MAPSET:\n");
+Curses_write_window (PROMPT_WINDOW,2,12,G_location());
+    Beep();
+    if (fatal)
+	sprintf (buf, "ERROR: %s", msg);
+    else
+	sprintf (buf, "WARNING: %s (click mouse to continue)", msg);
+    Menu_msg (buf);
+
+    if (fatal)
+	quit(1);
+    Mouse_pointer (&x, &y, &button);
+Curses_clear_window (PROMPT_WINDOW);
+
+    return 0;
+}
+


Property changes on: grass-addons/imagery/i.linespoints/main.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/mark.c
===================================================================
--- grass-addons/imagery/i.linespoints/mark.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/mark.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,205 @@
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.h"
+
+static int get_point2 (double *,double *);
+static int keyboard();
+static int _keyboard();
+static int screen (int,int,int);
+static int digitizer();
+static int cancel();
+
+int mark(int x,int y,int button)
+{
+    if (button != 1)
+    return where (x,y);
+
+                if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
+                        mark_point (VIEW_MAP1, x, y);
+                else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
+                        mark_point (VIEW_MAP1_ZOOM, x, y);
+                return 0 ; /* return but don't quit */
+       
+
+}
+
+int mark_point (View *view,int x, int y)
+{
+    double e1,n1;
+    double e2,n2;
+    int row,col;
+
+    char buf[100];
+
+/* convert x,y to east,north at center of cell */
+    col = view_to_col (view, x);
+    e1 = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y);
+    n1 = row_to_northing (&view->cell.head, row, 0.5);
+
+    Curses_clear_window (MENU_WINDOW);
+    sprintf (buf, "Point %d marked on image at", group.points.count+1);
+    Curses_write_window (MENU_WINDOW, 1, 1, buf);
+    sprintf (buf, "East:  %10.2f", e1);
+    Curses_write_window (MENU_WINDOW, 3, 3, buf);
+    sprintf (buf, "North: %10.2f", n1);
+    Curses_write_window (MENU_WINDOW, 4, 3, buf);
+    Curses_clear_window (INFO_WINDOW);
+
+    R_standard_color (ORANGE);
+    save_under_dot (x,y);
+    dot(x,y);
+
+    if (!get_point2(&e2, &n2))
+    {
+	Curses_clear_window (MENU_WINDOW);
+	restore_under_dot();
+    }
+    else
+    {
+	Curses_write_window (MENU_WINDOW, 7, 1, "Point located at");
+	sprintf (buf, "East:  %10.2f", e2);
+	Curses_write_window (MENU_WINDOW, 9, 3, buf);
+	sprintf (buf, "North: %10.2f", n2);
+	Curses_write_window (MENU_WINDOW,10, 3, buf);
+	I_new_control_point (&group.points, e1, n1, e2, n2, 1);
+	put_control_points (group.name, &group.points);
+	Compute_equation();
+	display_points(1);
+    }
+    release_under_dot();
+
+    return 0;
+}
+
+static double N,E;
+
+static int get_point2 (double *east,double *north)
+{
+    int digitizer();
+    int keyboard();
+    int stat;
+    int screen();
+    int cancel();
+    static int use = 1;
+    static Objects objects[] =
+    {
+	MENU ("CANCEL", cancel, &use),
+	INFO ("Mark point on target image", &use),
+	OTHER (screen, &use),
+	{0}
+    };
+
+    if (from_digitizer > 0)
+    {
+	stat = Input_other (digitizer, "Digitizer");
+    }
+    else if (from_screen > 0)
+    {
+	set_colors (&VIEW_MAP2->cell.colors);
+	stat = Input_pointer(objects) > 0;
+	set_colors (&VIEW_MAP1->cell.colors);
+    }
+    else
+	stat = Input_other (keyboard, "Keyboard");
+
+    if(stat)
+    {
+	*east = E;
+	*north = N;
+    }
+
+    return stat ;
+}
+
+static int 
+keyboard (void)
+{
+    int ok;
+    Curses_clear_window (INFO_WINDOW);
+    ok = _keyboard ();
+    Curses_clear_window (INFO_WINDOW);
+    return ok;
+}
+
+static int 
+_keyboard (void)
+{
+    char buf[100];
+
+    while(1)
+    {
+	Curses_prompt_gets ("Enter coordinates as east north: ", buf);
+	G_strip (buf);
+	if (*buf == 0)
+	{
+	    return 0;
+	}
+	if (sscanf (buf, "%lf %lf", &E, &N) != 2)
+	{
+	    Beep();
+	    continue;
+	}
+	Curses_clear_window (INFO_WINDOW);
+	sprintf (buf, "East:   %f\n", E);
+	Curses_write_window (INFO_WINDOW, 2, 2, buf);
+	sprintf (buf, "North:  %f\n", N);
+	Curses_write_window (INFO_WINDOW, 3, 2, buf);
+	Curses_write_window (INFO_WINDOW, 5, 1, "Look ok? (y/n) ");
+
+	while(1)
+	{
+	    int c;
+	    c = Curses_getch(0);
+	    if (c == 'y' || c == 'Y')
+		return 1;
+	    if (c == 'n' || c == 'N')
+		break;
+	    Beep();
+	}
+    }
+
+    return 0;
+}
+
+static int 
+digitizer (void)
+{
+    return digitizer_point (&E, &N);
+}
+
+
+static int screen (int x,int y,int button)
+{
+    int row,col;
+    char buf[50];
+
+    View *view;
+    if (In_view (VIEW_MAP2, x, y) && VIEW_MAP2->cell.configured)
+	view = VIEW_MAP2;
+    else if (In_view (VIEW_MAP2_ZOOM, x, y) && VIEW_MAP2_ZOOM->cell.configured)
+	view = VIEW_MAP2_ZOOM;
+    else
+	return 0; /* ignore mouse event */
+
+    col = view_to_col (view, x);
+    E = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y);
+    N = row_to_northing (&view->cell.head, row, 0.5);
+
+    if (button == 1)
+	return 1;
+
+    sprintf (buf, "East:   %10.2f\n", E);
+    Curses_write_window (INFO_WINDOW, 2, 2, buf);
+    sprintf (buf, "North:  %10.2f\n", N);
+    Curses_write_window (INFO_WINDOW, 3, 2, buf);
+
+    return 0;
+}
+
+static int 
+cancel (void)
+{
+    return -1;
+}


Property changes on: grass-addons/imagery/i.linespoints/mark.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/mouse.c
===================================================================
--- grass-addons/imagery/i.linespoints/mouse.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/mouse.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,59 @@
+#include "globals.h"
+#include "raster.h"
+
+static int first = 1;
+static int curx, cury;
+
+int 
+Mouse_pointer (int *x, int *y, int *button)
+{
+    if (first)
+    {
+	curx = (SCREEN_LEFT + SCREEN_RIGHT)/2;
+	cury = (SCREEN_TOP + SCREEN_BOTTOM)/2;
+	first = 0;
+    }
+    R_get_location_with_pointer (&curx, &cury, button);
+    *x = curx;
+    *y = cury;
+
+#ifdef BUTTON3
+    if (*button == 3) quit(0);
+#endif
+
+    return 0;
+}
+
+int 
+Mouse_box_anchored (int x1, int y1, int *x2, int *y2, int *button)
+{
+    R_get_location_with_box (x1, y1, x2, y2, button);
+    curx = *x2;
+    cury = *y2;
+    first = 0;
+
+#ifdef BUTTON3
+    if (*button == 3) quit(0);
+#endif
+
+    return 0;
+}
+
+int 
+Get_mouse_xy (int *x, int *y)
+{
+    *x = curx;
+    *y = cury;
+
+    return 0;
+}
+
+int 
+Set_mouse_xy (int x, int y)
+{
+    first = 0;
+    curx = x;
+    cury = y;
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/mouse.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/points.c
===================================================================
--- grass-addons/imagery/i.linespoints/points.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/points.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,93 @@
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.h"
+
+int display_line (View *view, double *east, double *north,int *status,int count);
+
+int display_points (int in_color)
+{
+    display_points_in_view (VIEW_MAP1, in_color,
+	    group.points.e1, group.points.n1,
+	    group.points.status, group.points.count);
+
+    display_points_in_view (VIEW_MAP1_ZOOM, in_color,
+	    group.points.e1, group.points.n1,
+	    group.points.status, group.points.count);
+
+    display_points_in_view (VIEW_MAP2, in_color,
+	    group.points.e2, group.points.n2,
+	    group.points.status, group.points.count);
+
+    display_points_in_view (VIEW_MAP2_ZOOM, in_color,
+	    group.points.e2, group.points.n2,
+	    group.points.status, group.points.count);
+
+    return 0;
+}
+
+int display_points_in_view (View *view, int in_color,
+    double *east, double *north, int *status, int count)
+{
+    if (!view->cell.configured) return 1;
+    D_cell_draw_setup(view->top, view->bottom,  view->left, view->right);
+    D_set_clip_window(view->top, view->bottom,  view->left, view->right);
+    while (count-- > 0)
+    {
+                if (in_color && ((*status ==2)||(*status ==-2)))
+                       display_line(view,east,  north, status,count);
+                if (in_color && (*status > 0))
+	    R_standard_color (GREEN);
+	else if (in_color && ((*status == 0)||(*status <= -2)))
+	    R_standard_color (RED);
+	else
+	    R_standard_color (GREY);
+	status++;
+	display_one_point (view, *east++, *north++);
+    }
+
+    return 0;
+}
+
+int display_one_point (View *view, double east, double north)
+{
+    int row, col, x, y;
+
+    row = northing_to_row (&view->cell.head, north) + .5;
+    col = easting_to_col  (&view->cell.head, east) + .5;
+    y = row_to_view (view, row);
+    x = col_to_view (view, col);
+    if (In_view(view, x, y))
+	dot (x,y);
+
+    return 0;
+}
+
+
+int display_line (View *view, double *east, double *north,int *status,int count)
+   {
+      int row, col, x[2], y[2];
+
+      if (count==0) return 1;
+      if ((*(status +1)!=3) && (*(status+1)!=-3)) return 1;
+
+   row = northing_to_row (&view->cell.head, *north) + .5;
+    col = easting_to_col  (&view->cell.head, *east) + .5;
+    y[0] = row_to_view (view, row);
+    x[0] = col_to_view (view, col);
+
+    row = northing_to_row (&view->cell.head, *(north+1)) + .5;
+    col = easting_to_col  (&view->cell.head, *(east+1)) + .5;
+    y[1] = row_to_view (view, row);
+    x[1] = col_to_view (view, col);
+    if (*status == 2 )
+        R_standard_color (GREEN);
+
+    else   R_standard_color (RED);
+    D_move_abs(x[0],y[0]);
+    D_cont_abs(x[1],y[1]);
+    /*  R_polyline_abs (x,y,2); */
+    /*plot_line(*east,*north,*(east+1),*(north+1)); */
+    R_flush();
+      }
+
+


Property changes on: grass-addons/imagery/i.linespoints/points.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/target.c
===================================================================
--- grass-addons/imagery/i.linespoints/target.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/target.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,70 @@
+#include "globals.h"
+#include <unistd.h>
+#include <string.h>
+/* read the target for the group and cast it into the alternate GRASS env */
+
+static int which_env;
+
+int get_target (void)
+{
+    char location[40];
+    char mapset[40];
+    char buf[1024];
+    int stat;
+
+    if (!I_get_target(group.name, location, mapset))
+    {
+	sprintf(buf, "Target information for group [%s] missing\n", group.name);
+	goto error;
+    }
+
+    sprintf (buf, "%s/%s", G_gisdbase(), location);
+    if (access(buf,0) != 0)
+    {
+	sprintf (buf,"Target location [%s] not found\n", location);
+	goto error;
+    }
+    G__create_alt_env();
+    G__setenv ("LOCATION_NAME", location);
+    stat = G__mapset_permissions(mapset);
+    if (stat > 0)
+    {
+	G__setenv ("MAPSET", mapset);
+	G__create_alt_search_path();
+	G__switch_env();
+	G__switch_search_path();
+	which_env = 0;
+	return 1;
+    }
+    sprintf (buf, "Mapset [%s] in target location [%s] - ",
+		mapset, location);
+    strcat (buf, stat == 0 ? "permission denied\n" : "not found\n");
+error:
+    strcat (buf, "Please run i.target for group ");
+    strcat (buf, group.name);
+    G_fatal_error (buf);
+}
+
+int select_current_env (void)
+{
+    if (which_env != 0)
+    {
+	G__switch_env();
+	G__switch_search_path();
+	which_env = 0;
+    }
+
+    return 0;
+}
+
+int select_target_env (void)
+{
+    if (which_env != 1)
+    {
+	G__switch_env();
+	G__switch_search_path();
+	which_env = 1;
+    }
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/target.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/title.c
===================================================================
--- grass-addons/imagery/i.linespoints/title.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/title.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,56 @@
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.h"
+
+int 
+display_title (View *view)
+{
+    View *title;
+    char left[100], center[100];
+    int size;
+    double magnification();
+
+    *left = 0;
+    *center = 0;
+
+    if (view->cell.configured)
+    {
+	sprintf (center, "%s (mag %.1f)",
+	    view->cell.name, magnification (view));
+    }
+
+    if (view == VIEW_MAP1)
+    {
+	sprintf (left, "%s", G_location());
+	title = VIEW_TITLE1;
+    }
+    else if (view == VIEW_MAP1_ZOOM)
+    {
+	title = VIEW_TITLE1_ZOOM;
+    }
+
+    if (view == VIEW_MAP2)
+    {
+	sprintf (left, "%s", G_location());
+	title = VIEW_TITLE2;
+    }
+    else if (view == VIEW_MAP2_ZOOM)
+    {
+	title = VIEW_TITLE2_ZOOM;
+    }
+
+    Erase_view (title);
+    R_standard_color (WHITE);
+    size = title->nrows - 4;
+    R_text_size (size, size);
+    Text (left, title->top, title->bottom, title->left, title->right, 2);
+    if (*center)
+    {
+	R_standard_color (YELLOW);
+	Text (center, title->top, title->bottom,
+		(title->left + title->right - Text_width (center)) / 2,
+		title->right, 2);
+    }
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/title.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/view.c
===================================================================
--- grass-addons/imagery/i.linespoints/view.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/view.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,57 @@
+#include <string.h>
+#include "raster.h"
+#include "globals.h"
+#include "local_proto.h"
+
+int Configure_view (
+    View *view,
+    char *name,
+    char *mapset,
+    double ns_res,
+    double ew_res	/* original map resolution */
+)
+{
+    Erase_view(view);
+    view->cell.configured = 0;
+
+/* copy the cell name into the view */
+    strcpy (view->cell.name, name);
+    strcpy (view->cell.mapset, mapset);
+
+/* determine the map edges */
+    view->cell.left   = view->left + (view->ncols - view->cell.head.cols)/2;
+    view->cell.right  = view->cell.left + view->cell.head.cols - 1;
+    view->cell.top    = view->top  + (view->nrows - view->cell.head.rows)/2;
+    view->cell.bottom = view->cell.top + view->cell.head.rows - 1;
+
+/* remember original resolutions */
+    view->cell.ns_res = ns_res;
+    view->cell.ew_res = ew_res;
+
+    view->cell.configured = 1;
+
+    return 0;
+}
+
+int 
+In_view (View *view, int x, int y)
+{
+    return (x >= view->left && x <= view->right && y >= view->top && y <= view->bottom);
+}
+
+int 
+Erase_view (View *view)
+{
+    R_standard_color (BLACK);
+    R_box_abs (view->left, view->top, view->right, view->bottom);
+
+    return 0;
+}
+
+double 
+magnification (View *view)
+{
+    if (!view->cell.configured)
+	return ((double) 0.0);
+    return (view->cell.ew_res / view->cell.head.ew_res);
+}


Property changes on: grass-addons/imagery/i.linespoints/view.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/where.c
===================================================================
--- grass-addons/imagery/i.linespoints/where.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/where.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,66 @@
+#include "globals.h"
+#include "local_proto.h"
+
+static int where_12 (View *,int,int);
+static int where_21 (View *,int,int);
+static int where_am_i (View *,int,int,Window *,double *,double *,Window *);
+
+int where (int x, int y)
+{
+    if (VIEW_MAP1->cell.configured && In_view (VIEW_MAP1, x, y))
+	where_12 (VIEW_MAP1, x, y);
+    else if (VIEW_MAP1_ZOOM->cell.configured && In_view (VIEW_MAP1_ZOOM, x, y))
+	where_12 (VIEW_MAP1_ZOOM, x, y);
+    else if (VIEW_MAP2->cell.configured && In_view (VIEW_MAP2, x, y))
+	where_21 (VIEW_MAP2, x, y);
+    else if (VIEW_MAP2_ZOOM->cell.configured && In_view (VIEW_MAP2_ZOOM, x, y))
+	where_21 (VIEW_MAP2_ZOOM, x, y);
+    return 0 ; /* return but don't quit */
+}
+
+static int where_12 (View *view,int x, int y)
+{
+    where_am_i (view, x, y, MENU_WINDOW, group.E12, group.N12, INFO_WINDOW);
+
+    return 0;
+}
+
+static int where_21 (View *view,int x, int y)
+{
+    where_am_i (view, x, y, INFO_WINDOW, group.E21, group.N21, MENU_WINDOW);
+
+    return 0;
+}
+
+static int where_am_i (View *view,int x, int y,Window *w1,
+    double *E,double *N,Window *w2)
+{
+    double e1,n1,e2,n2;
+    int row,col;
+
+    char buf[100];
+
+/* convert x,y to east,north at center of cell */
+    col = view_to_col (view, x);
+    e1 = col_to_easting (&view->cell.head, col, 0.5);
+    row = view_to_row (view, y);
+    n1 = row_to_northing (&view->cell.head, row, 0.5);
+
+    Curses_clear_window (w1);
+    sprintf (buf, "East:  %10.2f", e1);
+    Curses_write_window (w1, 3, 3, buf);
+    sprintf (buf, "North: %10.2f", n1);
+    Curses_write_window (w1, 4, 3, buf);
+
+/* if transformation equation is useable, determine point via equation */
+    if (group.equation_stat <= 0) return 1;
+
+    I_georef (e1, n1, &e2, &n2, E, N);
+    Curses_clear_window (w2);
+    sprintf (buf, "East:  %10.2f", e2);
+    Curses_write_window (w2, 3, 3, buf);
+    sprintf (buf, "North: %10.2f", n2);
+    Curses_write_window (w2, 4, 3, buf);
+
+    return 0;
+}


Property changes on: grass-addons/imagery/i.linespoints/where.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/write_line.c
===================================================================
--- grass-addons/imagery/i.linespoints/write_line.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/write_line.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,126 @@
+#include "defs.h"
+#define POINT_FILE "POINTS"
+
+int read_control_points (
+    FILE *fd,
+    struct Control_Points *cp)
+{
+    char buf[100];
+    double e1,e2,n1,n2;
+    int status;
+
+    cp->count = 0;
+
+/* read the control point lines. format is:
+   image_east image_north  target_east target_north  status
+*/
+    cp->e1 = NULL;
+    cp->e2 = NULL;
+    cp->n1 = NULL;
+    cp->n2 = NULL;
+    cp->status = NULL;
+
+    while (G_getl (buf, sizeof buf, fd))
+    {
+	G_strip(buf);
+	if (*buf == '#' || *buf == 0) continue;
+	if (sscanf (buf, "%lf%lf%lf%lf%d", &e1, &n1, &e2, &n2, &status) == 5)
+	    new_control_point (cp, e1, n1, e2, n2, status);
+	else
+	    return -4;
+    }
+
+    return 1;
+}
+
+int new_control_point (struct Control_Points *cp,
+    double e1,double n1,double e2,double n2, int status)
+{
+    int i;
+    unsigned int size;
+
+    if (status ==-1) return 1;
+    i = (cp->count)++ ;
+    size =  cp->count * sizeof(double) ;
+    cp->e1 = (double *) G_realloc (cp->e1, size);
+    cp->e2 = (double *) G_realloc (cp->e2, size);
+    cp->n1 = (double *) G_realloc (cp->n1, size);
+    cp->n2 = (double *) G_realloc (cp->n2, size);
+    size =  cp->count * sizeof(int) ;
+    cp->status = (int *) G_realloc (cp->status, size);
+
+    cp->e1[i] = e1;
+    cp->e2[i] = e2;
+    cp->n1[i] = n1;
+    cp->n2[i] = n2;
+    cp->status[i] = status;
+
+    return 0;
+}
+
+int put_control_points (
+    char *group,
+    struct Control_Points *cp)
+{
+    FILE *fd;
+    char msg[100];
+
+    fd = I_fopen_group_file_new (group, POINT_FILE);
+    if (fd == NULL)
+    {
+	sprintf (msg, "unable to create control point file for group [%s in %s]",
+		group, G_mapset());
+	G_warning (msg);
+	return 0;
+    }
+
+    write_control_points (fd, cp);
+    fclose (fd);
+    return 1;
+}
+
+
+
+ int write_control_points(FILE *fd, struct Control_Points *cp)
+{
+    int i;
+
+    fprintf (fd,"# %7s %15s %15s %15s %9s status\n","","image","","target","");
+    fprintf (fd,"# %15s %15s %15s %15s   (1=ok)\n","east","north","east","north");
+    fprintf (fd,"#\n");
+    for (i = 0; i < cp->count; i++)
+	if (cp->status[i] != -1)
+	    fprintf (fd, "  %15f %15f %15f %15f %4d\n",
+		cp->e1[i], cp->n1[i], cp->e2[i], cp->n2[i], cp->status[i]);
+
+    return 0;
+}
+
+int get_control_points (
+    char *group,
+    struct Control_Points *cp)
+{
+    FILE *fd;
+    char msg[100];
+    int stat;
+
+    fd = I_fopen_group_file_old (group, POINT_FILE);
+    if (fd == NULL)
+    {
+	sprintf (msg, "unable to open control point file for group [%s in %s]",
+		group, G_mapset());
+	G_warning (msg);
+	return 0;
+    }
+
+    stat = read_control_points (fd, cp);
+    fclose (fd);
+    if (stat < 0)
+    {
+	sprintf (msg, "bad format in control point file for group [%s in %s]",
+		group, G_mapset());
+	G_warning (msg);
+	return 0;
+    }
+    return 1;
+}
\ No newline at end of file


Property changes on: grass-addons/imagery/i.linespoints/write_line.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/zoom.c
===================================================================
--- grass-addons/imagery/i.linespoints/zoom.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/zoom.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,53 @@
+#include "globals.h"
+#include "local_proto.h"
+
+static int cancel();
+static int use_zoom_box = 1;
+static int use_zoom_pnt = 0;
+
+
+
+int zoom()
+{
+    static int use = 1;
+    int cancel();
+    static int which_zoom();
+
+   static Objects objects[]=
+    {
+      MENU("CANCEL",cancel,&use),
+      INFO("Current ZOOM Type.",&use),
+      OPTION("BOX",   2, &use_zoom_box),
+      OPTION("POINT", 2, &use_zoom_pnt),
+      OTHER(which_zoom, &use),
+      {0}
+ };
+
+  Input_pointer (objects);
+  return 0;	/* return, but don't QUIT */
+}
+
+static int
+which_zoom(int x,int y,int button)
+{
+
+  /* Button one to set point, Button 2 & 3 return location */
+  if (button != 1)
+    return where (x,y);
+
+
+  if (use_zoom_box == 1)
+     zoom_box(x,y);
+  else zoom_pnt(x,y);
+
+  return 0;
+}
+
+
+
+
+static int 
+cancel (void)
+{
+    return -1;
+}


Property changes on: grass-addons/imagery/i.linespoints/zoom.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/zoom_box.c
===================================================================
--- grass-addons/imagery/i.linespoints/zoom_box.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/zoom_box.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,178 @@
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.h"
+
+
+static int zoom2(int,int);
+static int cancel(void);
+
+static int x1, y1, x2, y2;
+static View *pick_view, *zoom_view, *main_view;
+static int target_flag;
+
+
+
+int zoom_box (int x,int y)	/* called by Input_pointer */
+{
+    static int use = 1;
+    int zoom2();
+	int cancel();
+
+    static Objects objects[] =
+    {
+	MENU("CANCEL",cancel,&use),
+	INFO(" Define the region ",&use),
+	OTHER(zoom2,&use),
+	{0}
+    };
+
+/* 
+ * user has marked first corner 
+ * this determines which view is being zoomed
+ */
+    x1 = x;
+    y1 = y;
+
+    if (In_view (pick_view = VIEW_MAP1, x1, y1))
+    {
+	main_view = VIEW_MAP1;
+	zoom_view = VIEW_MAP1_ZOOM;
+	target_flag = 0;
+    }
+    else if (In_view (pick_view = VIEW_MAP2, x1, y1))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP2;
+	zoom_view = VIEW_MAP2_ZOOM;
+	target_flag = 1;
+    }
+    else if (In_view (pick_view = VIEW_MAP1_ZOOM, x1, y1))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP1;
+	zoom_view = VIEW_MAP1_ZOOM;
+	target_flag = 0;
+    }
+    else if (In_view (pick_view = VIEW_MAP2_ZOOM, x1, y1))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP2;
+	zoom_view = VIEW_MAP2_ZOOM;
+	target_flag = 1;
+    }
+    else
+	return 0;	/* ignore the mouse event */
+    if (!pick_view->cell.configured) return 0;	/* just to be sure */
+
+    return Input_box (objects, x, y);
+}
+
+static int zoom2(int x,int y)
+{
+    int top, bottom, left, right;
+    int row,col;
+    struct Cell_head cellhd;
+
+    x2 = x;
+    y2 = y;
+/* 
+ * user has completed the zoom window.
+ * must be in same view as first corner
+ */
+    if (x1 == x2 || y1 == y2) return 0;	/* ignore event */
+    if (!In_view (pick_view,x2,y2)) return 0;
+/*
+ * ok, erase menu messages
+ */
+    Menu_msg("");
+
+/*
+ * assign window coordinates to top,bottom,left,right
+ */
+    if (x1 < x2)
+    {
+	left = x1;
+	right = x2;
+    }
+    else
+    {
+	left = x2;
+	right = x1;
+    }
+    if (y1 < y2)
+    {
+	top = y1;
+	bottom = y2;
+    }
+    else
+    {
+	top = y2;
+	bottom = y1;
+    }
+
+/* 
+ * Determine the the zoom window (ie, cellhd)
+ * must copy the current view cellhd first, to preserve header info
+ * (such as projection, zone, and other items.)
+ * compute zoom window northings,eastings, rows, cols, and resolution
+ */
+
+    G_copy (&cellhd, &pick_view->cell.head, sizeof(cellhd));
+
+/* convert top to northing at top edge of cell
+ * left to easting at left edge
+ */
+    col = view_to_col(pick_view,left);
+    row = view_to_row(pick_view,top);
+    cellhd.north = row_to_northing (&pick_view->cell.head,row,0.0);
+    cellhd.west  = col_to_easting  (&pick_view->cell.head,col,0.0);
+
+/* convert bottom to northing at bottom edge of cell
+ * right to easting at right edge
+ */
+    col = view_to_col(pick_view,right);
+    row = view_to_row(pick_view,bottom);
+    cellhd.south = row_to_northing (&pick_view->cell.head,row,1.0);
+    cellhd.east  = col_to_easting  (&pick_view->cell.head,col,1.0);
+
+
+    cellhd.rows = bottom-top+1;
+    cellhd.cols = right-left+1;
+    cellhd.ns_res = (cellhd.north-cellhd.south)/cellhd.rows;
+    cellhd.ew_res = (cellhd.east-cellhd.west)/cellhd.cols;
+
+/*
+ * Outline the zoom window on the main map
+ * Turn previous one to grey.
+ */
+    if (zoom_view->cell.configured)
+    {
+	R_standard_color (GREY);
+	Outline_cellhd (main_view, &zoom_view->cell.head);
+    }
+    R_standard_color (RED);
+    Outline_cellhd (main_view, &cellhd);
+
+
+/*
+ * zoom
+ */
+    if (target_flag)
+	select_target_env();
+    G_adjust_window_to_box (&cellhd, &zoom_view->cell.head, zoom_view->nrows, zoom_view->ncols);
+    Configure_view (zoom_view, pick_view->cell.name, pick_view->cell.mapset,
+	pick_view->cell.ns_res, pick_view->cell.ew_res);
+    drawcell (zoom_view);
+    select_current_env();
+    display_points(1);
+    return 1;	/* pop back */
+}
+
+static int 
+cancel (void)
+{
+    return -1;
+}


Property changes on: grass-addons/imagery/i.linespoints/zoom_box.c
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/imagery/i.linespoints/zoom_pnt.c
===================================================================
--- grass-addons/imagery/i.linespoints/zoom_pnt.c	                        (rev 0)
+++ grass-addons/imagery/i.linespoints/zoom_pnt.c	2010-03-11 20:15:13 UTC (rev 41382)
@@ -0,0 +1,180 @@
+#include "globals.h"
+#include "local_proto.h"
+#include "raster.h"
+
+
+static int cancel(void);
+
+static View *pick_view, *zoom_view, *main_view;
+static int target_flag;
+double ceil();
+double floor();
+
+
+int zoom_pnt (int x,int y)	/* called by Input_pointer */
+{
+    int top, bottom, left, right;
+    int n,row,col;
+    int nrows, ncols;
+    struct Cell_head cellhd;
+    int mag;
+    double magnification();
+    double north, south, east, west;
+
+    if (In_view (pick_view = VIEW_MAP1, x, y))
+    {
+	main_view = VIEW_MAP1;
+	zoom_view = VIEW_MAP1_ZOOM;
+	target_flag = 0;
+    }
+    else if (In_view (pick_view = VIEW_MAP2, x, y))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP2;
+	zoom_view = VIEW_MAP2_ZOOM;
+	target_flag = 1;
+    }
+    else if (In_view (pick_view = VIEW_MAP1_ZOOM, x, y))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP1;
+	zoom_view = VIEW_MAP1_ZOOM;
+	target_flag = 0;
+    }
+    else if (In_view (pick_view = VIEW_MAP2_ZOOM, x, y))
+    {
+	if (!pick_view->cell.configured)
+	    return 0;	/* ignore the mouse event */
+	main_view = VIEW_MAP2;
+	zoom_view = VIEW_MAP2_ZOOM;
+	target_flag = 1;
+    }
+    else
+	return 0;	/* ignore the mouse event */
+    if (!pick_view->cell.configured) return 0;	/* just to be sure */
+/*
+ * make sure point is within edges of image as well
+ */
+    if (x <= pick_view->cell.left) return 0;
+    if (x >= pick_view->cell.right) return 0;
+    if (y <= pick_view->cell.top) return 0;
+    if (y >= pick_view->cell.bottom) return 0;
+
+
+/*
+ * ok, erase menu messages
+ */
+    Menu_msg("");
+
+/* determine magnification of zoom */
+    if (zoom_view->cell.configured)
+    {
+	if (zoom_view == pick_view)
+	    mag = floor(magnification (zoom_view) + 1.0) + .1;
+	else
+	    mag = ceil(magnification (zoom_view)) + .1;
+    }
+    else
+    {
+	mag = floor(magnification (main_view) + 1.0) + .1;
+    }
+    if(!ask_magnification (&mag))
+	return 1;
+/* 
+ * Determine the the zoom window (ie, cellhd)
+ */
+
+    G_copy (&cellhd, &main_view->cell.head, sizeof(cellhd));
+    cellhd.ns_res = main_view->cell.ns_res / mag;
+    cellhd.ew_res = main_view->cell.ew_res / mag;
+    cellhd.cols   = (cellhd.east - cellhd.west) / cellhd.ew_res;
+    cellhd.rows   = (cellhd.north - cellhd.south) / cellhd.ns_res;
+
+
+/* convert x,y to col,row */
+
+    col  = view_to_col(pick_view,x);
+    east = col_to_easting (&pick_view->cell.head, col, 0.5);
+    col  = easting_to_col (&cellhd, east);
+
+    row   = view_to_row(pick_view,y);
+    north = row_to_northing (&pick_view->cell.head, row, 0.5);
+    row   = northing_to_row (&cellhd, north);
+
+    ncols = zoom_view->ncols ;
+    nrows = zoom_view->nrows ;
+
+
+    n = cellhd.cols - col;
+    if (n > col)
+	n = col;
+    if (n+n+1 >= ncols)
+    {
+	n = ncols/2;
+	if (n+n+1 >= ncols) n--;
+    }
+    left = col - n;
+    right = col + n;
+
+    n = cellhd.rows - row;
+    if (n > row)
+	n = row;
+    if (n+n+1 >= nrows)
+    {
+	n = nrows/2;
+	if (n+n+1 >= nrows) n--;
+    }
+    top = row - n;
+    bottom = row + n;
+
+
+    north = row_to_northing (&cellhd, top,0.0);
+    west  = col_to_easting  (&cellhd,left,0.0);
+    south = row_to_northing (&cellhd,bottom,1.0);
+    east  = col_to_easting  (&cellhd,right,1.0);
+
+
+    cellhd.north = north;
+    cellhd.south = south;
+    cellhd.east  = east ;
+    cellhd.west  = west ;
+
+    cellhd.rows = (cellhd.north-cellhd.south)/cellhd.ns_res;
+    cellhd.cols = (cellhd.east-cellhd.west)/cellhd.ew_res ;
+
+/*
+ * Outline the zoom window on the main map
+ * Turn previous one to grey.
+ */
+    if (zoom_view->cell.configured)
+    {
+	R_standard_color (GREY);
+	Outline_cellhd (main_view, &zoom_view->cell.head);
+    }
+    R_standard_color (RED);
+    Outline_cellhd (main_view, &cellhd);
+
+
+/*
+ * zoom
+ */
+    if (target_flag)
+	select_target_env();
+    G_copy (&zoom_view->cell.head, &cellhd, sizeof (cellhd));
+    Configure_view (zoom_view, pick_view->cell.name, pick_view->cell.mapset,
+	pick_view->cell.ns_res, pick_view->cell.ew_res);
+    drawcell (zoom_view);
+    select_current_env();
+    display_points(1);
+
+    return 1;	/* pop back */
+}
+
+
+static int 
+cancel (void)
+{
+    return -1;
+}


Property changes on: grass-addons/imagery/i.linespoints/zoom_pnt.c
___________________________________________________________________
Added: svn:eol-style
   + native



More information about the grass-commit mailing list