Bläddra i källkod

v.digit removed (replaced by wxGUI vector digitizer (gui/wxpython/vdigit)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35191 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 år sedan
förälder
incheckning
ba6d9a47c2

+ 0 - 1
vector/Makefile

@@ -77,7 +77,6 @@ SUBDIRS = \
 	v.out.ogr \
 	v.in.ogr \
 	v.external \
-	v.digit \
 	v.in.dwg
 
 include $(MODULE_TOPDIR)/include/Make/Dir.make

+ 0 - 28
vector/v.digit/Makefile

@@ -1,28 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = v.digit
-
-LIBES = $(DISPLAYLIB) $(RASTERLIB) $(VECTLIB) $(GISLIB) $(TCLTKLIBPATH) $(TCLTKLIBS)
-DEPENDENCIES= $(DISPLAYDEP) $(RASTERDEP) $(VECTDEP) $(GISDEP)
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-EXTRA_CFLAGS = $(XCFLAGS) $(TCLINCDIR) $(TKINCDIR) $(VECT_CFLAGS)
-EXTRA_INC = $(VECT_INC)
-
-AUXDIR := $(ARCH_DISTDIR)/etc/v.digit
-TCLFILES := $(patsubst %,$(AUXDIR)/%,$(wildcard *.tcl))
-
-ifneq ($(strip $(TCLTKLIBS)),)
-pre: $(AUXDIR)
-
-default: cmd $(TCLFILES)
-endif
-
-$(AUXDIR):
-	if [ ! -d $(ETC) ]; then $(MKDIR) $(ETC); fi
-	if [ ! -d $(AUXDIR) ]; then $(MKDIR) $@; fi
-
-$(AUXDIR)/%.tcl: %.tcl
-	$(INSTALL_DATA) $< $@
-

+ 0 - 685
vector/v.digit/attr.c

@@ -1,685 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <math.h>
-#include <tcl.h>
-#include <tk.h>
-#include <grass/gis.h>
-#include <grass/Vect.h>
-#include <grass/dbmi.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include <grass/colors.h>
-#include <grass/form.h>
-#include "global.h"
-#include "proto.h"
-
-static int last_cat_line;
-
-int del_cat(int line, int field, int cat)
-{
-    int type, i;
-    static struct line_pnts *Points = NULL;
-    static struct line_cats *Cats = NULL;
-    char buf[1000];
-
-    G_debug(3, "del_cat() line = %d, field = %d, cat = %d", line, field, cat);
-
-    if (Points == NULL)
-	Points = Vect_new_line_struct();
-    if (Cats == NULL)
-	Cats = Vect_new_cats_struct();
-
-    type = Vect_read_line(&Map, Points, Cats, line);
-    Vect_field_cat_del(Cats, field, cat);
-
-    last_cat_line = Vect_rewrite_line(&Map, line, type, Points, Cats);
-
-    check_record(field, cat);
-
-    Tcl_Eval(Toolbox, "clear_cats");
-
-    for (i = 0; i < Cats->n_cats; i++) {
-	sprintf(buf, "add_cat %d %d %d", last_cat_line, Cats->field[i],
-		Cats->cat[i]);
-	Tcl_Eval(Toolbox, buf);
-    }
-
-    symb_updated_lines_set_from_map();
-    symb_updated_nodes_set_from_map();
-    G_debug(2, "  last_cat_line = %d", last_cat_line);
-
-    return 0;
-}
-
-int add_cat(int field, int cat, int newrec)
-{
-    int type, i, ret;
-    static struct line_pnts *Points = NULL;
-    static struct line_cats *Cats = NULL;
-    char buf[1000];
-
-    G_debug(2,
-	    "add_cat() last_cat_line = %d, field = %d, cat = %d, newrec = %d",
-	    last_cat_line, field, cat, newrec);
-
-    if (Points == NULL)
-	Points = Vect_new_line_struct();
-    if (Cats == NULL)
-	Cats = Vect_new_cats_struct();
-
-    type = Vect_read_line(&Map, Points, Cats, last_cat_line);
-    Vect_cat_set(Cats, field, cat);
-
-    last_cat_line =
-	Vect_rewrite_line(&Map, last_cat_line, type, Points, Cats);
-
-    Tcl_Eval(Toolbox, "clear_cats");
-
-    for (i = 0; i < Cats->n_cats; i++) {
-	sprintf(buf, "add_cat %d %d %d", last_cat_line, Cats->field[i],
-		Cats->cat[i]);
-	Tcl_Eval(Toolbox, buf);
-    }
-
-    if (newrec) {
-	ret = new_record(field, cat);
-	if (ret == 0) {
-	    G_debug(2, "New record created.");
-	}
-	else if (ret == 1) {
-	    G_debug(2, "Record already existed.");
-	}
-	else if (ret == -1) {
-	    G_warning("Cannot create new record.");
-	}
-    }
-
-    symb_updated_lines_set_from_map();
-    symb_updated_nodes_set_from_map();
-    G_debug(2, "  last_cat_line = %d", last_cat_line);
-
-    return 0;
-}
-
-/* 
- * Create new record in table 
- * returns: 0 created
- *          1 existed
- *         -1 error  
- */
-int new_record(int field, int cat)
-{
-    int ret, old;
-    struct field_info *Fi;
-    dbDriver *driver;
-    dbValue value;
-    dbString sql;
-    char buf[1000];
-
-    db_init_string(&sql);
-
-    G_debug(2, "new_record() field = %d cat = %d", field, cat);
-
-    Fi = Vect_get_field(&Map, field);
-    if (Fi == NULL) {
-	i_message(MSG_OK, MSGI_ERROR,
-		  "Database table for this layer is not defined");
-	return -1;
-    }
-
-    /* Note: some drivers (dbf) writes date when db is closed so it is better open
-     * and close database for each record, so that data may not be lost later */
-
-    /* First check if already exists */
-    driver = db_start_driver_open_database(Fi->driver, Fi->database);
-    if (driver == NULL) {
-	sprintf(buf, "Cannot open database %s by driver %s", Fi->database,
-		Fi->driver);
-	i_message(MSG_OK, MSGI_ERROR, buf);
-	return -1;
-    }
-    ret = db_select_value(driver, Fi->table, Fi->key, cat, Fi->key, &value);
-    if (ret == -1) {
-	db_close_database_shutdown_driver(driver);
-	sprintf(buf, "Cannot select record from table %s", Fi->table);
-	i_message(MSG_OK, MSGI_ERROR, buf);
-	return -1;
-    }
-    if (ret == 0) {		/* insert new record */
-	sprintf(buf, "insert into %s (%s) values (%d)", Fi->table, Fi->key,
-		cat);
-	db_set_string(&sql, buf);
-	G_debug(2, db_get_string(&sql));
-	ret = db_execute_immediate(driver, &sql);
-	if (ret != DB_OK) {
-	    db_close_database_shutdown_driver(driver);
-	    sprintf(buf, "Cannot insert new record: %s", db_get_string(&sql));
-	    i_message(MSG_OK, MSGI_ERROR, buf);
-	    return -1;
-	}
-	old = 0;
-    }
-    else {			/* record already existed */
-	old = 1;
-    }
-
-    db_close_database_shutdown_driver(driver);
-
-    return old;
-}
-
-
-/* Display categories */
-
-struct display_cats
-{
-    double thresh;
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-};
-
-int display_cats_begin(void *closure)
-{
-    struct display_cats *dc = closure;
-
-    G_debug(2, "display_cats()");
-
-    dc->Points = Vect_new_line_struct();
-    dc->Cats = Vect_new_cats_struct();
-
-    i_prompt("Display categories:");
-    i_prompt_buttons("Select line", "", "Quit tool");
-
-    dc->thresh = get_thresh();
-    G_debug(2, "thresh = %f", dc->thresh);
-
-    F_clear();
-    last_cat_line = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int display_cats_update(void *closure, int sxn, int syn, int button)
-{
-    struct display_cats *dc = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(2, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    /* Display last highlighted in normal color */
-    G_debug(2, "  last_cat_line = %d", last_cat_line);
-    if (last_cat_line > 0)
-	display_line(last_cat_line, SYMB_DEFAULT, 1);
-
-    if (button == 3)		/* Quit tool */
-	return 1;
-
-    if (button == 1) {		/* Confirm / select */
-	int j, line;
-
-	F_clear();
-	/* Find nearest point or line (points first!) */
-	line = Vect_find_line(&Map, x, y, 0, GV_POINTS, dc->thresh, 0, 0);
-	G_debug(2, "point found = %d", line);
-	if (line == 0)
-	    line =
-		Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY,
-			       dc->thresh, 0, 0);
-	G_debug(2, "line found = %d", line);
-
-	/* Display new selected line if any */
-	if (line > 0) {
-	    int type;
-
-	    display_line(line, SYMB_HIGHLIGHT, 1);
-	    type = Vect_read_line(&Map, dc->Points, dc->Cats, line);
-
-	    Tcl_Eval(Toolbox, "mk_cats");	/* mk_cats checks if already opened */
-	    Tcl_Eval(Toolbox, "clear_cats");
-
-	    for (j = 0; j < dc->Cats->n_cats; j++) {
-		char buf[1000];
-
-		G_debug(3, "field = %d category = %d", dc->Cats->field[j],
-			dc->Cats->cat[j]);
-
-		sprintf(buf, "add_cat %d %d %d", line, dc->Cats->field[j],
-			dc->Cats->cat[j]);
-		Tcl_Eval(Toolbox, buf);
-
-	    }
-	}
-
-	last_cat_line = line;
-    }
-
-    return 0;
-}
-
-int display_cats_end(void *closure)
-{
-    Tcl_Eval(Toolbox, "destroy_cats");
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "display_cats(): End");
-    return 1;
-}
-
-void display_cats(void)
-{
-    static struct display_cats dc;
-
-    set_tool(display_cats_begin, display_cats_update, display_cats_end, &dc);
-}
-
-/* Copy categories from one feature to another */
-struct copy_cats
-{
-    int src_line, dest_line;
-    double thresh;
-    struct line_pnts *Points;
-    struct line_cats *Src_Cats, *Dest_Cats;
-};
-
-int copy_cats_begin(void *closure)
-{
-    struct copy_cats *cc = closure;
-
-    G_debug(2, "copy_cats()");
-
-    cc->Points = Vect_new_line_struct();
-    cc->Src_Cats = Vect_new_cats_struct();
-    cc->Dest_Cats = Vect_new_cats_struct();
-
-    i_prompt("Copy attributes:");
-    i_prompt_buttons("Select source object", "", "Quit tool");
-
-    cc->thresh = get_thresh();
-    G_debug(2, "thresh = %f", cc->thresh);
-
-    cc->src_line = 0;
-    cc->dest_line = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int copy_cats_update(void *closure, int sxn, int syn, int button)
-{
-    struct copy_cats *cc = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    if (button == 3)		/* Quit tool */
-	return 1;
-
-    if (cc->src_line > 0)
-	display_line(cc->src_line, SYMB_DEFAULT, 1);
-    if (cc->dest_line > 0)
-	display_line(cc->dest_line, SYMB_DEFAULT, 1);
-    if (button == 1) {
-	int line =
-	    Vect_find_line(&Map, x, y, 0, GV_LINES | GV_POINTS, cc->thresh, 0,
-			   0);
-	G_debug(3, "before: src_line=%d dest_line=%d line=%d", cc->src_line,
-		cc->dest_line, line);
-	if (cc->dest_line > 0) {
-	    int new_line, type, i;
-
-	    /* We have a source- and a destination-object
-	     * => copy categories */
-	    type =
-		Vect_read_line(&Map, cc->Points, cc->Dest_Cats,
-			       cc->dest_line);
-	    new_line =
-		Vect_rewrite_line(&Map, cc->dest_line, type, cc->Points,
-				  cc->Src_Cats);
-	    if (line == cc->dest_line)
-		line = new_line;
-	    cc->dest_line = new_line;
-
-	    for (i = 0; i < cc->Dest_Cats->n_cats; i++) {
-		check_record(cc->Dest_Cats->field[i], cc->Dest_Cats->cat[i]);
-	    }
-
-	    updated_lines_and_nodes_erase_refresh_display();
-
-	    /* move the selections on */
-	    cc->src_line = cc->dest_line;
-	    cc->dest_line = line;
-	}
-	else if (cc->src_line > 0) {
-	    /* We have a source-object and possibly a destination object
-	     * was selected */
-	    if (line <= 0)
-		cc->src_line = 0;
-	    else if (line != cc->src_line)
-		cc->dest_line = line;
-	}
-	else {
-	    /* We have no object selected and possible a source-object
-	     * was selected => read its categories into Src_Cats */
-	    cc->src_line = line;
-	    if (cc->src_line > 0)
-		Vect_read_line(&Map, cc->Points, cc->Src_Cats, cc->src_line);
-	}
-	G_debug(3, "after: src_line=%d dest_line=%d line=%d", cc->src_line,
-		cc->dest_line, line);
-    }
-    else if (button == 2) {
-	/* We need to deselect the last line selected */
-	if (cc->dest_line > 0) {
-	    display_line(cc->dest_line, SYMB_DEFAULT, 1);
-	    cc->dest_line = 0;
-	}
-	else if (cc->src_line > 0) {
-	    display_line(cc->src_line, SYMB_DEFAULT, 1);
-	    cc->src_line = 0;
-	}
-    }
-
-    /* Display the selected lines accordingly and set the button prompts */
-    if (cc->dest_line > 0) {
-	display_line(cc->dest_line, SYMB_HIGHLIGHT, 1);
-	display_line(cc->src_line, SYMB_HIGHLIGHT, 1);
-	i_prompt("Select the target object");
-	i_prompt_buttons("Conform and select next", "Deselect Target",
-			 "Quit tool");
-    }
-    else if (cc->src_line > 0) {
-	display_line(cc->src_line, SYMB_HIGHLIGHT, 1);
-	i_prompt("Select the target object");
-	i_prompt_buttons("Select", "Deselect Source", "Quit tool");
-    }
-    else {
-	i_prompt("Copy attributes:");
-	i_prompt_buttons("Select source object", "", "Quit tool");
-    }
-
-    return 0;
-}
-
-int copy_cats_end(void *closure)
-{
-    struct copy_cats *cc = closure;
-
-    if (cc->dest_line > 0)
-	display_line(cc->dest_line, SYMB_DEFAULT, 1);
-    if (cc->src_line > 0)
-	display_line(cc->src_line, SYMB_DEFAULT, 1);
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    Vect_destroy_line_struct(cc->Points);
-    Vect_destroy_cats_struct(cc->Src_Cats);
-    Vect_destroy_cats_struct(cc->Dest_Cats);
-
-    G_debug(3, "copy_cats(): End");
-
-    return 1;
-}
-
-void copy_cats(void)
-{
-    static struct copy_cats cc;
-
-    set_tool(copy_cats_begin, copy_cats_update, copy_cats_end, &cc);
-}
-
-/* Display attributes */
-
-struct display_attributes
-{
-    double thresh;
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int last_line;
-    dbString html;
-};
-
-int display_attributes_begin(void *closure)
-{
-    struct display_attributes *da = closure;
-
-    G_debug(2, "display_attributes()");
-
-    da->Points = Vect_new_line_struct();
-    da->Cats = Vect_new_cats_struct();
-
-    i_prompt("Display attributes:");
-    i_prompt_buttons("Select line", "", "Quit tool");
-
-    da->thresh = get_thresh();
-    G_debug(2, "thresh = %f", da->thresh);
-
-    F_clear();
-    da->last_line = 0;
-
-    db_init_string(&da->html);
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int display_attributes_update(void *closure, int sxn, int syn, int button)
-{
-    static int first_form = 1;
-    struct display_attributes *da = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    /* Display last highlighted in normal color */
-    if (da->last_line > 0) {
-	display_line(da->last_line, SYMB_DEFAULT, 1);
-    }
-
-    if (button == 3)		/* Quit tool */
-	return 1;
-
-    if (button == 1) {		/* Confirm / select */
-	int line;
-
-	F_clear();
-	/* Find nearest point or line (points first!) */
-	line = Vect_find_line(&Map, x, y, 0, GV_POINTS, da->thresh, 0, 0);
-	G_debug(2, "point found = %d", line);
-	if (line == 0)
-	    line =
-		Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY,
-			       da->thresh, 0, 0);
-	G_debug(2, "line found = %d", line);
-
-	/* Display new selected line if any */
-	if (line > 0) {
-	    char buf[1000], title[500];
-	    int type;
-
-	    display_line(line, SYMB_HIGHLIGHT, 1);
-	    type = Vect_read_line(&Map, da->Points, da->Cats, line);
-
-	    /* Note: F_open() must be run first time with closed monitor, otherwise next
-	     *         *        attempt to open driver hangs until form child process is killed */
-	    if (first_form) {
-		driver_close();
-		F_open("", "");
-		F_clear();
-		driver_open();
-		first_form = 0;
-	    }
-
-	    if (da->Cats->n_cats > 0) {
-		int j;
-
-		for (j = 0; j < da->Cats->n_cats; j++) {
-		    struct field_info *Fi;
-		    char *form;
-
-		    G_debug(3, "field = %d category = %d", da->Cats->field[j],
-			    da->Cats->cat[j]);
-
-		    sprintf(title, "Layer %d", da->Cats->field[j]);
-		    db_set_string(&da->html, "");
-		    db_append_string(&da->html,
-				     "<HTML><HEAD><TITLE>Attributes</TITLE><BODY>");
-
-		    sprintf(buf, "layer: %d<BR>category: %d<BR>",
-			    da->Cats->field[j], da->Cats->cat[j]);
-		    db_append_string(&da->html, buf);
-
-		    Fi = Vect_get_field(&Map, da->Cats->field[j]);
-		    if (Fi == NULL) {
-			db_append_string(&da->html,
-					 "Database connection not defined<BR>");
-		    }
-		    else {
-			sprintf(buf,
-				"driver: %s<BR>database: %s<BR>table: %s<BR>key column: %s<BR>",
-				Fi->driver, Fi->database, Fi->table, Fi->key);
-			db_append_string(&da->html, buf);
-
-			F_generate(Fi->driver, Fi->database, Fi->table,
-				   Fi->key, da->Cats->cat[j], NULL, NULL,
-				   F_EDIT, F_HTML, &form);
-
-			db_append_string(&da->html, form);
-			G_free(form);
-			G_free(Fi);
-		    }
-		    db_append_string(&da->html, "</BODY></HTML>");
-		    G_debug(3, db_get_string(&da->html));
-		    F_open(title, db_get_string(&da->html));
-		}
-	    }
-	    else {
-		sprintf(title, "Line %d", line);
-		db_init_string(&da->html);
-		db_set_string(&da->html, "");
-		db_append_string(&da->html,
-				 "<HTML><HEAD><TITLE>Attributes</TITLE><BODY>");
-		db_append_string(&da->html, "No categories");
-		db_append_string(&da->html, "</BODY></HTML>");
-		G_debug(3, db_get_string(&da->html));
-		F_open(title, db_get_string(&da->html));
-	    }
-	}
-	da->last_line = line;
-    }
-
-    return 0;
-}
-
-int display_attributes_end(void *closure)
-{
-    F_clear();
-    F_close();
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "display_attributes(): End");
-
-    return 1;
-}
-
-void display_attributes(void)
-{
-    static struct display_attributes da;
-
-    set_tool(display_attributes_begin, display_attributes_update,
-	     display_attributes_end, &da);
-}
-
-/* 
- * Check if deleted category exists in category index, ask user if not and delete it if requested
- * 
- * returns: 
- */
-int check_record(int field, int cat)
-{
-    int ret, field_index, type, id;
-    struct field_info *Fi;
-    dbDriver *driver;
-    dbValue value;
-    dbString sql;
-    char buf[1000];
-
-    db_init_string(&sql);
-
-    G_debug(3, "check_record() field = %d cat = %d", field, cat);
-
-    Fi = Vect_get_field(&Map, field);
-    if (Fi == NULL) {		/* no table */
-	return 0;
-    }
-
-    /* Are there still elemets with this category */
-    field_index = Vect_cidx_get_field_index(&Map, field);
-    G_debug(3, "field_index = %d", field_index);
-    if (field_index >= 0) {
-	ret =
-	    Vect_cidx_find_next(&Map, field_index, cat, GV_POINTS | GV_LINES,
-				0, &type, &id);
-	G_debug(3, "ret = %d", ret);
-
-	if (ret >= 0)
-	    return 0;		/* Category exists in map */
-    }
-
-    /* Does record exist ? */
-    driver = db_start_driver_open_database(Fi->driver, Fi->database);
-    if (driver == NULL) {
-	sprintf(buf, "Cannot open database %s by driver %s", Fi->database,
-		Fi->driver);
-	i_message(MSG_OK, MSGI_ERROR, buf);
-	return -1;
-    }
-    ret = db_select_value(driver, Fi->table, Fi->key, cat, Fi->key, &value);
-    G_debug(3, "n records = %d", ret);
-    if (ret == -1) {
-	db_close_database_shutdown_driver(driver);
-	sprintf(buf, "Cannot select record from table %s", Fi->table);
-	i_message(MSG_OK, MSGI_ERROR, buf);
-	return -1;
-    }
-
-    if (ret == 0)
-	return 0;
-
-    sprintf(buf,
-	    "There are no more features with category %d (layer %d) in the map, but there is "
-	    "record in the table. Delete this record?", cat, field);
-    ret = i_message(MSG_YESNO, MSGI_QUESTION, buf);
-
-    if (ret == 1)
-	return 0;		/* No, do not delete */
-
-    sprintf(buf, "delete from %s where %s = %d", Fi->table, Fi->key, cat);
-    db_set_string(&sql, buf);
-    G_debug(2, db_get_string(&sql));
-    ret = db_execute_immediate(driver, &sql);
-    if (ret != DB_OK) {
-	db_close_database_shutdown_driver(driver);
-	sprintf(buf, "Cannot delete record: %s", db_get_string(&sql));
-	i_message(MSG_OK, MSGI_ERROR, buf);
-	return -1;
-    }
-
-    db_close_database_shutdown_driver(driver);
-
-    return 0;
-}

+ 0 - 36
vector/v.digit/background.c

@@ -1,36 +0,0 @@
-/* ***************************************************************
- * *
- * * MODULE:       v.digit
- * * 
- * * AUTHOR(S):    Radim Blazek
- * *               
- * * PURPOSE:      Edit vector
- * *              
- * * COPYRIGHT:    (C) 2001 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.
- * *
- * **************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <grass/gis.h>
-#include "global.h"
-#include "proto.h"
-
-/* Add new command to background commands */
-int bg_add(char *cmd)
-{
-    G_debug(2, "bg_add(): cmd = %s", cmd);
-    if (nbgcmd == abgcmd) {
-	abgcmd += 10;
-	Bgcmd = (BGCMD *) G_realloc(Bgcmd, abgcmd * sizeof(BGCMD));
-    }
-    Bgcmd[nbgcmd].cmd = G_store(cmd);
-    Bgcmd[nbgcmd].on = 1;
-    nbgcmd++;
-
-    return nbgcmd;
-}

+ 0 - 465
vector/v.digit/c_face.c

@@ -1,465 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <tcl.h>
-#include <tk.h>
-#include <grass/gis.h>
-#include <grass/Vect.h>
-#include <grass/dbmi.h>
-#include <grass/raster.h>
-#include "global.h"
-#include "proto.h"
-
-/* Interface functions between GUI and C:
- *  c_*() functions in C, called from GUI, in this case from Tk
- */
-
-/* Request to cancel running tool */
-int c_cancel(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    G_debug(3, "c_cancel()");
-    cancel_tool();
-    Tool_next = TOOL_NOTHING;
-    return TCL_OK;
-}
-
-/* set the next tool to start */
-int c_next_tool(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    char *tl;
-
-    G_debug(3, "c_next_tool()");
-    if (argc < 2) {
-	G_warning("c_next_tool(): inicorrect number of parameters");
-	return TCL_ERROR;
-    }
-    tl = argv[1];
-
-    if (strcmp(tl, "new_point") == 0)
-	Tool_next = TOOL_NEW_POINT;
-    else if (strcmp(tl, "new_line") == 0)
-	Tool_next = TOOL_NEW_LINE;
-    else if (strcmp(tl, "new_boundary") == 0)
-	Tool_next = TOOL_NEW_BOUNDARY;
-    else if (strcmp(tl, "new_centroid") == 0)
-	Tool_next = TOOL_NEW_CENTROID;
-    else if (strcmp(tl, "move_vertex") == 0)
-	Tool_next = TOOL_MOVE_VERTEX;
-    else if (strcmp(tl, "add_vertex") == 0)
-	Tool_next = TOOL_ADD_VERTEX;
-    else if (strcmp(tl, "rm_vertex") == 0)
-	Tool_next = TOOL_RM_VERTEX;
-    else if (strcmp(tl, "split_line") == 0)
-	Tool_next = TOOL_SPLIT_LINE;
-    else if (strcmp(tl, "edit_line") == 0)
-	Tool_next = TOOL_EDIT_LINE;
-    else if (strcmp(tl, "move_line") == 0)
-	Tool_next = TOOL_MOVE_LINE;
-    else if (strcmp(tl, "delete_line") == 0)
-	Tool_next = TOOL_DELETE_LINE;
-    else if (strcmp(tl, "display_cats") == 0)
-	Tool_next = TOOL_DISPLAY_CATS;
-    else if (strcmp(tl, "copy_cats") == 0)
-	Tool_next = TOOL_COPY_CATS;
-    else if (strcmp(tl, "display_attributes") == 0)
-	Tool_next = TOOL_DISPLAY_ATTRIBUTES;
-    else if (strcmp(tl, "exit") == 0)
-	Tool_next = TOOL_EXIT;
-    else if (strcmp(tl, "zoom_window") == 0)
-	Tool_next = TOOL_ZOOM_WINDOW;
-    else if (strcmp(tl, "zoom_out_centre") == 0)
-	Tool_next = TOOL_ZOOM_OUT_CENTRE;
-    else if (strcmp(tl, "zoom_pan") == 0)
-	Tool_next = TOOL_ZOOM_PAN;
-    else if (strcmp(tl, "zoom_default") == 0)
-	Tool_next = TOOL_ZOOM_DEFAULT;
-    else if (strcmp(tl, "zoom_region") == 0)
-	Tool_next = TOOL_ZOOM_REGION;
-    else if (strcmp(tl, "redraw") == 0)
-	Tool_next = TOOL_REDRAW;
-    else if (strcmp(tl, "settings") == 0)
-	Tool_next = TOOL_DISPLAY_SETTINGS;
-    else {
-	G_warning("c_next_tool(): Unknown tool: %s", tl);
-	return TCL_ERROR;
-    }
-
-    G_debug(2, "  Tool_next = %d", Tool_next);
-
-    /* Stop running if any */
-    cancel_tool();
-    next_tool();
-
-    return TCL_OK;
-}
-
-/* set color */
-int c_set_color(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int code;
-
-    G_debug(2, "c_set_color()");
-    if (argc < 5) {
-	G_warning("c_set_color(): inicorrect number of parameters");
-	return TCL_ERROR;
-    }
-
-    code = get_symb_code(argv[1]);
-
-    if (code < 0) {
-	G_warning("c_set_color(): Unknown symb name: %s", argv[1]);
-	return TCL_ERROR;
-    }
-
-    G_debug(2, "symb = %d", code);
-    G_debug(2, " %s %s %s", argv[2], argv[3], argv[4]);
-
-    Symb[code].r = atoi(argv[2]);
-    Symb[code].g = atoi(argv[3]);
-    Symb[code].b = atoi(argv[4]);
-
-    return TCL_OK;
-}
-
-/* set layer on/off */
-int c_set_on(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int code;
-
-    G_debug(2, "c_set_on()");
-    if (argc < 3) {
-	G_warning("c_set_on(): inicorrect number of parameters");
-	return TCL_ERROR;
-    }
-
-    code = get_symb_code(argv[1]);
-
-    if (code < 0) {
-	G_warning("c_set_on(): Unknown symb name: %s", argv[1]);
-	return TCL_ERROR;
-    }
-
-    G_debug(2, "symb = %d on = %d", code, atoi(argv[2]));
-
-    Symb[code].on = atoi(argv[2]);
-
-    return TCL_OK;
-}
-
-int
-c_tool_centre(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    G_debug(3, "c_tool_centre()");
-
-    tool_centre();
-    return TCL_OK;
-}
-
-/* create table definition in GUI */
-int
-c_table_definition(ClientData cdata, Tcl_Interp * interp, int argc,
-		   char *argv[])
-{
-    int col, ncols, sqltype;
-    char buf[1000];
-    struct field_info *Fi;
-    dbString tabname;
-    dbDriver *driver;
-    dbHandle handle;
-    dbTable *table;
-    dbColumn *column;
-
-    G_debug(2, "c_table_definition()");
-
-    db_init_string(&tabname);
-
-    if (Vect_get_num_dblinks(&Map) > 0) {
-	Fi = Vect_get_dblink(&Map, 0);
-
-	driver = db_start_driver(Fi->driver);
-	if (driver == NULL) {
-	    G_warning("Cannot open driver %s", Fi->driver);
-	    return TCL_OK;
-	}
-	db_init_handle(&handle);
-	db_set_handle(&handle, Vect_subst_var(Fi->database, &Map), NULL);
-	if (db_open_database(driver, &handle) != DB_OK) {
-	    G_warning("Cannot open database %s", Fi->database);
-	    db_shutdown_driver(driver);
-	    return TCL_OK;
-	}
-	db_init_string(&tabname);
-	db_set_string(&tabname, Fi->table);
-	if (db_describe_table(driver, &tabname, &table) != DB_OK)
-	    return TCL_OK;
-
-	ncols = db_get_table_number_of_columns(table);
-	for (col = 0; col < ncols; col++) {
-	    column = db_get_table_column(table, col);
-	    sqltype = db_get_column_sqltype(column);
-	    sprintf(buf, "add_tab_col \"%s\" \"%s\" %d 0 0 0",
-		    db_get_column_name(column), db_sqltype_name(sqltype),
-		    db_get_column_length(column));
-	    Tcl_Eval(Toolbox, buf);
-
-	}
-    }
-    else {
-	Tcl_Eval(Toolbox, "add_tab_col cat integer 0 1 0 0");
-	Tcl_Eval(Toolbox, "table_buttons");
-    }
-
-    return TCL_OK;
-}
-
-/* create new table */
-int
-c_create_table(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int field, ret;
-    struct field_info *Fi;
-    dbString sql, err;
-    dbDriver *driver;
-    dbHandle handle;
-
-    G_debug(2, "c_create_table() field = %s key = %s cols = %s", argv[1],
-	    argv[3], argv[4]);
-
-    Tcl_SetVar(Toolbox, "create_table_err", "1", TCL_GLOBAL_ONLY);
-    db_init_string(&sql);
-    db_init_string(&err);
-    field = atoi(argv[1]);
-
-    Fi = Vect_default_field_info(&Map, field, NULL, GV_1TABLE);
-    G_debug(2, "driver = %s, database = %s", Fi->driver, Fi->database);
-
-    driver = db_start_driver(Fi->driver);
-    if (driver == NULL) {
-	G_warning("Cannot open driver %s", Fi->driver);
-	db_set_string(&err, "Cannot open driver ");
-	db_append_string(&err, Fi->driver);
-	Tcl_SetVar(Toolbox, "create_table_msg", db_get_string(&err),
-		   TCL_GLOBAL_ONLY);
-	return TCL_OK;
-    }
-    db_init_handle(&handle);
-    db_set_handle(&handle, Vect_subst_var(Fi->database, &Map), NULL);
-    if (db_open_database(driver, &handle) != DB_OK) {
-	G_warning("Cannot open database %s", Fi->database);
-	db_set_string(&err, "Cannot open database ");
-	db_append_string(&err, Fi->database);
-	db_append_string(&err, " by driver ");
-	db_append_string(&err, Fi->driver);
-	db_append_string(&err, db_get_error_msg());
-	db_shutdown_driver(driver);
-	Tcl_SetVar(Toolbox, "create_table_msg", db_get_string(&err),
-		   TCL_GLOBAL_ONLY);
-	return TCL_OK;
-    }
-
-    db_set_string(&sql, "create table ");
-    db_append_string(&sql, Fi->table);
-    db_append_string(&sql, " ( ");
-    db_append_string(&sql, argv[4]);
-    db_append_string(&sql, " ) ");
-    G_debug(2, db_get_string(&sql));
-
-    if (db_execute_immediate(driver, &sql) != DB_OK) {
-	G_warning("Cannot create table: %s", db_get_string(&sql));
-	db_set_string(&err, "Cannot create table: ");
-	db_append_string(&err, db_get_string(&sql));
-	db_append_string(&err, "\n");
-	db_append_string(&err, db_get_error_msg());
-	db_close_database(driver);
-	db_shutdown_driver(driver);
-	Tcl_SetVar(Toolbox, "create_table_msg", db_get_string(&err),
-		   TCL_GLOBAL_ONLY);
-	return TCL_OK;
-    }
-
-    if (db_create_index2(driver, Fi->table, argv[3]) != DB_OK) {
-	G_warning("Cannot create index");
-	db_set_string(&err, "Cannot create index:\n");
-	db_append_string(&err, db_get_error_msg());
-	db_close_database(driver);
-	db_shutdown_driver(driver);
-	Tcl_SetVar(Toolbox, "create_table_msg", db_get_string(&err),
-		   TCL_GLOBAL_ONLY);
-	return TCL_OK;
-    }
-
-    if (db_grant_on_table
-	(driver, Fi->table, DB_PRIV_SELECT, DB_GROUP | DB_PUBLIC) != DB_OK) {
-	G_warning("Cannot grant privileges on table %s", Fi->table);
-	db_set_string(&err, "Cannot grant privileges on table:\n");
-	db_append_string(&err, db_get_error_msg());
-	db_close_database(driver);
-	db_shutdown_driver(driver);
-	Tcl_SetVar(Toolbox, "create_table_msg", db_get_string(&err),
-		   TCL_GLOBAL_ONLY);
-	return TCL_OK;
-    }
-
-    db_close_database(driver);
-    db_shutdown_driver(driver);
-
-    ret =
-	Vect_map_add_dblink(&Map, field, NULL, Fi->table, argv[3],
-			    Fi->database, Fi->driver);
-    if (ret == -1) {
-	db_set_string(&err,
-		      "Cannot add database link to vector, link for given field probably "
-		      "already exists.");
-	Tcl_SetVar(Toolbox, "create_table_msg", db_get_string(&err),
-		   TCL_GLOBAL_ONLY);
-	return TCL_OK;
-    }
-
-    Tcl_SetVar(Toolbox, "create_table_err", "0", TCL_GLOBAL_ONLY);
-
-    return TCL_OK;
-}
-
-/* set variable */
-int c_var_set(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int type, code;
-
-    G_debug(5, "c_var_set()");
-
-    if (argc != 3) {
-	G_warning("c_var_set(): incorrect number of parameters");
-	return TCL_ERROR;
-    }
-
-    type = var_get_type_by_name(argv[1]);
-    if (type == -1)
-	return TCL_ERROR;
-    code = var_get_code_by_name(argv[1]);
-
-    switch (type) {
-    case VART_INT:
-	var_seti(code, atoi(argv[2]));
-	break;
-    case VART_DOUBLE:
-	var_setd(code, atof(argv[2]));
-	break;
-    case VART_CHAR:
-	var_setc(code, argv[2]);
-	break;
-    }
-
-    return TCL_OK;
-}
-
-/* Create bgcmd records in GUI */
-int
-c_create_bgcmd(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int i;
-
-    G_debug(3, "c_create_bgcmd()");
-
-    for (i = 0; i < nbgcmd; i++) {
-	i_add_bgcmd(i);
-    }
-
-    return TCL_OK;
-}
-
-/* set bgcmd */
-int c_set_bgcmd(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int index, on;
-
-    G_debug(3, "c_bgcmd_set()");
-
-    if (argc != 4) {
-	G_warning("c_bgcmd_set(): incorrect number of parameters");
-	return TCL_ERROR;
-    }
-
-    index = atoi(argv[1]);
-    on = atoi(argv[2]);
-
-    G_debug(3, "  index = %d on = %d cmd = %s", index, on, argv[3]);
-
-    Bgcmd[index].on = on;
-    G_free(Bgcmd[index].cmd);
-    Bgcmd[index].cmd = G_store(argv[3]);
-
-    return TCL_OK;
-}
-
-/* Add blank field for bgcmd */
-int
-c_add_blank_bgcmd(ClientData cdata, Tcl_Interp * interp, int argc,
-		  char *argv[])
-{
-    char buf[100];
-    int k = 0;
-
-    G_debug(3, "c_add_blank_bgcmd()");
-
-    memset(buf, '\0', strlen(buf));
-    k = bg_add("");
-
-    sprintf(buf, "set comrow %d", k - 1);
-    Tcl_Eval(Toolbox, buf);
-
-
-    return TCL_OK;
-}
-
-/* Delete line category, parameters: line field cat */
-int c_del_cat(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int line, field, cat;
-
-    G_debug(3, "c_del_cat()");
-
-    if (argc != 4) {
-	G_warning("c_del_cat(): incorrect number of parameters");
-	return TCL_ERROR;
-    }
-
-    line = atoi(argv[1]);
-    field = atoi(argv[2]);
-    cat = atoi(argv[3]);
-
-    G_debug(3, "  line = %d field = %d cat = %d", line, field, cat);
-
-    del_cat(line, field, cat);
-
-    return TCL_OK;
-}
-
-/* Add new category to the current line */
-int c_add_cat(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int field, cat, newrec;
-
-    G_debug(3, "c_add_cat()");
-
-    if (argc != 4) {
-	G_warning("c_del_cat(): incorrect number of parameters");
-	return TCL_ERROR;
-    }
-
-    field = atoi(argv[1]);
-    cat = atoi(argv[2]);
-    newrec = atoi(argv[3]);
-
-    if (field < 1 || cat < 1) {
-	Tcl_Eval(Toolbox, "MessageDlg .msg -icon error -type ok "
-		 "-message \"Layer and category must be greater than 0\"");
-	return TCL_OK;
-    }
-
-    G_debug(3, "  field = %d cat = %d newrec = %d", field, cat, newrec);
-
-    add_cat(field, cat, newrec);
-
-    return TCL_OK;
-}

+ 0 - 92
vector/v.digit/cat.c

@@ -1,92 +0,0 @@
-/* ***************************************************************
- * *
- * * MODULE:       v.digit
- * * 
- * * AUTHOR(S):    Radim Blazek
- * *               
- * * PURPOSE:      Edit vector
- * *              
- * * COPYRIGHT:    (C) 2001 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.
- * *
- * **************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/colors.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include "global.h"
-#include "proto.h"
-
-
-/* Init cats */
-void cat_init(void)
-{
-    int i, line, nlines;
-    struct line_cats *Cats;
-
-    G_debug(2, "cat_init()");
-    Cats = Vect_new_cats_struct();
-
-    /* Max cats */
-    nMaxFieldCat = 0;
-    aMaxFieldCat = 10;		/* allocated space */
-    MaxFieldCat = (void *)G_malloc((aMaxFieldCat) * sizeof(int) * 2);
-
-    /* Read the map and set maximum categories */
-    nlines = Vect_get_num_lines(&Map);
-    for (line = 1; line <= nlines; line++) {
-	Vect_read_line(&Map, NULL, Cats, line);
-	for (i = 0; i < Cats->n_cats; i++) {
-	    if ((cat_max_get(Cats->field[i])) < Cats->cat[i]) {
-		cat_max_set(Cats->field[i], Cats->cat[i]);
-	    }
-	}
-    }
-}
-
-/* get maximum cat for field */
-int cat_max_get(int field)
-{
-    int i;
-
-    G_debug(2, "cat_max_get() field = %d", field);
-
-    for (i = 0; i < nMaxFieldCat; i++) {
-	if (MaxFieldCat[i][0] == field) {
-	    return (MaxFieldCat[i][1]);
-	}
-    }
-
-    return 0;
-}
-
-/* set maximum cat for field */
-void cat_max_set(int field, int cat)
-{
-    int i;
-
-    G_debug(2, "cat_max_set() field = %d cat = %d", field, cat);
-
-    for (i = 0; i < nMaxFieldCat; i++) {
-	if (MaxFieldCat[i][0] == field) {
-	    MaxFieldCat[i][1] = cat;
-	    return;
-	}
-    }
-    /* Field not found -> add new */
-    if (nMaxFieldCat == aMaxFieldCat) {
-	aMaxFieldCat += 10;
-	MaxFieldCat =
-	    (void *)G_realloc(MaxFieldCat, (aMaxFieldCat) * sizeof(int) * 2);
-    }
-    MaxFieldCat[nMaxFieldCat][0] = field;
-    MaxFieldCat[nMaxFieldCat][1] = cat;
-    nMaxFieldCat++;
-}

+ 0 - 81
vector/v.digit/cats.tcl

@@ -1,81 +0,0 @@
-# Categories
-
-# remove all cats from list
-proc clear_cats { } {
-    global Cats CatsFr GVariable GWidget GBgcmd
-
-    foreach f [ winfo children $CatsFr] {
-	destroy $f
-    }
-}
-
-# add category to list
-proc add_cat { line field cat } {
-    global Cats CatsFr GVariable GWidget GBgcmd
-
-    set row [ frame $CatsFr.${field}_$cat ]
-
-    Label $row.field -anchor w -width 10 -text [G_msg "Layer: $field"]
-    Label $row.cat -anchor w -width 10 -text [G_msg "Category: $cat"]
-    Button $row.del -anchor w -text [G_msg "Delete"] -borderwidth 1 -width 6 \
-    	-command "c_del_cat $line $field $cat" 
-
-    pack $row.field $row.cat -side left -expand yes -fill x
-    pack $row.del -side right -expand no
-    pack $row -side top -fill x -expand yes -padx 5
-}
-
-# create cats window
-proc mk_cats { } {
-    global Cats CatsFr GVariable GWidget GBgcmd
-
-    # Already opened
-    if { [winfo exists .cats] } {
-        puts [G_msg "Categories already opened"]
-        wm deiconify .cats
-        raise .cats
-        return
-    } 
-
-    # Window
-    set Cats [toplevel .cats]
-    wm title $Cats [G_msg "Categories"]
- 
-    # Scrolling window
-    set CatsSw [ScrolledWindow $Cats.sw -relief sunken -borderwidth 2]
-    set CatsSf [ScrollableFrame $Cats.sf -width 300 -height 100]
-    $CatsSw setwidget $CatsSf
-    pack $CatsSw $CatsSf -fill both -expand yes
-    set CatsFr [$CatsSf getframe]
-    pack $CatsFr -side top -expand yes -fill x -anchor n
-
-    set row1 [ frame $Cats.row1 ]
-    Label $row1.flab -anchor w -text [G_msg "Layer:"] -anchor e
-    Entry $row1.fentry -width 5 -textvariable GVariable(new_cat_field) -bg white
-    Label $row1.clab -anchor w -text [G_msg "   Category:"] -anchor e
-    Entry $row1.centry -width 8 -textvariable GVariable(new_cat_cat) -bg white
-    pack $row1.flab $row1.fentry $row1.clab $row1.centry -side left
-    pack $row1 -side top -fill x -expand yes -anchor n -padx 5 -pady 2
-
-    set row2 [ frame $Cats.row2 ]
-    checkbutton $row2.newrec -variable GVariable(new_cat_newrec) -height 1
-    Label $row2.newreclab -anchor w -width 30 -text [G_msg "Insert new record to table"]
-    Button $row2.new -text [G_msg "Add new"] -borderwidth 1 -width 6 \
-        -command { c_add_cat $GVariable(new_cat_field) $GVariable(new_cat_cat) $GVariable(new_cat_newrec) }
-    pack $row2.newrec $row2.newreclab $row2.new -side left
-    pack $row2 -side top -fill x -expand yes -anchor n -padx 5
-
-    pack $Cats -fill both -expand yes -padx 1 -pady 1
-    $Cats raise
-    tkwait visibility $Cats
-}
-
-
-
-# destroy cats window
-proc destroy_cats {} {
-    global Cats GVariable GWidget GBgcmd
-
-    puts "Destroy Cats"
-    destroy $Cats
-}

+ 0 - 182
vector/v.digit/centre.c

@@ -1,182 +0,0 @@
-/* ***************************************************************
- * *
- * * MODULE:       v.digit
- * * 
- * * AUTHOR(S):    Radim Blazek
- * *               
- * * PURPOSE:      Edit vector
- * *              
- * * COPYRIGHT:    (C) 2001 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.
- * *
- * **************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <grass/config.h>
-#include <grass/gis.h>
-#include <grass/display.h>
-#include <grass/glocale.h>
-#include "global.h"
-#include "proto.h"
-
-/* This function is started from the GUI, it regularly updates GUI and checks GUI requirements. 
- *  If Tool_next is set by GUI, the tool is started by the tool_centre()
- */
-void tool_centre(void)
-{
-    /* Init variables */
-    var_init();
-
-    /* Init snap */
-    var_seti(VAR_SNAP, 1);
-    var_seti(VAR_SNAP_MODE, SNAP_SCREEN);
-    var_seti(VAR_SNAP_SCREEN, 10);
-    var_setd(VAR_SNAP_MAP, 10);
-
-    G_get_window(&window);
-
-    /* Set tool */
-    Tool_next = TOOL_NOTHING;
-
-    /* Display the map */
-    symb_init();
-    G_get_window(&window);
-    driver_open();
-    display_erase();
-    display_bg();
-    display_map();
-    driver_close();
-
-    symb_init_gui();
-    i_prompt("Select tool");
-}
-
-void next_tool(void)
-{
-    switch (Tool_next) {
-    case TOOL_EXIT:
-	G_debug(2, "Quit");
-	end();
-	break;
-    case TOOL_NEW_POINT:
-	/* Tool_next = TOOL_NOTHING; *//* Commented -> Draw next one once first is done */
-	new_line(GV_POINT);
-	break;
-    case TOOL_NEW_LINE:
-	new_line(GV_LINE);
-	break;
-    case TOOL_NEW_BOUNDARY:
-	new_line(GV_BOUNDARY);
-	break;
-    case TOOL_NEW_CENTROID:
-	new_line(GV_CENTROID);
-	break;
-    case TOOL_MOVE_VERTEX:
-	Tool_next = TOOL_NOTHING;
-	move_vertex();
-	break;
-    case TOOL_ADD_VERTEX:
-	Tool_next = TOOL_NOTHING;
-	add_vertex();
-	break;
-    case TOOL_RM_VERTEX:
-	Tool_next = TOOL_NOTHING;
-	rm_vertex();
-	break;
-    case TOOL_SPLIT_LINE:
-	Tool_next = TOOL_NOTHING;
-	split_line();
-	break;
-    case TOOL_EDIT_LINE:
-	Tool_next = TOOL_NOTHING;
-	edit_line();
-	break;
-    case TOOL_MOVE_LINE:
-	Tool_next = TOOL_NOTHING;
-	move_line();
-	break;
-    case TOOL_DELETE_LINE:
-	Tool_next = TOOL_NOTHING;
-	delete_line();
-	break;
-    case TOOL_DISPLAY_CATS:
-	Tool_next = TOOL_NOTHING;
-	display_cats();
-	break;
-    case TOOL_COPY_CATS:
-	Tool_next = TOOL_NOTHING;
-	copy_cats();
-	break;
-    case TOOL_DISPLAY_ATTRIBUTES:
-	Tool_next = TOOL_NOTHING;
-	display_attributes();
-	break;
-    case TOOL_DISPLAY_SETTINGS:
-	Tool_next = TOOL_NOTHING;
-	Tcl_Eval(Toolbox, "settings");
-	break;
-    case TOOL_ZOOM_WINDOW:
-	Tool_next = TOOL_NOTHING;
-	zoom_window();
-	break;
-    case TOOL_ZOOM_OUT_CENTRE:
-	Tool_next = TOOL_NOTHING;
-	zoom_centre(2);
-	break;
-    case TOOL_ZOOM_PAN:
-	Tool_next = TOOL_NOTHING;
-	zoom_pan();
-	break;
-    case TOOL_ZOOM_DEFAULT:
-	Tool_next = TOOL_NOTHING;
-	zoom_default();
-	break;
-    case TOOL_ZOOM_REGION:
-	Tool_next = TOOL_NOTHING;
-	zoom_region();
-	break;
-    case TOOL_REDRAW:
-	Tool_next = TOOL_NOTHING;
-	driver_open();
-	display_redraw();
-	driver_close();
-	break;
-    case TOOL_NOTHING:
-	break;
-    }
-}
-
-/* This function is regularly called from R_get_location_*() functions to enable GUI to kill running tool */
-void update(int wx, int wy)
-{
-    double x, y;
-
-    G_debug(5, "Update function wx = %d wy = %d", wx, wy);
-
-    if (wx != COOR_NULL && wy != COOR_NULL) {
-	x = D_d_to_u_col(wx);
-	y = D_d_to_u_row(wy);
-	i_coor(x, y);
-    }
-}
-
-void end(void)
-{
-    G_debug(1, "end()");
-    Vect_build_partial(&Map, GV_BUILD_NONE);
-    Vect_build(&Map);
-    Vect_close(&Map);
-
-    if (1 == G_put_window(&GRegion))
-	G_message(_("Region restored to original extent."));
-
-    /* clear the screen */
-    Tcl_Eval(Toolbox, ".screen.canvas delete all");
-
-    exit(EXIT_SUCCESS);
-}

+ 0 - 265
vector/v.digit/display.c

@@ -1,265 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-#include <math.h>
-#include <grass/gis.h>
-#include <grass/Vect.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include <grass/colors.h>
-#include "global.h"
-#include "proto.h"
-
-/* --- DISLAY ---
- *  For all display functions the display driver must be opened first.
- *  Because some functions like erase() call other grass commands, driver is closed
- *  and reopened within these functions
- */
-
-/* Display points */
-void display_points(struct line_pnts *Points, int flsh)
-{
-    int i;
-
-    G_debug(2, "display_points()");
-
-    driver_line_width(var_geti(VAR_LINEWIDTH));
-    driver_move(Points->x[0], Points->y[0]);
-    for (i = 1; i < Points->n_points; i++)
-	driver_cont(Points->x[i], Points->y[i]);
-
-    driver_line_width(0);
-}
-
-/* Display icon */
-void display_icon(double x, double y, int icon, double angle, int size,
-		  int flsh)
-{
-    G_debug(2, "display_icon()");
-    if (icon == G_ICON_CROSS && angle == 0)
-	driver_plot_icon(x, y, "cross");
-    else if (icon == G_ICON_CROSS)
-	driver_plot_icon(x, y, "cross45");
-    else if (icon == G_ICON_BOX)
-	driver_plot_icon(x, y, "box");
-}
-
-/* Display vector line 
- *  color : code from SymbNumber 
- *
- *  ! This function doesn't check Symb[symb].on so that new digitized line is displayed even
- *    if its symbology is switched off (that means incorrect and user friendly)
- */
-void display_line(int line, int color, int flsh)
-{
-    int type, symb;
-    static struct line_pnts *Points;
-    static struct line_cats *Cats;
-    static int first = 1;
-
-    G_debug(2, "display_line(): line = %d color = %d", line, color);
-
-    if (first) {
-	Points = Vect_new_line_struct();
-	Cats = Vect_new_cats_struct();
-	first = 0;
-    }
-
-    if (!Vect_line_alive(&Map, line))
-	return;
-
-    type = Vect_read_line(&Map, Points, Cats, line);
-
-    if (color == SYMB_DEFAULT)
-	symb = LineSymb[line];
-    else
-	symb = color;
-
-    symb_set_driver_color(symb);
-
-    if (type & GV_POINTS)
-	display_icon(Points->x[0], Points->y[0], G_ICON_CROSS, 0, 6, flsh);
-    else
-	display_points(Points, flsh);
-
-}
-
-/* Redraw updated lines */
-void display_updated_lines(int symb)
-{
-    int i, line;
-
-    for (i = 0; i < Vect_get_num_updated_lines(&Map); i++) {
-	line = Vect_get_updated_line(&Map, i);
-	if (!Vect_line_alive(&Map, line))
-	    continue;
-	display_line(line, symb, 0);
-    }
-}
-
-/* Display node, color may be given but shape and size is read from symbology table,
- *  this is useful to delete (redraw by background) existing node
- *  
- *  color : code from SymbNumber 
- */
-void display_node(int node, int color, int flsh)
-{
-    int symb;
-    double x, y;
-
-    G_debug(2, "display_node(): node = %d color = %d", node, color);
-
-    if (!Vect_node_alive(&Map, node))
-	return;
-
-    if (color == SYMB_DEFAULT)
-	symb = NodeSymb[node];
-    else
-	symb = color;
-
-    symb_set_driver_color(symb);
-    Vect_get_node_coor(&Map, node, &x, &y, NULL);
-    display_icon(x, y, G_ICON_CROSS, 0.785, 6, flsh);
-}
-
-/* Redraw updated nodes */
-void display_updated_nodes(int symb)
-{
-    int i, node;
-
-    if (symb != SYMB_DEFAULT)
-	symb_set_driver_color(symb);
-
-    for (i = 0; i < Vect_get_num_updated_nodes(&Map); i++) {
-	node = Vect_get_updated_node(&Map, i);
-	if (!Vect_node_alive(&Map, node))
-	    continue;
-	if (NodeSymb[node] == SYMB_NODE_0)
-	    continue;
-	display_node(node, symb, 0);
-    }
-}
-
-/* Display vector map */
-void display_map(void)
-{
-    int i, n, symb;
-
-
-    G_debug(2, "display_map()");
-
-
-    /* Because after resize of monitor we expect manual call to display_map()
-     *  it is good to refresh D_* here */
-    driver_refresh();
-
-    /* Lines */
-    n = Vect_get_num_lines(&Map);
-    symb_set_driver_color(SYMB_HIGHLIGHT);
-    for (i = 1; i <= n; i++) {
-	symb = LineSymb[i];
-	G_debug(2, "symb = %d", symb);
-	if (!Symb[symb].on)
-	    continue;
-	display_line(i, SYMB_DEFAULT, 0);
-    }
-
-    /* Nodes: first nodes with more than 1 line, then nodes with only 1 line, 
-     *   so that dangles are not hidden, and nodes without lines (points, 
-     *   centroids, are displayed) */
-    n = Vect_get_num_nodes(&Map);
-
-    if (Symb[SYMB_NODE_2].on) {
-	symb_set_driver_color(SYMB_NODE_2);
-	for (i = 1; i <= n; i++) {
-	    if (!Vect_node_alive(&Map, i))
-		continue;
-	    if (NodeSymb[i] != SYMB_NODE_2)
-		continue;
-	    display_node(i, NodeSymb[i], 0);
-	}
-    }
-
-    if (Symb[SYMB_NODE_1].on) {
-	symb_set_driver_color(SYMB_NODE_1);
-	for (i = 1; i <= n; i++) {
-	    G_debug(2, "node = %d NodeSymb = %d", i, NodeSymb[i]);
-	    if (!Vect_node_alive(&Map, i))
-		continue;
-	    if (NodeSymb[i] != SYMB_NODE_1)
-		continue;
-	    display_node(i, NodeSymb[i], 0);
-	}
-    }
-}
-
-/* Display bacground */
-void display_bg(void)
-{
-    static char w_buf[] = "GRASS_WIDTH=0000000000";
-    static char h_buf[] = "GRASS_HEIGHT=0000000000";
-    static char img_buf[GPATH_MAX];
-    static char cmd_buf[GPATH_MAX];
-    char *ppmfile = G_tempfile();
-    int i;
-
-    G_debug(2, "display_bg()");
-
-    putenv("GRASS_VERBOSE=0");
-    putenv("GRASS_RENDER_IMMEDIATE=TRUE");
-    putenv("GRASS_TRUECOLOR=TRUE");
-
-    sprintf(cmd_buf, "GRASS_BACKGROUNDCOLOR=%02x%02x%02x",
-	    Symb[SYMB_BACKGROUND].r, Symb[SYMB_BACKGROUND].g,
-	    Symb[SYMB_BACKGROUND].b);
-    putenv(cmd_buf);
-
-    sprintf(img_buf, "GRASS_PNGFILE=%s.ppm", ppmfile);
-    putenv(img_buf);
-
-    sprintf(w_buf, "GRASS_WIDTH=%d", (int)(D_get_d_east() - D_get_d_west()));
-    putenv(w_buf);
-
-    sprintf(h_buf, "GRASS_HEIGHT=%d",
-	    (int)(D_get_d_south() - D_get_d_north()));
-    putenv(h_buf);
-
-    for (i = 0; i < nbgcmd; i++) {
-	putenv((i > 0) ? "GRASS_PNG_READ=TRUE" : "GRASS_PNG_READ=FALSE");
-	if (Bgcmd[i].on)
-	    system(Bgcmd[i].cmd);
-    }
-
-    sprintf(cmd_buf, "image create photo bgimage -file {%s.ppm}", ppmfile);
-    Tcl_Eval(Toolbox, cmd_buf);
-
-    sprintf(cmd_buf,
-	    ".screen.canvas create image %d %d -image bgimage -anchor nw",
-	    (int)D_a_to_d_col(0), (int)D_a_to_d_row(0));
-    Tcl_Eval(Toolbox, cmd_buf);
-
-    remove(ppmfile);
-    G_free(ppmfile);
-}
-
-/* Erase */
-void display_erase(void)
-{
-    driver_close();
-    Tcl_Eval(Toolbox, ".screen.canvas delete all");
-    driver_open();
-
-    /* As erase must be run after each zoom by v.digit, here is good place to reset plot.
-     *  Other such place is display_map() */
-    driver_refresh();
-}
-
-/* Redraw */
-void display_redraw(void)
-{
-    display_erase();
-    display_bg();
-    display_map();
-}

+ 0 - 138
vector/v.digit/driver.c

@@ -1,138 +0,0 @@
-#include <math.h>
-#include <grass/gis.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include <grass/colors.h>
-#include "global.h"
-#include "proto.h"
-
-static char color[16];
-static int width;
-
-void driver_rgb_color(int r, int g, int b)
-{
-    sprintf(color, "#%02x%02x%02x", r, g, b);
-}
-
-void driver_line_width(int w)
-{
-    width = w ? w : 1;
-}
-
-static int curx, cury;
-static double lastx;
-
-static void convert(double x, double y, int *xi, int *yi)
-{
-    if (D_is_lat_lon()) {
-	double d = x - lastx;
-	if (fabs(d) > 180)
-	    x -= 360 * floor(d / 360 + 0.5);
-    }
-
-    *xi = (int)floor(D_u_to_d_col(x));
-    *yi = (int)floor(D_u_to_d_row(y));
-}
-
-void driver_cont(double x, double y)
-{
-    char buf[1024];
-    int xi, yi;
-
-    convert(x, y, &xi, &yi);
-
-    sprintf(buf, ".screen.canvas create line %d %d %d %d -width %d -fill %s",
-	    curx, cury, xi, yi, width, color);
-    Tcl_Eval(Toolbox, buf);
-
-    curx = xi;
-    cury = yi;
-    lastx = x;
-}
-
-void driver_move(double x, double y)
-{
-    int xi, yi;
-
-    convert(x, y, &xi, &yi);
-
-    curx = xi;
-    cury = yi;
-    lastx = x;
-}
-
-void driver_plot_icon(double x, double y, const char *icon)
-{
-    char buf[1024];
-    int xi, yi;
-
-    xi = (int) floor(D_u_to_d_col(x));
-    yi = (int) floor(D_u_to_d_row(y));
-
-    sprintf(buf,
-	    ".screen.canvas create bitmap %d %d -bitmap @$iconpath/%s.xbm -foreground %s -anchor center",
-	    xi, yi, icon, color);
-    if (Tcl_Eval(Toolbox, buf) != TCL_OK)
-	G_warning("driver_plot_icon: %s", Toolbox->result);
-}
-
-static void get_window(int *t, int *b, int *l, int *r)
-{
-    Tcl_Eval(Toolbox,
-	     "list 0 [winfo height .screen.canvas] 0 [winfo width .screen.canvas]");
-    sscanf(Toolbox->result, "%d %d %d %d", t, b, l, r);
-
-    if (*b > 1 || *r > 1)
-	return;
-
-    Tcl_Eval(Toolbox,
-	     "list 0 [.screen.canvas cget -height] 0 [.screen.canvas cget -width]");
-    sscanf(Toolbox->result, "%d %d %d %d", t, b, l, r);
-}
-
-static void setup(void)
-{
-    struct Cell_head region;
-    int t, b, l, r;
-
-    get_window(&t, &b, &l, &r);
-
-    /* Set the map region associated with graphics frame */
-    G_get_set_window(&region);
-    if (G_set_window(&region) < 0)
-	G_fatal_error("Invalid graphics coordinates");
-
-    /* Determine conversion factors */
-    D_do_conversions(&region, t, b, l, r);
-}
-
-int driver_refresh(void)
-{
-    setup();
-    return 1;
-}
-
-int driver_open(void)
-{
-    double n, s, e, w;
-
-    if (Tcl_Eval(Toolbox, "create_screen") != TCL_OK)
-	G_warning("create_screen: %s", Toolbox->result);
-
-
-    setup();
-
-    n = D_d_to_u_row(D_get_d_north());
-    s = D_d_to_u_row(D_get_d_south());
-    w = D_d_to_u_col(D_get_d_west());
-    e = D_d_to_u_col(D_get_d_east());
-
-    Scale = (n - s) / (D_get_d_south() - D_get_d_north());
-
-    return 1;
-}
-
-int driver_close(void)
-{
-    return 1;
-}

+ 0 - 262
vector/v.digit/form.c

@@ -1,262 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <tcl.h>
-#include <tk.h>
-#include <locale.h>
-#include <grass/gis.h>
-#include <grass/dbmi.h>
-#include <grass/form.h>
-
-/* Structure to store column names and values */
-typedef struct
-{
-    char *name;
-    int ctype;
-    char *value;
-} COLUMN;
-
-static char *Drvname, *Dbname, *Tblname, *Key;
-
-static COLUMN *Columns = NULL;
-static int allocatedRows = 0;	/* allocated space */
-static int nRows = 0;
-
-/* Start new sql update */
-int reset_values(ClientData cdata, Tcl_Interp * interp, int argc,
-		 char *argv[])
-{
-    nRows = 0;
-    Drvname = NULL;
-    Dbname = NULL;
-    Tblname = NULL;
-    Key = NULL;
-
-    return TCL_OK;
-}
-
-int set_value(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    G_debug(2, "set_value(): %s %s", argv[1], argv[2]);
-
-    if (strcmp(argv[1], F_DRIVER_FNAME) == 0) {
-	Drvname = G_store(argv[2]);
-    }
-    else if (strcmp(argv[1], F_DATABASE_FNAME) == 0) {
-	Dbname = G_store(argv[2]);
-    }
-    else if (strcmp(argv[1], F_TABLE_FNAME) == 0) {
-	Tblname = G_store(argv[2]);
-    }
-    else if (strcmp(argv[1], F_KEY_FNAME) == 0) {
-	Key = G_store(argv[2]);
-    }
-    else {
-	if (nRows == allocatedRows) {
-	    allocatedRows += 100;
-	    Columns =
-		(COLUMN *) G_realloc(Columns,
-				     (allocatedRows) * sizeof(COLUMN));
-	}
-	Columns[nRows].name = G_store(argv[1]);
-	Columns[nRows].value = G_store(argv[2]);
-	nRows++;
-    }
-
-    return TCL_OK;
-}
-
-/* Update table, use the data previously stored by set_value() */
-int submit(ClientData cdata, Tcl_Interp * interp, int argc, char *argv[])
-{
-    int i, first, ncols, found, col, sqltype, keyval = 0, ret;
-    char buf[2001];
-    dbString sql, table_name, strval;
-    dbDriver *driver;
-    dbHandle handle;
-    dbTable *table;
-    dbColumn *column;
-
-    G_debug(2, "submit()");
-
-    db_init_string(&sql);
-    db_init_string(&table_name);
-    db_init_string(&strval);
-
-    /* Check if all internal values are set */
-    if (Drvname == NULL || Dbname == NULL || Tblname == NULL || Key == NULL) {
-	G_warning("db connection was not set by form\n");
-	sprintf(buf, "set submit_msg \"db connection was not set by form.\"");
-	Tcl_Eval(interp, buf);
-	Tcl_Eval(interp, "set submit_result 0");
-	return TCL_OK;
-    }
-
-    /* Get column types */
-    G_debug(2, "Open driver");
-    driver = db_start_driver(Drvname);
-    if (driver == NULL) {
-	G_warning("Cannot open driver\n");
-	sprintf(buf, "set submit_msg \"Cannot open driver '%s'\"", Drvname);
-	Tcl_Eval(interp, buf);
-	Tcl_Eval(interp, "set submit_result 0");
-	return TCL_OK;
-    }
-    G_debug(2, "Driver opened");
-
-    db_init_handle(&handle);
-    db_set_handle(&handle, Dbname, NULL);
-    G_debug(2, "Open database");
-    if (db_open_database(driver, &handle) != DB_OK) {
-	G_warning("Cannot open database\n");
-	db_shutdown_driver(driver);
-	sprintf(buf,
-		"set submit_msg \"Cannot open database '%s' by driver '%s'\"",
-		Dbname, Drvname);
-	Tcl_Eval(interp, buf);
-	Tcl_Eval(interp, "set submit_result 0");
-	return TCL_OK;
-    }
-    G_debug(2, "Database opened");
-
-    db_set_string(&table_name, Tblname);
-    if (db_describe_table(driver, &table_name, &table) != DB_OK) {
-	G_warning("Cannot describe table\n");
-	db_shutdown_driver(driver);
-	db_close_database(driver);
-	sprintf(buf, "set submit_msg \"Cannot describe table '%s'\"",
-		Tblname);
-	Tcl_Eval(interp, buf);
-	Tcl_Eval(interp, "set submit_result 0");
-	return TCL_OK;
-    }
-    ncols = db_get_table_number_of_columns(table);
-
-    /* For each column get ctype */
-    for (i = 0; i < nRows; i++) {
-	found = 0;
-	for (col = 0; col < ncols; col++) {
-	    /* get keyval */
-	    if (G_strcasecmp(Columns[i].name, Key) == 0) {
-		keyval = atoi(Columns[i].value);
-	    }
-	    column = db_get_table_column(table, col);
-	    if (G_strcasecmp(db_get_column_name(column), Columns[i].name) ==
-		0) {
-		sqltype = db_get_column_sqltype(column);
-		Columns[i].ctype = db_sqltype_to_Ctype(sqltype);
-		found = 1;
-		break;
-	    }
-	}
-	if (!found && (G_strcasecmp(Columns[i].name, F_ENCODING) != 0)) {
-	    G_warning("Cannot find column type");
-	    db_close_database(driver);
-	    db_shutdown_driver(driver);
-	    sprintf(buf, "set submit_msg \"Cannot find column type\"");
-	    Tcl_Eval(interp, buf);
-	    Tcl_Eval(interp, "set submit_result 0");
-	    return TCL_OK;
-	}
-    }
-
-    /* Construct update statement */
-    sprintf(buf, "update %s set ", Tblname);
-    db_set_string(&sql, buf);
-
-    first = 1;
-    for (i = 0; i < nRows; i++) {
-	G_debug(3, "Index = %d of %d Name = %s, Key = %s", i, nRows,
-		Columns[i].name, Key);
-	if (G_strcasecmp(Columns[i].name, Key) == 0)
-	    continue;
-
-	if (G_strcasecmp(Columns[i].name, F_ENCODING) == 0) {
-
-	    G_debug(3, "GRASS_DB_ENCODING env-var is '%s', col val is '%s'",
-		    G__getenv("GRASS_DB_ENCODING"), Columns[i].value);
-
-	    if ((strlen(Columns[i].value) == 0) ||
-		G_strcasecmp(Columns[i].value,
-			     G__getenv("GRASS_DB_ENCODING")) == 0)
-		continue;
-	    else {
-		G_setenv("GRASS_DB_ENCODING", Columns[i].value);
-		G_debug(3, "Set env var GRASS_DB_ENCODING to '%s'",
-			Columns[i].value);
-		if (Tcl_SetSystemEncoding(interp, Columns[i].value) ==
-		    TCL_ERROR) {
-		    G_warning
-			("Could not set Tcl system encoding to '%s' (%s)",
-			 Columns[i].value, interp->result);
-		}
-	    }
-	    continue;
-	}
-
-	if (!first) {
-	    db_append_string(&sql, ", ");
-	}
-	if (strlen(Columns[i].value) == 0) {
-	    sprintf(buf, "%s = null", Columns[i].name);
-	}
-	else {
-	    if (Columns[i].ctype == DB_C_TYPE_INT ||
-		Columns[i].ctype == DB_C_TYPE_DOUBLE) {
-		sprintf(buf, "%s = %s", Columns[i].name, Columns[i].value);
-	    }
-	    else {
-		memset(buf, '\0', strlen(buf));
-		ret = Tcl_UtfToExternal(interp,
-					Tcl_GetEncoding(interp,
-							G__getenv
-							("GRASS_DB_ENCODING")),
-					Columns[i].value,
-					strlen(Columns[i].value), 0, NULL,
-					buf, 2000, NULL, NULL, NULL);
-
-		if (ret != TCL_OK) {
-		    G_warning("Could not convert UTF to external.");
-		    db_set_string(&strval, Columns[i].value);
-		}
-		else {
-		    db_set_string(&strval, buf);
-		}
-
-		db_double_quote_string(&strval);
-		sprintf(buf, "%s = '%s'", Columns[i].name,
-			db_get_string(&strval));
-	    }
-	}
-	db_append_string(&sql, buf);
-	first = 0;
-    }
-
-    sprintf(buf, " where %s = %d", Key, keyval);
-    db_append_string(&sql, buf);
-
-    G_debug(2, "SQL: %s", db_get_string(&sql));
-
-    /* Update table */
-    ret = db_execute_immediate(driver, &sql);
-
-    db_close_database(driver);
-    db_shutdown_driver(driver);
-
-    if (ret != DB_OK) {
-	G_warning("Cannot update table");
-	Tcl_VarEval(interp, "set submit_msg \"Cannot update table:\n",
-		    db_get_error_msg(), "\"", NULL);
-	Tcl_Eval(interp, "set submit_result 0");
-    }
-    else {
-	Tcl_Eval(interp, "set submit_msg \"Record successfully updated\"");
-	Tcl_Eval(interp, "set submit_result 1");
-    }
-
-    return TCL_OK;
-}

+ 0 - 132
vector/v.digit/form.tcl

@@ -1,132 +0,0 @@
-lappend auto_path $env(GISBASE)/bwidget
-package require -exact BWidget 1.2.1 
-#package require http
-
-set formpath $env(GISBASE)/etc/v.digit
-source $formpath/html_library.tcl
-
-proc create_submit_msg { formid  }  {
-    global submit_result submit_msg formf
-
-    destroy $formf($formid).sbw 
-    destroy $formf($formid).sbt
-
-    if { $submit_result == 1 } { set color "green" } else { set color "red" }
-    set sbw [ScrolledWindow $formf($formid).sbw -relief sunken -borderwidth 2]
-    set sbt [text $formf($formid).sbt -height 3 -width 20 -foreground $color ]
-    pack $sbw $sbt -fill x
-    $sbw setwidget $sbt
-    $sbt insert end $submit_msg
-    $sbt configure -state disabled
-}
-
-proc add_form { formid title html } {
-    global nb formf
-
-    set form($formid) [$nb insert end $formid -text $title]
-    $nb raise $formid
-    set formf($formid) [ frame $form($formid).frm ]
-    set formsw($formid) [ScrolledWindow $formf($formid).sw -relief sunken -borderwidth 2]
-    set formtxt($formid) [ text $formf($formid).txt -height 5 -width 20 ]
-    pack $formf($formid) $formsw($formid) $formtxt($formid) -fill both -expand yes
-    $formsw($formid) setwidget $formtxt($formid)
-    HMinit_win $formtxt($formid)
-    HMparse_html $html "HMrender $formtxt($formid)"
-    $formtxt($formid) configure -state disabled
-}
-
-proc clear_nb { }  {
-    global submit_msg
- 
-    set submit_msg ""
-  
-    foreach frm [ .form.nb pages ] {
-        .form.nb delete $frm
-    }
-}
-
-proc HMsubmit_form {win param query} {
-    global submit_result submit_msg
-
-    regexp -- {\.form\.nb\.f(.+)\.frm\.txt} $win r formid 
-    #puts "win = $win formid = $formid"
-
-    reset_values
-    foreach {col val} $query {
-        #puts "$col : $val" 
-        set_value $col $val 
-    }
-
-    submit $formid
-    #puts "result = $submit_result msg = $submit_msg" 
-    create_submit_msg $formid   
-}
-
-proc make_form {} {
-	global nb
-
-	set nb [NoteBook .form.nb]
-	$nb configure -width 300 -height 500
-	pack .form.nb -fill both -expand yes
-}
-
-proc close_form {} {
-	global form_open
-
-	wm withdraw .form
-	set form_open false
-}
-
-proc open_form {title html} {
-	global form_open encoding_val frmid
-
-	if {! $form_open} {
-		wm state .form normal
-		set form_open true
-	}
-
-	set html [encoding convertfrom $encoding_val $html]
-
-	#  Insert new page 
-	add_form $frmid $title $html
-
-	incr frmid
-}
-
-proc clear_form {} {
-	clear_nb
-}
-
-proc done_form {} {
-	clear_nb
-	close_form
-}
-
-proc init_form {} {
-	global submit_result submit_msg
-	global frmid form_open encoding_val
-
-	toplevel .form
-
-	make_form
-
-	wm protocol .form WM_DELETE_WINDOW close_form
-
-	bind .form <Destroy> { if { "%W" == ".form"} { close_form } }
-
-	set submit_result ""
-	set submit_msg ""
-
-	set frmid 0
-	set form_open true
-
-	set encoding_val [exec g.gisenv GRASS_DB_ENCODING]
-	if {$encoding_val == ""} {
-		set encoding_val [encoding system]
-	}
-
-	if {[catch {encoding system $encoding_val}]} {
-		puts stderr "Could not set Tcl system encoding to $encoding_val"
-	}
-}
-

+ 0 - 253
vector/v.digit/generate.c

@@ -1,253 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/dbmi.h>
-#include <grass/form.h>
-
-/* Generate form in HTML/TXT format.
- *  Pointer to resulting string is stored to 'form'. This string must be freed by application.
- *
- *  returns: -1 error 
- *            0 success
- */
-int
-F_generate(char *drvname, char *dbname, char *tblname, char *key, int keyval,
-	   char *frmname, char *frmmapset,
-	   int edit_mode, int format, char **form)
-{
-    int col, ncols, ctype, sqltype, more;
-    char buf[5000], buf1[100];
-    const char *colname;
-    dbString sql, html, str;
-    dbDriver *driver;
-    dbHandle handle;
-    dbCursor cursor;
-    dbTable *table;
-    dbColumn *column;
-    dbValue *value;
-
-    int i = 0;
-
-    /* see /usr/lib/tcl8.4/encoding/ */
-    static char *encoding_list[] = {
-	"utf-8",
-	"ascii",
-	"iso8859-1",
-	"iso8859-2",
-	"iso8859-15",
-	"iso2022-jp",
-	"koi8-r",
-	"euc-jp",
-	NULL
-    };
-    const char *enc_env;
-
-    G__read_env();
-    enc_env = G__getenv("GRASS_DB_ENCODING");
-
-    /* TODO: support 'format' (txt, html), currently html only */
-
-    G_debug(2,
-	    "F_generate(): drvname = '%s', dbname = '%s'\n      tblname = '%s', key = '%s', keyval = %d\n"
-	    "    form = '%s', form_mapset = '%s'\n      edit_mode = %d",
-	    drvname, dbname, tblname, key, keyval, frmname, frmmapset,
-	    edit_mode);
-
-    db_init_string(&sql);
-    db_init_string(&html);	/* here is the result stored */
-    db_init_string(&str);
-
-    G_debug(2, "Open driver");
-    driver = db_start_driver(drvname);
-    if (driver == NULL) {
-	G_warning("Cannot open driver\n");
-	sprintf(buf, "Cannot open driver '%s'<BR>", drvname);
-	*form = G_store(buf);
-	return -1;
-    }
-    G_debug(2, "Driver opened");
-
-    db_init_handle(&handle);
-    db_set_handle(&handle, dbname, NULL);
-    G_debug(2, "Open database");
-    if (db_open_database(driver, &handle) != DB_OK) {
-	G_warning("Cannot open database\n");
-	db_shutdown_driver(driver);
-	sprintf(buf, "Cannot open database '%s' by driver '%s'<BR>", dbname,
-		drvname);
-	*form = G_store(buf);
-	return -1;
-    }
-    G_debug(2, "Database opened");
-
-    /* TODO: test if table exist first, but this should be tested by application befor
-     *        F_generate() is called, because it may be correct (connection defined in DB
-     *        but table does not exist) */
-
-    sprintf(buf, "select * from %s where %s = %d", tblname, key, keyval);
-    G_debug(2, "%s", buf);
-    db_set_string(&sql, buf);
-    if (db_open_select_cursor(driver, &sql, &cursor, DB_SEQUENTIAL) != DB_OK) {
-	G_warning("Cannot open select cursor\n");
-	db_close_database(driver);
-	db_shutdown_driver(driver);
-	sprintf(buf,
-		"Cannot open select cursor:<BR>'%s'<BR>on database '%s' by driver '%s'<BR>",
-		db_get_string(&sql), dbname, drvname);
-	*form = G_store(buf);
-	return -1;
-    }
-    G_debug(2, "Select Cursor opened");
-
-    table = db_get_cursor_table(&cursor);
-
-    if (db_fetch(&cursor, DB_NEXT, &more) != DB_OK) {
-	G_warning("Cannot fetch next record\n");
-	db_close_cursor(&cursor);
-	db_close_database(driver);
-	db_shutdown_driver(driver);
-	*form = G_store("Cannot fetch next record");
-	return -1;
-    }
-
-    if (!more) {
-	G_warning("No database record");
-	if (format == F_HTML) {
-	    *form = G_store("No record selected.<BR>");
-	}
-	else {
-	    *form = G_store("No record selected.");
-	}
-    }
-    else {
-	ncols = db_get_table_number_of_columns(table);
-
-	/* Start form */
-	if (format == F_HTML) {
-	    if (edit_mode == F_EDIT) {
-		db_append_string(&html, "<FORM>");
-
-		sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
-			F_DRIVER_FNAME, drvname);
-		db_append_string(&html, buf);
-		/* Note: because html_library.tcl failes to parse
-		 *  <INPUT name=abc value='dbname=xxx'> and returnes
-		 *  name="xxx" value="dbname=xxx" order of value and name parameters is changed */
-		sprintf(buf, "<INPUT type=hidden value=\"%s\" name=%s>",
-			dbname, F_DATABASE_FNAME);
-		db_append_string(&html, buf);
-		sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
-			F_TABLE_FNAME, tblname);
-		db_append_string(&html, buf);
-		sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
-			F_KEY_FNAME, key);
-		db_append_string(&html, buf);
-
-	    }
-
-	    for (col = 0; col < ncols; col++) {
-		column = db_get_table_column(table, col);
-		sqltype = db_get_column_sqltype(column);
-		ctype = db_sqltype_to_Ctype(sqltype);
-		value = db_get_column_value(column);
-		db_convert_value_to_string(value, sqltype, &str);
-		colname = db_get_column_name(column);
-
-		G_debug(2, "%s: %s", colname, db_get_string(&str));
-
-		if (edit_mode == F_VIEW) {
-		    sprintf(buf, "<B>%s : </B> %s <BR>", colname,
-			    db_get_string(&str));
-		    db_append_string(&html, buf);
-		}
-		else {
-		    sprintf(buf, "<B>%s : </B>", colname);
-		    db_append_string(&html, buf);
-
-		    if (G_strcasecmp(colname, key) == 0) {
-			sprintf(buf,
-				"%s<BR> <INPUT type=hidden name=%s value=\"%s\">",
-				db_get_string(&str), colname,
-				db_get_string(&str));
-		    }
-		    else {
-			switch (ctype) {
-			case DB_C_TYPE_INT:
-			    sprintf(buf1, "20");
-			    break;
-			case DB_C_TYPE_DOUBLE:
-			    sprintf(buf1, "30");
-			    break;
-			case DB_C_TYPE_STRING:
-			    sprintf(buf1, "%d", db_get_column_length(column));
-			    break;
-			case DB_C_TYPE_DATETIME:
-			    sprintf(buf1, "20");
-			    break;
-			}
-			sprintf(buf,
-				"<INPUT type=text size=%s name=%s value=\"%s\"><BR>",
-				buf1, colname, db_get_string(&str));
-		    }
-		    db_append_string(&html, buf);
-		}
-	    }
-
-	    if (edit_mode == F_EDIT) {
-		sprintf(buf,
-			"<HR>   Assume data encoding as:<BR><BR><SELECT NAME=%s SIZE=4><HR><BR>",
-			F_ENCODING);
-		db_append_string(&html, buf);
-
-		i = 0;
-		while (encoding_list[i] != NULL) {
-
-		    if (G_strcasecmp(encoding_list[i], enc_env) == 0)
-			sprintf(buf, "<OPTION VALUE=\"%s\" SELECTED>%s",
-				encoding_list[i], encoding_list[i]);
-		    else
-			sprintf(buf, "<OPTION VALUE=\"%s\">%s",
-				encoding_list[i], encoding_list[i]);
-		    ++i;
-		    db_append_string(&html, buf);
-		}
-
-		sprintf(buf, "</SELECT>");
-		db_append_string(&html, buf);
-	    }
-
-	    /* Close form */
-	    if (edit_mode == F_EDIT) {
-		db_append_string(&html, "</FORM>");
-	    }
-	}
-	else {			/* F_TXT */
-	    for (col = 0; col < ncols; col++) {
-		column = db_get_table_column(table, col);
-		sqltype = db_get_column_sqltype(column);
-		ctype = db_sqltype_to_Ctype(sqltype);
-		value = db_get_column_value(column);
-		db_convert_value_to_string(value, sqltype, &str);
-		colname = db_get_column_name(column);
-
-		G_debug(2, "%s: %s", colname, db_get_string(&str));
-
-		sprintf(buf, "%s : %s\n", colname, db_get_string(&str));
-		db_append_string(&html, buf);
-	    }
-	}
-    }
-    G_debug(2, "FORM STRING:\n%s\n", db_get_string(&html));
-
-    db_close_cursor(&cursor);
-    db_close_database(driver);
-    db_shutdown_driver(driver);
-
-    *form = G_store(db_get_string(&html));
-
-    db_free_string(&sql);
-    db_free_string(&html);
-    db_free_string(&str);
-
-    return 0;
-}

+ 0 - 160
vector/v.digit/global.h

@@ -1,160 +0,0 @@
-#include <tcl.h>
-#include <tk.h>
-#include <grass/Vect.h>
-
-/*      tool in c:         name in Tk */
-typedef enum
-{
-    TOOL_NOTHING,
-    TOOL_EXIT,
-    TOOL_NEW_POINT,
-    TOOL_NEW_LINE,
-    TOOL_NEW_BOUNDARY,
-    TOOL_NEW_CENTROID,
-    TOOL_MOVE_VERTEX,
-    TOOL_ADD_VERTEX,		/* add vertex on line */
-    TOOL_RM_VERTEX,		/* remove vertex from line */
-    TOOL_SPLIT_LINE,
-    TOOL_EDIT_LINE,		/* continue editing a line or boundary */
-    TOOL_MOVE_LINE,
-    TOOL_DELETE_LINE,
-    TOOL_DISPLAY_CATS,
-    TOOL_COPY_CATS,
-    TOOL_DISPLAY_ATTRIBUTES,
-    TOOL_ZOOM_WINDOW,		/* zoom by window */
-    TOOL_ZOOM_OUT_CENTRE,
-    TOOL_ZOOM_PAN,
-    TOOL_ZOOM_DEFAULT,
-    TOOL_ZOOM_REGION,
-    TOOL_REDRAW,
-    TOOL_DISPLAY_SETTINGS
-} ToolNumber;
-
-/* Xdriver coordinate value considered to bu null */
-#define COOR_NULL PORT_INT_MAX
-
-/* SYMBOLOGY */
-typedef enum
-{
-    SYMB_DEFAULT,		/* line color acording to real line/node type from Line/NodeSymb */
-    SYMB_BACKGROUND,
-    SYMB_HIGHLIGHT,
-    SYMB_POINT,
-    SYMB_LINE,
-    SYMB_BOUNDARY_0,		/* No areas */
-    SYMB_BOUNDARY_1,		/* 1 area */
-    SYMB_BOUNDARY_2,		/* 2 areas */
-    SYMB_CENTROID_IN,		/* Centroid in area */
-    SYMB_CENTROID_OUT,		/* Centroid outside area */
-    SYMB_CENTROID_DUPL,		/* Duplicate centroid in area */
-    SYMB_NODE_0,		/* Node without lines (points or centroids) */
-    SYMB_NODE_1,		/* Node with 1 line */
-    SYMB_NODE_2,		/* Node with 2 lines */
-    SYMB_COUNT			/* MUST BE LAST, number of symbology layers */
-} SymbNumber;
-
-typedef struct
-{
-    int on;			/* 1 - on, 0 - off */
-    int r, g, b;		/* color 0-255 */
-} SYMB;
-
-/* Message type */
-#define MSG_OK 0
-#define MSG_YESNO 1
-
-/* Message icon */
-#define MSGI_ERROR 0
-#define MSGI_QUESTION 1
-
-/* Snapping modes */
-#define SNAP_SCREEN 0		/* Snap in screen pixels */
-#define SNAP_MAP    1		/* Snap in map units */
-
-/* Variables */
-#define VART_INT    0
-#define VART_DOUBLE 1
-#define VART_CHAR   2
-
-typedef struct
-{
-    int code;
-    char *name;
-    int type;
-    int i;
-    double d;
-    char *c;
-} VAR;
-
-#define VAR_CAT       0		/* category for next line */
-#define VARN_CAT      "cat"
-#define VAR_FIELD     1
-#define VARN_FIELD    "field"	/* field for next line */
-#define VAR_CAT_MODE  2
-#define VARN_CAT_MODE "cat_mode"	/* mode of cat imput */
-#define VAR_INSERT    3
-#define VARN_INSERT   "insert"	/* insert new row to table for next line (1) or not (0) */
-#define VAR_MESSAGE   4
-#define VARN_MESSAGE  "message"	/* text of message to be displayed in popup window */
-#define VAR_SNAP      5
-#define VARN_SNAP     "snap"	/* If to snap to nearest node (1) or not (0) */
-#define VAR_SNAP_MODE    6
-#define VARN_SNAP_MODE   "snap_mode"	/* Snapping mode (screen pixels / map units) */
-#define VAR_SNAP_SCREEN  7
-#define VARN_SNAP_SCREEN "snap_screen"	/* Snapping threshold in screen pixels */
-#define VAR_SNAP_MAP     8
-#define VARN_SNAP_MAP    "snap_map"	/* Snapping threshold in map units */
-#define VAR_ZOOM_REGION  9
-#define VARN_ZOOM_REGION "zoom_region"	/* Name of region to zoom in */
-#define VAR_ANSWER      10
-#define VARN_ANSWER      "answer"	/* Answer from dialog */
-#define VAR_LINEWIDTH   11
-#define VARN_LINEWIDTH   "linewidth"	/* Width for lines and boundaries */
-
-extern VAR Variable[];
-
-/* Category and field set for current line to be written */
-#define CAT_MODE_NO   0		/* No category */
-#define CAT_MODE_MAN  1		/* Manual imput */
-#define CAT_MODE_NEXT 2		/* Next not yet used category of given field */
-#define CAT_MODE_COUNT 3	/* Count of modes */
-
-extern char *CatModeLab[];
-
-/* Maximum value for field */
-extern int (*MaxFieldCat)[2];
-extern int nMaxFieldCat, aMaxFieldCat;
-
-extern SYMB Symb[SYMB_COUNT];
-
-extern struct Map_info Map;
-extern struct Cell_head GRegion;	/* Current region (synchronized with GRASS WIND) */
-extern Tcl_Interp *Toolbox;
-extern int Tool_next;		/* Next tool to be run */
-extern double Xscale, Yscale;	/* Scale factors = size_in_map / size_on_screen */
-
-extern struct Cell_head window;
-
-extern double Scale;		/* Map / xdriver */
-
-
-/* Display symbology for lines and nodes */
-extern int *LineSymb;		/* array of line symbology codes, starts from index 1 */
-extern int aLineSymb;		/* number of lines / allocated space (array size + 1) */
-extern int *NodeSymb;		/* array of nodes' symbology codes, start from index 1 */
-extern int aNodeSymb;		/* number of nodes / allocated space (array size + 1) */
-
-/* Background commands */
-typedef struct
-{
-    char *cmd;			/* command */
-    int on;			/* 1 display, 0 do not display */
-} BGCMD;
-
-extern BGCMD *Bgcmd;
-extern int nbgcmd;
-extern int abgcmd;
-
-#define MOUSE_POINT	1
-#define MOUSE_LINE	2
-#define MOUSE_BOX	3

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 1423
vector/v.digit/html_library.tcl


+ 0 - 249
vector/v.digit/i_face.c

@@ -1,249 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <tcl.h>
-#include <tk.h>
-#include <grass/gis.h>
-#include <grass/raster.h>
-#include <grass/Vect.h>
-#include "global.h"
-#include "proto.h"
-
-/* Interface functions between GUI and C:
- *  i_*() functions in GUI,  called from C 
- */
-
-/* Set GUI promt to given string */
-int i_prompt(char *str)
-{
-    Tcl_SetVar(Toolbox, "prompt", str, TCL_GLOBAL_ONLY);
-    return 1;
-}
-
-/* Set GUI promt to given string */
-int i_prompt_buttons(char *l, char *m, char *r)
-{
-    Tcl_SetVar(Toolbox, "prompt_left", l, TCL_GLOBAL_ONLY);
-    Tcl_SetVar(Toolbox, "prompt_middle", m, TCL_GLOBAL_ONLY);
-    Tcl_SetVar(Toolbox, "prompt_right", r, TCL_GLOBAL_ONLY);
-    return 1;
-}
-
-/* Set GUI coordinates to given values */
-int i_coor(double x, double y)
-{
-    char buf[100];
-
-    if (x == COOR_NULL || y == COOR_NULL)
-	buf[0] = '\0';
-    else
-	sprintf(buf, "%.2f, %.2f", x, y);
-
-    Tcl_SetVar(Toolbox, "coor", buf, TCL_GLOBAL_ONLY);
-    return 1;
-}
-
-/* Set symbology color */
-int i_set_color(char *name, int r, int g, int b)
-{
-    char var[50], col[20];
-
-    G_debug(2, "i_set_color(): %s : %d %d %d", name, r, g, b);
-
-    sprintf(col, "#%02x%02x%02x", r, g, b);
-
-    G_debug(2, " -> color = %s", col);
-
-    sprintf(var, "symb(%s,color)", name);
-    Tcl_SetVar(Toolbox, var, col, TCL_GLOBAL_ONLY);
-
-    return 1;
-}
-
-/* Set symbology on/off */
-int i_set_on(char *name, int on)
-{
-    char var[50], val[20];
-
-    G_debug(2, "i_set_on(): %s : %d", name, on);
-
-    sprintf(var, "symb(%s,on)", name);
-    sprintf(val, "%d", on);
-    Tcl_SetVar(Toolbox, var, val, TCL_GLOBAL_ONLY);
-
-    return 1;
-}
-
-/* create: 1 - create, 0 - destroy */
-void i_new_line_options(int create)
-{
-    int i;
-    char val[1000];
-
-    G_debug(4, "i_new_line_options(), create = %d", create);
-
-    if (create) {
-	Tcl_Eval(Toolbox, "new_line_options 1");
-
-	/* Set cat mode */
-	sprintf(val, "$GWidget(cat_mode) configure -values [list");
-	for (i = 0; i < CAT_MODE_COUNT; i++) {
-	    sprintf(val, "%s \"%s\"", val, CatModeLab[i]);
-	}
-	sprintf(val, "%s]", val);
-
-	G_debug(2, "Cat modes: %s", val);
-	Tcl_Eval(Toolbox, val);
-
-	sprintf(val, "$GWidget(cat_mode) setvalue @%d",
-		var_geti(VAR_CAT_MODE));
-	G_debug(2, "Cat mode: %s", val);
-	Tcl_Eval(Toolbox, val);
-    }
-    else {
-	Tcl_Eval(Toolbox, "new_line_options 0");
-    }
-
-    sprintf(val, "%d", var_geti(VAR_FIELD));
-    Tcl_SetVar(Toolbox, "field", val, TCL_GLOBAL_ONLY);
-    i_set_cat_mode();
-}
-
-/* set category options */
-void i_set_cat_mode(void)
-{
-
-    G_debug(5, "i_set_cat_mode");
-
-    if (var_geti(VAR_CAT_MODE) == CAT_MODE_NO) {
-	Tcl_Eval(Toolbox, "$GWidget(field) configure -state disabled");
-    }
-    else {
-	Tcl_Eval(Toolbox, "$GWidget(field) configure -state normal");
-    }
-
-    if (var_geti(VAR_CAT_MODE) == CAT_MODE_MAN) {
-	Tcl_Eval(Toolbox, "$GWidget(cat) configure -state normal");
-    }
-    else {
-	Tcl_Eval(Toolbox, "$GWidget(cat) configure -state disabled");
-    }
-}
-
-/* set variable */
-void i_var_seti(int code, int i)
-{
-    char cmd[100], *name;
-
-    G_debug(5, "i_var_seti()");
-
-    name = var_get_name_by_code(code);
-    sprintf(cmd, "set GVariable(%s) %d", name, i);
-    G_debug(5, "cmd: %s", cmd);
-    Tcl_Eval(Toolbox, cmd);
-}
-
-/* set variable */
-void i_var_setd(int code, double d)
-{
-    char cmd[100], *name;
-
-    G_debug(5, "i_var_seti");
-
-    name = var_get_name_by_code(code);
-    sprintf(cmd, "set GVariable(%s) %f", name, d);
-    G_debug(5, "cmd: %s", cmd);
-    Tcl_Eval(Toolbox, cmd);
-}
-
-/* set variable */
-void i_var_setc(int code, char *c)
-{
-    char cmd[100], *name;
-
-    G_debug(5, "i_var_seti");
-
-    name = var_get_name_by_code(code);
-
-    Tcl_SetVar(Toolbox, "tmp", c, TCL_GLOBAL_ONLY);
-
-    sprintf(cmd, "set GVariable(%s) $tmp", name);
-    G_debug(5, "cmd: %s", cmd);
-    Tcl_Eval(Toolbox, cmd);
-}
-
-/* open GUI window with message */
-int i_message(int type, int icon, char *msg)
-{
-    int answer;
-    char *tp = "ok", *ico = "error", buf[1000];
-
-    G_debug(5, "i_message()");
-
-    switch (type) {
-    case MSG_OK:
-	tp = "ok";
-	break;
-    case MSG_YESNO:
-	tp = "yesno";
-	break;
-    }
-    switch (icon) {
-    case MSGI_ERROR:
-	ico = "error";
-	break;
-    case MSGI_QUESTION:
-	ico = "question";
-	break;
-    }
-
-    var_setc(VAR_MESSAGE, msg);
-    sprintf(buf,
-	    "set GVariable(answer) [MessageDlg .msg -type %s -icon %s -message $GVariable(message)]",
-	    tp, ico);
-    Tcl_Eval(Toolbox, buf);
-
-    sprintf(buf, "c_var_set answer $GVariable(answer)");
-    Tcl_Eval(Toolbox, buf);
-
-    answer = var_geti(VAR_ANSWER);
-    G_debug(4, "answer = %d", answer);
-
-    return answer;
-}
-
-/* add background command */
-void i_add_bgcmd(int index)
-{
-    char cmd[2000];
-
-    G_debug(3, "i_add_bgcmd()");
-
-    sprintf(cmd, "set GBgcmd(%d,on) %d", index, Bgcmd[index].on);
-    Tcl_Eval(Toolbox, cmd);
-
-    sprintf(cmd, "GBgcmd(%d,cmd)", index);
-    Tcl_SetVar(Toolbox, cmd, Bgcmd[index].cmd, TCL_GLOBAL_ONLY);
-
-    sprintf(cmd, "set row [ frame $GWidget(bgcmd).row%d ]", index);
-    Tcl_Eval(Toolbox, cmd);
-
-    sprintf(cmd, "checkbutton $row.a -variable GBgcmd(%d,on) -height 1 "
-	    "-command { c_set_bgcmd %d $GBgcmd(%d,on) $GBgcmd(%d,cmd) }",
-	    index, index, index, index);
-    Tcl_Eval(Toolbox, cmd);
-
-    sprintf(cmd, "Entry $row.b -width 40 -textvariable GBgcmd(%d,cmd) "
-	    "-command { c_set_bgcmd %d $GBgcmd(%d,on) $GBgcmd(%d,cmd) }",
-	    index, index, index, index);
-    Tcl_Eval(Toolbox, cmd);
-
-    Tcl_Eval(Toolbox, "pack $row.a $row.b -side left;");
-
-    Tcl_Eval(Toolbox, "pack $row -side top -fill x -expand no -anchor n");
-
-    sprintf(cmd, "bind $GWidget(bgcmd).row%d.b <KeyRelease> "
-	    " { c_set_bgcmd %d $GBgcmd(%d,on) $GBgcmd(%d,cmd) }",
-	    index, index, index, index);
-    Tcl_Eval(Toolbox, cmd);
-}

+ 0 - 31
vector/v.digit/license.terms

@@ -1,31 +0,0 @@
-Sun Microsystems, Inc.  The following terms apply to all files
-associated with the software unless explicitly disclaimed in individual
-files.
-
-The authors hereby grant permission to use, copy, modify, distribute,
-and license this software and its documentation for any purpose, provided
-that existing copyright notices are retained in all copies and that this
-notice is included verbatim in any distributions. No written agreement,
-license, or royalty fee is required for any of the authorized uses.
-Modifications to this software may be copyrighted by their authors
-and need not follow the licensing terms described here, provided that
-the new terms are clearly indicated on the first page of each file where
-they apply.
-
-IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
-FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
-ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
-DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
-IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
-NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
-MODIFICATIONS.
-
-RESTRICTED RIGHTS: Use, duplication or disclosure by the government
-is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
-of the Rights in Technical Data and Computer Software Clause as DFARS
-252.227-7013 and FAR 52.227-19.

+ 0 - 718
vector/v.digit/line.c

@@ -1,718 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <math.h>
-#include <grass/gis.h>
-#include <grass/Vect.h>
-#include <grass/dbmi.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include <grass/colors.h>
-#include <grass/form.h>
-#include "global.h"
-#include "proto.h"
-
-int write_line(struct Map_info *Map, int type, struct line_pnts *Points)
-{
-    int i, field, cat, ret;
-    static int first_form = 1;
-    char *form;
-    struct line_cats *Cats;
-    struct field_info *Fi;
-    dbString html;
-
-    Cats = Vect_new_cats_struct();
-    db_init_string(&html);
-
-    cat = var_geti(VAR_CAT);
-    if (var_geti(VAR_CAT_MODE) != CAT_MODE_NO && cat > 0 &&
-	var_geti(VAR_FIELD) > 0) {
-	Vect_cat_set(Cats, var_geti(VAR_FIELD), cat);
-
-	G_debug(2, "write field = %d cat = %d", var_geti(VAR_FIELD),
-		var_geti(VAR_CAT));
-
-	if (cat_max_get(var_geti(VAR_FIELD)) < var_geti(VAR_CAT)) {
-	    cat_max_set(var_geti(VAR_FIELD), var_geti(VAR_CAT));
-	}
-    }
-
-    ret = Vect_write_line(Map, type, Points, Cats);
-
-    for (i = 0; i < Vect_get_num_updated_lines(Map); i++)
-	G_debug(2, "Updated line: %d", Vect_get_updated_line(Map, i));
-
-    for (i = 0; i < Vect_get_num_updated_nodes(Map); i++)
-	G_debug(2, "Updated node: %d", Vect_get_updated_node(Map, i));
-
-    /* Reset category (this automaticaly resets cat for next not used) */
-    var_seti(VAR_FIELD, var_geti(VAR_FIELD));
-
-    if (var_geti(VAR_CAT_MODE) != CAT_MODE_NO && var_geti(VAR_INSERT) &&
-	cat > 0) {
-	G_debug(2, "Insert new record");
-	db_set_string(&html, "<HTML><HEAD><TITLE>Form</TITLE><BODY>");
-
-	field = var_geti(VAR_FIELD);
-	ret = new_record(field, cat);
-	if (ret == -1) {
-	    return -1;
-	}
-	else if (ret == 0) {
-	    db_append_string(&html, "New record was created.<BR>");
-	}
-	else {			/* record already existed */
-	    db_append_string(&html,
-			     "Record for this category already existed.<BR>");
-	}
-
-	/* Open form */
-	Fi = Vect_get_field(Map, field);
-	if (Fi == NULL) {
-	    return -1;
-	}
-	F_generate(Fi->driver, Fi->database, Fi->table, Fi->key, cat, NULL,
-		   NULL, F_EDIT, F_HTML, &form);
-	db_append_string(&html, form);
-	db_append_string(&html, "</BODY></HTML>");
-
-	/* Note: F_open() must be run first time with closed monitor, otherwise next
-	 *        attempt to open driver hangs until form child process is killed */
-	if (first_form)
-	    driver_close();
-	F_clear();
-	F_open("Attributes", db_get_string(&html));
-	if (first_form) {
-	    driver_open();
-	    first_form = 0;
-	}
-
-	G_free(form);
-	db_free_string(&html);
-
-    }
-
-    return 0;
-}
-
-/* Snap to node */
-int snap(double *x, double *y)
-{
-    int node;
-    double thresh;
-
-    G_debug(2, "snap(): x = %f, y = %f", *x, *y);
-
-    thresh = get_thresh();
-
-    node = Vect_find_node(&Map, *x, *y, 0, thresh, 0);
-
-    if (node > 0)
-	Vect_get_node_coor(&Map, node, x, y, NULL);
-
-    G_debug(2, "node = %d x = %f, y = %f", node, *x, *y);
-    return node;
-}
-
-/* Digitize new line */
-struct new_line
-{
-    int type;
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int first;
-};
-
-int new_line_begin(void *closure)
-{
-    struct new_line *nl = closure;
-    char buf[1000];
-
-    G_debug(2, "new_line(): type = %d", nl->type);
-
-    nl->Points = Vect_new_line_struct();
-    nl->Cats = Vect_new_cats_struct();
-
-    sprintf(buf, "Digitize new %s:", get_line_type_name(nl->type));
-    i_prompt(buf);
-    i_prompt_buttons("New point", "", "Quit tool");
-
-    i_new_line_options(1);
-
-    nl->first = 1;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int new_line_update(void *closure, int sxn, int syn, int button)
-{
-    struct new_line *nl = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    if (nl->first && button == 3) {	/* Quit tool ( points & lines ), first is always for points */
-	Tool_next = TOOL_NOTHING;
-	return 1;
-    }
-
-    if (nl->type & GV_POINTS) {
-	/* We can get here with button = 1 or 2 -> the same write point */
-	snap(&x, &y);
-	Vect_append_point(nl->Points, x, y, 0);
-
-	write_line(&Map, nl->type, nl->Points);
-	updated_lines_and_nodes_erase_refresh_display();
-	return 1;
-    }
-    else {			/* GV_LINES */
-	/* Button may be 1,2,3 */
-	if (button == 1) {	/* New point */
-	    snap(&x, &y);
-	    Vect_append_point(nl->Points, x, y, 0);
-
-	    if (nl->type == GV_LINE)
-		symb_set_driver_color(SYMB_LINE);
-	    else
-		symb_set_driver_color(SYMB_BOUNDARY_0);
-
-	    display_points(nl->Points, 1);
-	    set_location(D_u_to_d_col(x), D_u_to_d_row(y));
-	    nl->first = 0;
-	    set_mode(MOUSE_LINE);
-	}
-	else if (button == 2) {	/* Undo last point */
-	    if (nl->Points->n_points >= 1) {
-		symb_set_driver_color(SYMB_BACKGROUND);
-		display_points(nl->Points, 1);
-		nl->Points->n_points--;
-
-		if (nl->type == GV_LINE)
-		    symb_set_driver_color(SYMB_LINE);
-		else
-		    symb_set_driver_color(SYMB_BOUNDARY_0);
-
-		display_points(nl->Points, 1);
-		set_location(D_u_to_d_col
-			     (nl->Points->x[nl->Points->n_points - 1]),
-			     D_u_to_d_row(nl->Points->
-					  y[nl->Points->n_points - 1])
-		    );
-	    }
-	    if (nl->Points->n_points == 0) {
-		i_prompt_buttons("New point", "", "Quit tool");
-		nl->first = 1;
-		set_mode(MOUSE_POINT);
-	    }
-	}
-	else {			/* button = 3 -> write the line and quit */
-	    if (nl->Points->n_points > 1) {
-		/* Before the line is written, we must check if connected to existing nodes, if yes,
-		 * such nodes must be add to update list before! the line is written (areas/isles */
-		int node1 =
-		    Vect_find_node(&Map, nl->Points->x[0], nl->Points->y[0],
-				   nl->Points->z[0], 0, Vect_is_3d(&Map));
-		int i = nl->Points->n_points - 1;
-		int node2 =
-		    Vect_find_node(&Map, nl->Points->x[i], nl->Points->y[i],
-				   nl->Points->z[i], 0, Vect_is_3d(&Map));
-
-		G_debug(2, "  old node1 = %d  old node2 = %d", node1, node2);
-		write_line(&Map, nl->type, nl->Points);
-		updated_lines_and_nodes_erase_refresh_display();
-	    }
-	    else
-		G_warning("Less than 2 points for line -> nothing written");
-
-	    return 1;
-	}
-	G_debug(2, "n_points = %d", nl->Points->n_points);
-    }
-
-    i_prompt_buttons("New point", "Undo last point", "Close line");
-    return 0;
-}
-
-int new_line_end(void *closure)
-{
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-    i_new_line_options(0);
-
-    G_debug(3, "new_line(): End");
-    return 1;
-}
-
-void new_line(int type)
-{
-    static struct new_line nl;
-
-    nl.type = type;
-
-    set_tool(new_line_begin, new_line_update, new_line_end, &nl);
-}
-
-/* Continue work on the end of a line */
-
-struct edit_line
-{
-    int phase;
-    double thresh;
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int line;
-    int line_type;
-    int reversed;
-};
-
-int edit_line_begin(void *closure)
-{
-    struct edit_line *el = closure;
-
-    G_debug(2, "edit_line()");
-
-    i_prompt("Edit line or boundary:");
-    i_prompt_buttons("Select", "", "Quit tool");
-
-    el->thresh = get_thresh();
-    G_debug(2, "thresh = %f", el->thresh);
-
-    el->phase = 1;
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-void edit_line_phase2(struct edit_line *el, double x, double y)
-{
-    int node1, node2;
-    double nodex, nodey, nodez, dist;
-
-    el->phase = 2;
-
-    el->Points = Vect_new_line_struct();
-    el->Cats = Vect_new_cats_struct();
-    el->line_type = Vect_read_line(&Map, el->Points, el->Cats, el->line);
-
-    el->reversed = 0;
-
-    /* Find out the node nearest to the line */
-    Vect_get_line_nodes(&Map, el->line, &node1, &node2);
-
-    Vect_get_node_coor(&Map, node2, &nodex, &nodey, &nodez);
-    dist = (x - nodex) * (x - nodex) + (y - nodey) * (y - nodey);
-
-    Vect_get_node_coor(&Map, node1, &nodex, &nodey, &nodez);
-    if ((x - nodex) * (x - nodex) + (y - nodey) * (y - nodey) < dist) {
-	/* The first node is the nearest => reverse the line and remember
-	 * doing so. */
-	Vect_line_reverse(el->Points);
-	el->reversed = 1;
-    }
-
-    display_node(node1, SYMB_BACKGROUND, 1);
-    display_node(node2, SYMB_BACKGROUND, 1);
-    i_prompt_buttons("New Point", "Undo Last Point", "Close line");
-
-    set_location(D_u_to_d_col(el->Points->x[el->Points->n_points - 1]),
-		 D_u_to_d_row(el->Points->y[el->Points->n_points - 1])
-	);
-    set_mode(MOUSE_LINE);
-}
-
-int edit_line_update(void *closure, int sxn, int syn, int button)
-{
-    struct edit_line *el = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    if (button == 3)		/* Tool broken by GUI */
-	return 1;
-
-    switch (el->phase) {
-    case 1:
-	if (button != 1)
-	    return 0;
-
-	/* Find nearest point or line */
-	el->line =
-	    Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY, el->thresh,
-			   0, 0);
-	G_debug(2, "line found = %d", el->line);
-
-	/* Display new selected line if any */
-	if (el->line > 0) {
-	    display_line(el->line, SYMB_HIGHLIGHT, 1);
-	    edit_line_phase2(el, x, y);
-	}
-	break;
-
-    case 2:
-	if (button == 1) {	/* New point */
-	    snap(&x, &y);
-	    Vect_append_point(el->Points, x, y, 0);
-
-	    if (el->line_type == GV_LINE)
-		symb_set_driver_color(SYMB_LINE);
-	    else
-		symb_set_driver_color(SYMB_BOUNDARY_0);
-
-	    display_points(el->Points, 1);
-	    set_location(sxn, syn);
-	    i_prompt_buttons("New Point", "Undo Last Point", "Close line");
-	}
-	else if (button == 2) {	/* Undo last point */
-	    if (el->Points->n_points > 1) {
-		symb_set_driver_color(SYMB_BACKGROUND);
-		display_points(el->Points, 1);
-
-		el->Points->n_points--;
-
-		if (el->line_type == GV_LINE)
-		    symb_set_driver_color(SYMB_LINE);
-		else
-		    symb_set_driver_color(SYMB_BOUNDARY_0);
-
-		display_points(el->Points, 1);
-		set_location(D_u_to_d_col
-			     (el->Points->x[el->Points->n_points - 1]),
-			     D_u_to_d_row(el->Points->
-					  y[el->Points->n_points - 1])
-		    );
-		if (el->Points->n_points == 1)
-		    i_prompt_buttons("New Point", "", "Delete line and exit");
-	    }
-	}
-	break;
-    }
-
-    return 0;
-}
-
-int edit_line_end(void *closure)
-{
-    struct edit_line *el = closure;
-
-    if (el->phase > 1) {
-	if (el->reversed)
-	    Vect_line_reverse(el->Points);
-
-	if (el->Points->n_points > 1) {
-	    Vect_rewrite_line(&Map, el->line, el->line_type, el->Points,
-			      el->Cats);
-	    updated_lines_and_nodes_erase_refresh_display();
-	}
-	else {
-	    int i;
-
-	    /* delete lines with less than two points */
-	    Vect_delete_line(&Map, el->line);
-	    for (i = 0; i < el->Cats->n_cats; i++) {
-		check_record(el->Cats->field[i], el->Cats->cat[i]);
-	    }
-	}
-
-
-	Vect_destroy_line_struct(el->Points);
-	Vect_destroy_cats_struct(el->Cats);
-    }
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "edit_line(): End");
-
-    return 1;
-}
-
-void edit_line(void)
-{
-    static struct edit_line el;
-
-    set_tool(edit_line_begin, edit_line_update, edit_line_end, &el);
-}
-
-/* Delete line */
-struct delete_line
-{
-    double thresh;
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int first;
-    int line;
-    int last_line;
-};
-
-int delete_line_begin(void *closure)
-{
-    struct delete_line *dl = closure;
-
-    G_debug(2, "delete_line()");
-
-    dl->Points = Vect_new_line_struct();
-    dl->Cats = Vect_new_cats_struct();
-
-    i_prompt("Delete point, line, boundary, or centroid:");
-    i_prompt_buttons("Select", "Unselect", "Quit tool");
-
-    dl->thresh = get_thresh();
-    G_debug(2, "thresh = %f", dl->thresh);
-
-    dl->line = 0;
-    dl->first = 1;
-    dl->last_line = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int delete_line_update(void *closure, int sxn, int syn, int button)
-{
-    struct delete_line *dl = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    /* Display last highlighted in normal color */
-    if (dl->last_line > 0) {
-	display_line(dl->last_line, SYMB_DEFAULT, 1);
-    }
-
-    if (button == 3)		/* Quit tool */
-	return 1;
-
-    if (button == 1) {		/* Confirm / select */
-	/* Delete last if any */
-	if (dl->last_line > 0) {
-	    int node1, node2;
-	    int i;
-
-	    /* Erase line and nodes !!! (because if the line is not connected to any other, nodes will die */
-	    display_line(dl->last_line, SYMB_BACKGROUND, 1);
-	    Vect_get_line_nodes(&Map, dl->line, &node1, &node2);
-	    G_debug(2, "delete line = %d node1 = %d node2 = %d",
-		    dl->last_line, node1, node2);
-
-	    display_node(node1, SYMB_BACKGROUND, 1);
-	    display_node(node2, SYMB_BACKGROUND, 1);
-
-	    Vect_read_line(&Map, NULL, dl->Cats, dl->last_line);
-	    Vect_delete_line(&Map, dl->last_line);
-	    for (i = 0; i < dl->Cats->n_cats; i++) {
-		check_record(dl->Cats->field[i], dl->Cats->cat[i]);
-	    }
-
-	    for (i = 0; i < Vect_get_num_updated_lines(&Map); i++)
-		G_debug(2, "Updated line: %d",
-			Vect_get_updated_line(&Map, i));
-
-	    for (i = 0; i < Vect_get_num_updated_nodes(&Map); i++)
-		G_debug(2, "Updated node: %d",
-			Vect_get_updated_node(&Map, i));
-
-	    updated_lines_and_nodes_erase_refresh_display();
-	}
-
-	/* Find neares point or line */
-	dl->line =
-	    Vect_find_line(&Map, x, y, 0, GV_POINT | GV_CENTROID, dl->thresh,
-			   0, 0);
-	G_debug(2, "point found = %d", dl->line);
-	if (dl->line == 0)
-	    dl->line =
-		Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY,
-			       dl->thresh, 0, 0);
-	G_debug(2, "line found = %d", dl->line);
-
-	/* Display new selected line if any */
-	if (dl->line > 0) {
-	    display_line(dl->line, SYMB_HIGHLIGHT, 1);
-	}
-    }
-    else {			/* button == 2 -> unselect */
-	dl->line = 0;
-    }
-
-    if (dl->line > 0)
-	i_prompt_buttons("Confirm and select next", "Unselect", "Quit tool");
-    else
-	i_prompt_buttons("Select", "Unselect", "Quit tool");
-
-    dl->last_line = dl->line;
-    dl->first = 0;
-
-    return 0;
-}
-
-int delete_line_end(void *closure)
-{
-    struct delete_line *dl = closure;
-
-    /* Display last highlighted in normal color */
-    if (dl->last_line > 0) {
-	display_line(dl->last_line, SYMB_DEFAULT, 1);
-    }
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "delete_line(): End");
-
-    return 1;
-}
-
-void delete_line(void)
-{
-    static struct delete_line dl;
-
-    set_tool(delete_line_begin, delete_line_update, delete_line_end, &dl);
-}
-
-/* Move line */
-struct move_line
-{
-    double thresh;
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int line;
-    int last_line;
-    double xo, yo;
-};
-
-int move_line_begin(void *closure)
-{
-    struct move_line *ml = closure;
-
-    G_debug(2, "move_line()");
-
-    ml->Points = Vect_new_line_struct();
-    ml->Cats = Vect_new_cats_struct();
-
-    i_prompt("Move point, line, boundary, or centroid:");
-    i_prompt_buttons("Select", "", "Quit tool");
-
-    ml->thresh = get_thresh();
-    G_debug(2, "thresh = %f", ml->thresh);
-
-    ml->last_line = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int move_line_update(void *closure, int sxn, int syn, int button)
-{
-    struct move_line *ml = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    if (ml->last_line > 0) {
-	display_line(ml->last_line, SYMB_DEFAULT, 1);
-    }
-
-    if (button == 3)
-	return 1;
-
-    if (button == 1) {		/* Select / new location */
-	int type;
-
-	if (ml->last_line == 0) {	/* Select line */
-	    ml->line =
-		Vect_find_line(&Map, x, y, 0, GV_POINT | GV_CENTROID,
-			       ml->thresh, 0, 0);
-	    G_debug(2, "point found = %d", ml->line);
-	    if (ml->line == 0)
-		ml->line =
-		    Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY,
-				   ml->thresh, 0, 0);
-	    G_debug(2, "line found = %d", ml->line);
-
-	    /* Display new selected line if any */
-	    if (ml->line > 0) {
-		display_line(ml->line, SYMB_HIGHLIGHT, 1);
-
-		/* Find the nearest point on the line */
-		type = Vect_read_line(&Map, ml->Points, NULL, ml->line);
-		Vect_line_distance(ml->Points, x, y, 0, 0, &ml->xo, &ml->yo,
-				   NULL, NULL, NULL, NULL);
-		set_location(D_u_to_d_col(ml->xo), D_u_to_d_row(ml->yo));
-
-		i_prompt_buttons("New location", "Unselect", "Quit tool");
-	    }
-	    ml->last_line = ml->line;
-	}
-	else {			/* Line is already selected */
-	    int node1, node2;
-	    int i;
-
-	    display_line(ml->last_line, SYMB_BACKGROUND, 1);
-	    Vect_get_line_nodes(&Map, ml->last_line, &node1, &node2);
-	    display_node(node1, SYMB_BACKGROUND, 1);
-	    display_node(node2, SYMB_BACKGROUND, 1);
-
-	    type = Vect_read_line(&Map, ml->Points, ml->Cats, ml->last_line);
-	    for (i = 0; i < ml->Points->n_points; i++) {
-		ml->Points->x[i] = ml->Points->x[i] + x - ml->xo;
-		ml->Points->y[i] = ml->Points->y[i] + y - ml->yo;
-	    }
-
-	    Vect_rewrite_line(&Map, ml->last_line, type, ml->Points,
-			      ml->Cats);
-
-	    updated_lines_and_nodes_erase_refresh_display();
-	    ml->last_line = 0;
-	}
-
-    }
-    if (button == 2) {		/* Unselect */
-	if (ml->last_line > 0) {
-	    ml->last_line = 0;
-	}
-    }
-
-    if (ml->last_line == 0) {
-	i_prompt_buttons("Select", "", "Quit tool");
-	set_mode(MOUSE_POINT);
-    }
-    else
-	set_mode(MOUSE_LINE);
-
-    return 0;
-}
-
-int move_line_end(void *closure)
-{
-    struct move_line *ml = closure;
-
-    /* Display last highlighted in normal color */
-    if (ml->last_line > 0) {
-	display_line(ml->last_line, SYMB_DEFAULT, 1);
-    }
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "move_line(): End");
-
-    return 1;
-}
-
-void move_line(void)
-{
-    static struct move_line ml;
-
-    set_tool(move_line_begin, move_line_update, move_line_end, &ml);
-}

+ 0 - 232
vector/v.digit/main.c

@@ -1,232 +0,0 @@
-/* ***************************************************************
- * MODULE:       v.digit
- * AUTHOR(S):    Radim Blazek
- * PURPOSE:      Edit vector
- * COPYRIGHT:    (C) 2001 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.
- **************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <tcl.h>
-#include <tk.h>
-#include <grass/gis.h>
-#include <grass/display.h>
-#include <grass/raster.h>
-#include <grass/Vect.h>
-#include <grass/glocale.h>
-#include "global.h"
-#include "proto.h"
-
-VAR Variable[] = {
-    {VAR_CAT, VARN_CAT, VART_INT, 0, 0, NULL},
-    {VAR_FIELD, VARN_FIELD, VART_INT, 0, 0, NULL},
-    {VAR_CAT_MODE, VARN_CAT_MODE, VART_INT, 0, 0, NULL},
-    {VAR_INSERT, VARN_INSERT, VART_INT, 0, 0, NULL},
-    {VAR_MESSAGE, VARN_MESSAGE, VART_CHAR, 0, 0, NULL},
-    {VAR_SNAP, VARN_SNAP, VART_INT, 0, 0, NULL},
-    {VAR_SNAP_MODE, VARN_SNAP_MODE, VART_INT, 0, 0, NULL},
-    {VAR_SNAP_SCREEN, VARN_SNAP_SCREEN, VART_INT, 0, 0, NULL},
-    {VAR_SNAP_MAP, VARN_SNAP_MAP, VART_DOUBLE, 0, 0, NULL},
-    {VAR_ZOOM_REGION, VARN_ZOOM_REGION, VART_CHAR, 0, 0, NULL},
-    {VAR_ANSWER, VARN_ANSWER, VART_INT, 0, 0, NULL},
-    {VAR_LINEWIDTH, VARN_LINEWIDTH, VART_INT, 2, 0, NULL},
-    {0, NULL, 0, 0, 0, NULL}
-};
-
-BGCMD *Bgcmd = NULL;
-int nbgcmd = 0;
-int abgcmd = 0;
-
-char *CatModeLab[] = { "No category", "Manual entry", "Next not used" };
-
-/* Maximum value for field */
-int (*MaxFieldCat)[2];
-int nMaxFieldCat, aMaxFieldCat;
-
-SYMB Symb[SYMB_COUNT];
-
-struct Map_info Map;
-struct Cell_head GRegion;	/* Current region (synchronized with GRASS WIND) */
-Tcl_Interp *Toolbox;
-int Tool_next;		/* Next tool to be run */
-double Xscale, Yscale;	/* Scale factors = size_in_map / size_on_screen */
-
-struct Cell_head window;
-
-double Scale;		/* Map / xdriver */
-
-/* Display symbology for lines and nodes */
-int *LineSymb;		/* array of line symbology codes, starts from index 1 */
-int aLineSymb;		/* number of lines / allocated space (array size + 1) */
-int *NodeSymb;		/* array of nodes' symbology codes, start from index 1 */
-int aNodeSymb;		/* number of nodes / allocated space (array size + 1) */
-
-int Tcl_AppInit(Tcl_Interp * interp)
-{
-    int ret;
-
-    G_debug(3, "v.digit Tcl_AppInit (...)");
-
-    ret = Tcl_Init(interp);
-    if (ret != TCL_OK) {
-	return TCL_ERROR;
-    }
-    ret = Tk_Init(interp);
-    if (ret != TCL_OK) {
-	return TCL_ERROR;
-    }
-
-    Toolbox = interp;
-
-    Tcl_CreateCommand(interp, "c_tool_centre", (Tcl_CmdProc *) c_tool_centre,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_next_tool", (Tcl_CmdProc *) c_next_tool,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_cancel", (Tcl_CmdProc *) c_cancel,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_set_color", (Tcl_CmdProc *) c_set_color,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_set_on", (Tcl_CmdProc *) c_set_on,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_create_table",
-		      (Tcl_CmdProc *) c_create_table, (ClientData) NULL,
-		      (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_table_definition",
-		      (Tcl_CmdProc *) c_table_definition, (ClientData) NULL,
-		      (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_var_set", (Tcl_CmdProc *) c_var_set,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_create_bgcmd",
-		      (Tcl_CmdProc *) c_create_bgcmd, (ClientData) NULL,
-		      (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_set_bgcmd", (Tcl_CmdProc *) c_set_bgcmd,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_add_blank_bgcmd",
-		      (Tcl_CmdProc *) c_add_blank_bgcmd, (ClientData) NULL,
-		      (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_del_cat", (Tcl_CmdProc *) c_del_cat,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_add_cat", (Tcl_CmdProc *) c_add_cat,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "c_update_tool", (Tcl_CmdProc *) c_update_tool,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-
-    Tcl_CreateCommand(interp, "submit", (Tcl_CmdProc *) submit,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "set_value", (Tcl_CmdProc *) set_value,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-    Tcl_CreateCommand(interp, "reset_values", (Tcl_CmdProc *) reset_values,
-		      (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
-
-    Tcl_SetVar(interp, "map_mapset", Map.mapset, TCL_GLOBAL_ONLY);
-    Tcl_SetVar(interp, "map_name", Map.name, TCL_GLOBAL_ONLY);
-
-    G_debug(3, "Starting toolbox.tcl");
-
-    return TCL_OK;
-}
-
-int main(int argc, char *argv[])
-{
-    int i;
-    struct GModule *module;
-    struct Option *map_opt, *bgcmd_opt;
-    struct Flag *new_f;
-    const char *mapset;
-    char **tokens;
-    char *fake_argv[4];
-    char toolbox[GPATH_MAX];
-
-    G_gisinit(argv[0]);
-
-    module = G_define_module();
-    module->keywords = _("vector, editing, digitization");
-    module->description =
-	_("Interactive editing and digitization of vector maps.");
-
-    map_opt = G_define_standard_option(G_OPT_V_MAP);
-
-    bgcmd_opt = G_define_option();
-    bgcmd_opt->key = "bgcmd";
-    bgcmd_opt->type = TYPE_STRING;
-    bgcmd_opt->required = NO;
-    bgcmd_opt->multiple = NO;
-    bgcmd_opt->answer = "";
-    bgcmd_opt->description =
-	_("Display commands to be used for canvas backdrop (separated by ';')");
-
-    new_f = G_define_flag();
-    new_f->key = 'n';
-    new_f->description = _("Create new file if it does not exist.");
-
-    if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);
-
-    G_debug(2, "Variable = %p", Variable);
-
-    /* Read background commands */
-    if (bgcmd_opt->answer) {
-	tokens = G_tokenize(bgcmd_opt->answer, ";");
-	for (i = 0; tokens[i] != NULL; i++) {
-	    G_debug(2, "cmd %d : %s", i, tokens[i]);
-	    bg_add(tokens[i]);
-	}
-	G_free_tokens(tokens);
-    }
-
-    for (i = 0; i < nbgcmd; i++)
-	G_debug(2, "cmd %d : %s", i, Bgcmd[i].cmd);
-
-    Tool_next = TOOL_NOTHING;
-    G_get_window(&GRegion);
-    G_debug(1, "Region: N = %f S = %f E = %f W = %f", GRegion.north,
-	    GRegion.south, GRegion.east, GRegion.west);
-
-    /* Open map */
-    mapset = G_find_vector2(map_opt->answer, G_mapset());
-    if (mapset == NULL) {
-	if (new_f->answer) {
-	    G_message(_("New empty map created."));
-	    Vect_open_new(&Map, map_opt->answer, 0);
-	    Vect_build(&Map);
-	    Vect_close(&Map);
-	    Vect_open_update(&Map, map_opt->answer, G_mapset());
-	}
-	else {
-	    G_fatal_error(_("Map <%s> does not exist in current mapset. Add flag -n to create a new map."),
-			  map_opt->answer);
-	}
-    }
-    else {
-	Vect_set_open_level(2);
-	Vect_open_update(&Map, map_opt->answer, mapset);
-    }
-    Vect_set_category_index_update(&Map);
-    Vect_hist_command(&Map);
-
-    G_debug(1, "Map opened");
-
-    /* Init maximum categories */
-    cat_init();
-
-    /* Init symbology for lines and nodes */
-    symb_lines_init();
-    symb_nodes_init();
-
-    G_debug(3, "Starting Tk_Main.");
-
-    /* Open toolbox */
-    sprintf(toolbox, "%s/etc/v.digit/toolbox.tcl", G_gisbase());
-    fake_argv[0] = argv[0];
-    fake_argv[1] = "-f";
-    fake_argv[2] = toolbox;
-    fake_argv[3] = NULL;
-    Tk_Main(3, fake_argv, Tcl_AppInit);
-
-    /* Not reached */
-    exit(EXIT_SUCCESS);
-}

+ 0 - 58
vector/v.digit/open.c

@@ -1,58 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/dbmi.h>
-#include "global.h"
-#include "proto.h"
-
-int first = 1;
-
-/* Open new form
- *
- *  returns: 0 success
- */
-int F_open(char *title, char *html)
-{
-    int len;
-    char *buf;
-
-    if (first) {
-	Tcl_Eval(Toolbox, "init_form");
-	first = 0;
-    }
-
-    G_debug(2, "PARENT HTML:\n%s\n", html);
-
-    len = strlen(title) + strlen(html) + 20;
-    buf = G_malloc(len);
-    sprintf(buf, "open_form {%s} {%s}", title, html);
-    Tcl_Eval(Toolbox, buf);
-    G_free(buf);
-
-    return 0;
-}
-
-/* Clear old forms from window
- *
- */
-void F_clear(void)
-{
-    G_debug(2, "F_clear()");
-
-    if (first)
-	return;
-
-    Tcl_Eval(Toolbox, "clear_form");
-}
-
-void F_close(void)
-{
-    G_debug(2, "F_close()");
-
-    if (first)
-	return;
-
-    Tcl_Eval(Toolbox, "done_form");
-
-    first = 1;
-}

+ 0 - 145
vector/v.digit/proto.h

@@ -1,145 +0,0 @@
-
-/* Driver */
-int driver_open(void);
-int driver_close(void);
-int driver_refresh(void);
-void driver_rgb_color(int r, int g, int b);
-void driver_line_width(int w);
-void driver_plot_icon(double x, double y, const char *icon);
-void driver_move(double x, double y);
-void driver_cont(double x, double y);
-
-/* Miscellaneous */
-void tool_centre(void);
-void next_tool(void);
-void update(int, int);
-void end(void);
-
-/* Symbology */
-int get_symb_code(char *);
-char *get_symb_name(int);
-void symb_init(void);
-void symb_init_gui(void);
-void symb_set_driver_color(int);
-
-int symb_line_from_map(int);
-void symb_line_set_from_map(int);
-void symb_lines_init(void);
-void symb_updated_lines_set_from_map(void);
-
-int symb_node_from_map(int);
-void symb_node_set_from_map(int);
-void symb_nodes_init(void);
-void symb_updated_nodes_set_from_map(void);
-
-void updated_lines_and_nodes_erase_refresh_display(void);
-
-/* Edit */
-int snap(double *, double *);
-void new_line(int);
-void move_vertex(void);
-void add_vertex(void);
-void rm_vertex(void);
-void split_line(void);
-void move_line(void);
-void delete_line(void);
-void edit_line(void);
-
-/* Attributes */
-void copy_cats(void);
-void display_cats(void);
-int del_cat(int, int, int);
-int add_cat(int, int, int);
-void display_attributes(void);
-int new_record(int, int);
-int check_record(int, int);
-
-/* Display */
-void display_points(struct line_pnts *, int);
-void display_icon(double, double, int, double, int, int);
-void display_line(int, int, int);
-void display_updated_lines(int);
-void display_node(int, int, int);
-void display_updated_nodes(int);
-void display_map(void);
-void display_bg(void);
-void display_erase(void);
-void display_redraw(void);
-
-/* Zoom */
-void zoom_window(void);
-int zoom_centre(double factor);
-void zoom_pan(void);
-int zoom_default(void);
-int zoom_region(void);
-
-/* c_face.c */
-int c_cancel(ClientData, Tcl_Interp *, int, char **);
-int c_next_tool(ClientData, Tcl_Interp *, int, char **);
-int c_tool_centre(ClientData, Tcl_Interp *, int, char **);
-int c_set_color(ClientData, Tcl_Interp *, int, char **);
-int c_set_on(ClientData, Tcl_Interp *, int, char **);
-int c_create_table(ClientData, Tcl_Interp *, int, char **);
-int c_table_definition(ClientData, Tcl_Interp *, int, char **);
-int c_var_set(ClientData, Tcl_Interp *, int, char **);
-int c_create_bgcmd(ClientData, Tcl_Interp *, int, char **);
-int c_set_bgcmd(ClientData, Tcl_Interp *, int, char **);
-int c_add_blank_bgcmd(ClientData, Tcl_Interp *, int, char **);
-int c_del_cat(ClientData, Tcl_Interp *, int, char **);
-int c_add_cat(ClientData, Tcl_Interp *, int, char **);
-
-/* i_face.c */
-int i_prompt(char *);
-int i_prompt_buttons(char *, char *, char *);
-int i_coor(double, double);
-int i_set_color(char *, int, int, int);
-int i_set_on(char *, int);
-int i_update(void);
-void i_new_line_options(int);
-void i_set_cat_mode(void);
-void i_var_seti(int, int);
-void i_var_setd(int, double);
-void i_var_setc(int, char *);
-int i_message(int, int, char *);
-void i_add_bgcmd(int);
-
-/* Cats */
-void cat_init(void);
-int cat_max_get(int);
-void cat_max_set(int, int);
-
-/* Variables */
-void var_init(void);
-int var_seti(int, int);
-int var_setd(int, double);
-int var_setc(int, char *);
-int var_get_type_by_name(char *);
-int var_get_code_by_name(char *);
-char *var_get_name_by_code(int code);
-int var_geti(int);
-double var_getd(int);
-char *var_getc(int);
-
-/* Background */
-int bg_add(char *);
-
-/* Utilities */
-char *get_line_type_name(int type);
-void set_location(int x, int y);
-void set_mode(int m);
-
-typedef int tool_func_begin(void *closure);
-typedef int tool_func_update(void *closure, int sxn, int syn, int button);
-typedef int tool_func_end(void *closure);
-
-void set_tool(tool_func_begin * begin,
-	      tool_func_update * update, tool_func_end * end, void *closure);
-void cancel_tool(void);
-int c_update_tool(ClientData, Tcl_Interp *, int, char **);
-
-double get_thresh();
-
-/* form */
-int reset_values(ClientData, Tcl_Interp *, int, char **);
-int set_value(ClientData, Tcl_Interp *, int, char **);
-int submit(ClientData, Tcl_Interp *, int, char **);

+ 0 - 355
vector/v.digit/settings.tcl

@@ -1,355 +0,0 @@
-# Include the select dialog code because it defines scroll bindings
-source $env(GISBASE)/etc/gtcltk/select.tcl
-
-# Symbology table
-proc color2rgb { color } {
-    regexp -- {#(..)(..)(..)} $color x r g b
-    set r [expr 0x$r ]
-    set g [expr 0x$g ]
-    set b [expr 0x$b ]
-    return [list $r $g $b]
-}
-
-proc set_color { col color } {
-    set clr [ color2rgb $color] 
-    c_set_color $col [lindex $clr 0]  [lindex $clr 1]  [lindex $clr 2]
-    if {$col == "background"} {.screen.canvas configure -background $color}
-}
-
-proc set_on { code on } {
-    c_set_on $code $on
-}
-
-set tabrow 1
-set comrow 0
-
-proc set_col_type { rnum } {
-    global columns
-
-    if { $columns(type,$rnum) == "varchar" } {
-        $columns(frm,$rnum).c configure -state normal
-    } else {
-        $columns(frm,$rnum).c configure -state disabled
-    }
-}
-
-proc add_tab_col { name type width namedit typedit widthedit } {
-    global tabrow columns table_frame iconpath
-
-    set row [ frame $table_frame.row$tabrow ]
-    set columns(frm,$tabrow) $row
-
-    set columns(name,$tabrow) $name
-    set columns(type,$tabrow) $type
-    set columns(width,$tabrow) $width
-    set columns(rem,$tabrow) 0
-   
-    Entry $row.a -width 20 -textvariable columns(name,$tabrow) -bg white
-    if { $namedit == 0 } { $row.a configure -state disabled }
-    ComboBox $row.b -textvariable columns(type,$tabrow) \
-    	-values {"integer" "double precision" "varchar"} \
-		-modifycmd "set_col_type $tabrow" -entrybg white
-    if { $typedit == 0 } { $row.b configure -state disabled }
-    Entry $row.c -width 10 -textvariable columns(width,$tabrow) -bg white
-    if { $widthedit == 0 } { $row.c configure -state disabled }
-    set_col_type $tabrow
-    Button $row.d -image [image create photo -file "$iconpath/remove.gif"]  \
-    	-borderwidth 1\
-    	-command "rem_tab_col $row $tabrow"
-    if { $typedit == 0 } { $row.d configure -state disabled }
-     
-    pack $row.a $row.b $row.c $row.d -side left; 
-    pack $row -side top -fill x -expand no -anchor n 
-
-    incr tabrow
-}
-
-proc rem_tab_col { row num } {
-	global columns
-	
-	set columns(rem,$num) 1
-	destroy $row
-}
-
-proc table_buttons { } {
-    global table_page
-    set addcol [Button $table_page.addcol -text [G_msg "Add new column"]  \
-    	-borderwidth 1\
-        -command { add_tab_col "" "integer" 50 1 1 0 }]
-    set cretab [Button $table_page.cretab -text [G_msg "Create table"]  \
-    	-borderwidth 1\
-    	-command { make_table } ]
-    pack $addcol $cretab  -side left -anchor s
-}
-
-proc add_command { } {
-    global comrow GWidget GBgcmd
-
-    c_add_blank_bgcmd
-    
-    set GBgcmd($comrow,on) 1
-
-    set GBgcmd($comrow,cmd) ""
-
-    set row [ frame $GWidget(bgcmd).row$comrow ]
-
-    checkbutton $row.a -variable GBgcmd($comrow,on) -height 1 
- 
-    Entry $row.b -width 40 -textvariable GBgcmd($comrow,cmd) -bg white
-
-    pack $row.a $row.b -side left
-
-    pack $row -side top -fill x -expand no -anchor n
-
-    bind $GWidget(bgcmd).row$comrow.b <KeyRelease> 
-		{c_create_bgcmd}
-    incr comrow
-
-}
-
-proc command_buttons { } {
-    global GWidget
-    set addcom [Button $GWidget(bgcmd).addcom -text [G_msg "Add command"]  \
-    	-borderwidth 1 \
-		-command { add_command }]
-   pack $addcom -side left -anchor s
-}
-
-proc clear_table { } {
-    global table_page table_frame
-    if { [winfo exists $table_page.addcol] } { destroy $table_page.addcol }
-    if { [winfo exists $table_page.cretab] } { destroy $table_page.cretab }
-    foreach f [ winfo children $table_frame] {
-        destroy $f
-    }
-}
-
-proc make_table { } {
-    global tabrow columns create_table_err create_table_msg
-
-    set coldef ""
-    for {set i 1} {$i < $tabrow} {incr i} {
-    	if { $columns(rem,$i) == 0 } {
-        	if { $i > 1 } { append coldef ", " }
-        	append coldef "$columns(name,$i) $columns(type,$i) "
-        	if { $columns(type,$i) == "varchar" } {
-            		append coldef "( $columns(width,$i) )"
-		}
-	}
-    }
-    puts $coldef
-
-    set field 1
-    set field_name ""
-    set create_table_msg ""
-    c_create_table $field $field_name $columns(name,1) $coldef
-    
-    if { $create_table_err == 1 } {
-        MessageDlg .msg -icon error -parent .settings -type ok -message $create_table_msg
-    } else {
-        MessageDlg .msg -icon info -parent .settings -type ok -message [G_msg "Table successfully created"]
-        clear_table
-        c_table_definition
-    }
-}
-
-# create settings window
-proc settings {} {
-    global symb GVariable  table_page table_frame tabrow GWidget GBgcmd
-    set clw 30
-    
-    if {![info exists GVariable(linewidth)]} {
-    	set GVariable(linewidth) 2
-    }
-
-    if { [winfo exists .settings] } {
-        puts [G_msg "Settings already opened"]
-        wm deiconify .settings
-        raise .settings
-        return
-    } 
-    set stt [toplevel .settings]
- 
-    set nb [NoteBook $stt.nb]  
-    set bottom [frame $stt.frm]
-    set ok [Button $bottom.ok -text [G_msg "OK"] -width 5 -borderwidth 1\
-    	-command {c_next_tool redraw
-    		destroy .settings}]
-    pack $ok -side right -padx 15
-    
-    $nb compute_size
-
-
-    # --- Symbology ---
-    set symbf [$nb insert end colors -text [G_msg "Symbology"]]
-
-    # Background
-    set row [ frame $symbf.row1 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Background"]  
-    SelectColor $row.b -type menubutton -variable symb(background,color) \
-                -command { set_color background $symb(background,color) }
-    pack $row.a -side left; pack $row.b -side right; pack $row -side top -fill x -expand yes
-
-    # Highlight
-    set row [ frame $symbf.row2 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Highlight"]  
-    SelectColor $row.b -type menubutton -variable symb(highlight,color) \
-                -command { set_color highlight $symb(highlight,color) }
-    pack $row.a -side left; pack $row.b -side right; pack $row -side top -fill x -expand yes
-
-    # Point
-    set row [ frame $symbf.row3 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Point"]  
-    checkbutton $row.b -variable symb(point,on) -height 1 -padx 0 -width 0 \
-                -command { set_on point $symb(point,on) }
-    SelectColor $row.c -type menubutton -variable symb(point,color) \
-                -command { set_color point $symb(point,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    # Line
-    set row [ frame $symbf.row4 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Line"]  
-    checkbutton $row.b -variable symb(line,on) -height 1 -padx 0 -width 0 \
-                -command { set_on line $symb(line,on) }
-    SelectColor $row.c -type menubutton -variable symb(line,color) \
-                -command { set_color line $symb(line,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    # Boundary
-    set row [ frame $symbf.row5 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Boundary (no area)"]  
-    checkbutton $row.b -variable symb(boundary_0,on) -height 1 -padx 0 -width 0 \
-                -command { set_on boundary_0 $symb(boundary_0,on) }
-    SelectColor $row.c -type menubutton -variable symb(boundary_0,color) \
-                -command { set_color boundary_0 $symb(boundary_0,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    set row [ frame $symbf.row6 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Boundary (1 area)"]  
-    checkbutton $row.b -variable symb(boundary_1,on) -height 1 -padx 0 -width 0 \
-                -command { set_on boundary_1 $symb(boundary_1,on) }
-    SelectColor $row.c -type menubutton -variable symb(boundary_1,color) \
-                -command { set_color boundary_1 $symb(boundary_1,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    set row [ frame $symbf.row7 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Boundary (2 areas)"]  
-    checkbutton $row.b -variable symb(boundary_2,on) -height 1 -padx 0 -width 0 \
-                -command { set_on boundary_2 $symb(boundary_2,on) }
-    SelectColor $row.c -type menubutton -variable symb(boundary_2,color) \
-                -command { set_color boundary_2 $symb(boundary_2,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    # Centroid
-    set row [ frame $symbf.row8 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Centroid (in area)"]  
-    checkbutton $row.b -variable symb(centroid_in,on) -height 1 -padx 0 -width 0 \
-                -command { set_on centroid_in $symb(centroid_in,on) }
-    SelectColor $row.c -type menubutton -variable symb(centroid_in,color) \
-                -command { set_color centroid_in $symb(centroid_in,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    set row [ frame $symbf.row9 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Centroid (outside area)"]  
-    checkbutton $row.b -variable symb(centroid_out,on) -height 1 -padx 0 -width 0 \
-                -command { set_on centroid_out $symb(centroid_out,on) }
-    SelectColor $row.c -type menubutton -variable symb(centroid_out,color) \
-                -command { set_color centroid_out $symb(centroid_out,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    set row [ frame $symbf.row10 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Centroid (duplicate in area)"]  
-    checkbutton $row.b -variable symb(centroid_dupl,on) -height 1 -padx 0 -width 0 \
-                -command { set_on centroid_dupl $symb(centroid_dupl,on) }
-    SelectColor $row.c -type menubutton -variable symb(centroid_dupl,color) \
-                -command { set_color centroid_dupl $symb(centroid_dupl,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    # Node
-    set row [ frame $symbf.row11 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Node (1 line)"]  
-    checkbutton $row.b -variable symb(node_1,on) -height 1 -padx 0 -width 0 \
-                -command { set_on node_1 $symb(node_1,on) }
-    SelectColor $row.c -type menubutton -variable symb(node_1,color) \
-                -command { set_color node_1 $symb(node_1,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-    set row [ frame $symbf.row12 ]
-    Label $row.a -anchor w -width $clw -text [G_msg "Node (2 lines)"]  
-    checkbutton $row.b -variable symb(node_2,on) -height 1 -padx 0 -width 0 \
-                -command { set_on node_2 $symb(node_2,on) }
-    SelectColor $row.c -type menubutton -variable symb(node_2,color) \
-                -command { set_color node_2 $symb(node_2,color) }
-    pack $row.a -side left; pack $row.c $row.b -side right; pack $row -side top -fill x -expand yes
-
-
-
-    # --- Settings ---
-    set setf [$nb insert end settings -text [G_msg "Settings"]]
-
-    # Snapping threshold
-    set row [ frame $setf.row1 ]
-
-    Label $row.a -anchor w -text [G_msg "Snapping threshold in screen pixels"]  
-    radiobutton $row.b -variable GVariable(snap_mode) -value 0 -height 1 -padx 0 -width 0 \
-                -command { c_var_set snap_mode $GVariable(snap_mode) }
-    Entry $row.c -width 10 -textvariable GVariable(snap_screen) -bg white \
-                           -command { c_var_set snap_screen $GVariable(snap_screen) } 
-    bind $row.c <KeyRelease> { c_var_set snap_screen $GVariable(snap_screen) }
-    pack $row.a -side left; pack $row.c $row.b -side right; 
-    pack $row -side top -fill x -expand no -anchor n 
-    
-    set row [ frame $setf.row2 ]
-    Label $row.a -anchor w -text [G_msg "Snapping threshold in map units"]  
-    radiobutton $row.b -variable GVariable(snap_mode) -value 1 -height 1 -padx 0 -width 0 \
-                -command { c_var_set snap_mode $GVariable(snap_mode) }
-    Entry $row.c -width 10 -textvariable GVariable(snap_map) -bg white \
-                           -command { c_var_set snap_map $GVariable(snap_map) }
-    bind $row.c <KeyRelease> { c_var_set snap_map $GVariable(snap_map) }
-    pack $row.a -side left; pack $row.c $row.b -side right; 
-    pack $row -side top -fill x -expand no -anchor n 
-
-    # how to make a simple blank spacing line?
-    set row [ frame $setf.row3 ]
-    Label $row.a -anchor w
-    pack $row.a -side left;
-    pack $row -side top -fill x -expand no -anchor n
-
-    # Linewidth
-    set row [ frame $setf.row4 ]
-    Label $row.a -anchor w -text [G_msg "Line width in screen pixels"]
-    SpinBox $row.b -range {1 50 1} -textvariable GVariable(linewidth) \
-		   -width 2 -helptext [G_msg "Set line width in pixels"] -entrybg white \
-		   -modifycmd {c_var_set linewidth $GVariable(linewidth); c_next_tool redraw}
-    pack $row.a -side left; pack $row.b -side right;
-    pack $row -side top -fill x -expand no -anchor n
-
-
-    # --- Table (define new attribute table) ---
-    set tabrow 1
-    set table_page [$nb insert end table -text [G_msg "Table"]]
-
-    set tabsw [ScrolledWindow $table_page.sw ]
-    set tabsf [ScrollableFrame $table_page.sf -width 400]
-    $tabsw setwidget $tabsf
-    pack $tabsw $tabsf -fill both -expand yes
-    set table_frame [$tabsf getframe]
-
-    c_table_definition
-
-    # --- Background commands ---
-    set GWidget(bgcmd) [$nb insert end bgcmd -text [G_msg "Background"]]
-
-    command_buttons
-    c_create_bgcmd
-    
-    # -- pack notebook and bottom frame--
-    pack $nb -fill both -expand yes -padx 1 -pady 1
-    pack $bottom -side bottom -expand 1 -fill x
-    
-    $nb raise [$nb page 0]
-
-    tkwait visibility $stt
-}
-
-

+ 0 - 281
vector/v.digit/symb.c

@@ -1,281 +0,0 @@
-/* ***************************************************************
- * *
- * * MODULE:       v.digit
- * * 
- * * AUTHOR(S):    Radim Blazek
- * *               
- * * PURPOSE:      Edit vector
- * *              
- * * COPYRIGHT:    (C) 2001 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.
- * *
- * **************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/colors.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include "global.h"
-#include "proto.h"
-
-struct symb
-{
-    char *name;
-    int code;
-    int r, g, b;		/* default colors */
-};
-
-struct symb default_symb_table[] = {
-    {"background", SYMB_BACKGROUND, 255, 255, 255},	/* white */
-    {"highlight", SYMB_HIGHLIGHT, 255, 255, 0},	/* yellow */
-    {"point", SYMB_POINT, 0, 0, 0},	/* black */
-    {"line", SYMB_LINE, 0, 0, 0},	/* black */
-    {"boundary_0", SYMB_BOUNDARY_0, 153, 153, 153},	/* grey */
-    {"boundary_1", SYMB_BOUNDARY_1, 255, 125, 0},	/* orange */
-    {"boundary_2", SYMB_BOUNDARY_2, 0, 255, 0},	/* green */
-    {"centroid_in", SYMB_CENTROID_IN, 0, 0, 153},	/* dark blue */
-    {"centroid_out", SYMB_CENTROID_OUT, 153, 153, 0},	/* mustard */
-    {"centroid_dupl", SYMB_CENTROID_DUPL, 255, 0, 255},	/* magenta */
-    {"node_1", SYMB_NODE_1, 255, 0, 0},	/* red */
-    {"node_2", SYMB_NODE_2, 0, 153, 0},	/* dark green */
-    {"", 0, 0, 0, 0}
-};
-
-/* Convert symbology  name to code */
-int get_symb_code(char *name)
-{
-    int i;
-
-    G_debug(2, "get_symb_code(): name = %s", name);
-
-    for (i = 0; default_symb_table[i].name[0]; i++) {
-	if (strcmp(name, default_symb_table[i].name) == 0) {
-	    G_debug(2, "-> code = %d", default_symb_table[i].code);
-	    return (default_symb_table[i].code);
-	}
-    }
-
-    G_warning("get_symb_code(): symbol name %s does not exist", name);
-    return (-1);
-}
-
-/* Returns pointer to symbology name */
-char *get_symb_name(int code)
-{
-    G_debug(2, "get_symb_name(): code = %d", code);
-
-    G_debug(2, "-> name = %s", default_symb_table[code].name);
-
-    return (default_symb_table[code].name);
-}
-
-/* Init symbology: set defaults */
-void symb_init(void)
-{
-    int i, code;
-
-    for (i = 0; default_symb_table[i].name[0]; i++) {
-	code = default_symb_table[i].code;
-	Symb[code].on = 1;
-	Symb[code].r = default_symb_table[i].r;
-	Symb[code].g = default_symb_table[i].g;
-	Symb[code].b = default_symb_table[i].b;
-    }
-}
-
-/* Synchronize GUI */
-void symb_init_gui(void)
-{
-    int i, code;
-
-    for (i = 0; default_symb_table[i].name[0]; i++) {
-	code = get_symb_code(default_symb_table[i].name);
-	i_set_color(default_symb_table[i].name, Symb[code].r, Symb[code].g,
-		    Symb[code].b);
-	i_set_on(default_symb_table[i].name, Symb[code].on);
-    }
-}
-
-/* Set driver color */
-void symb_set_driver_color(int code)
-{
-    G_debug(2, "set color to symb %d: %d %d %d", code, Symb[code].r,
-	    Symb[code].g, Symb[code].b);
-
-    driver_rgb_color(Symb[code].r, Symb[code].g, Symb[code].b);
-}
-
-
-/* --- LINES --- */
-/* Get line symbology from map */
-int symb_line_from_map(int line)
-{
-    int type, area1, area2, nareas;
-
-    G_debug(2, "line_symb_from_map(): line = %d", line);
-
-    type = Vect_read_line(&Map, NULL, NULL, line);
-
-    switch (type) {
-    case GV_POINT:
-	return SYMB_POINT;
-    case GV_LINE:
-	return SYMB_LINE;
-    case GV_BOUNDARY:
-	nareas = 0;
-	Vect_get_line_areas(&Map, line, &area1, &area2);
-	/* Count areas/isles on both sides */
-	if (area1 != 0)
-	    nareas++;
-	if (area2 != 0)
-	    nareas++;
-	G_debug(2, "  boundary = %d nareas = %d", line, nareas);
-	if (nareas == 0)
-	    return SYMB_BOUNDARY_0;
-	else if (nareas == 1)
-	    return SYMB_BOUNDARY_1;
-	else
-	    return SYMB_BOUNDARY_2;
-    case GV_CENTROID:
-	area1 = Vect_get_centroid_area(&Map, line);
-	G_debug(2, "  centroid = %d area = %d", line, area1);
-	if (area1 == 0)
-	    return SYMB_CENTROID_OUT;
-	else if (area1 > 0)
-	    return SYMB_CENTROID_IN;
-	else
-	    return SYMB_CENTROID_DUPL;	/* area1 < 0 */
-    }
-
-    /* Should not be reached */
-    return SYMB_HIGHLIGHT;
-}
-
-/* Init line symbology table */
-void symb_lines_init(void)
-{
-    int i;
-
-    G_debug(2, "symb_line_init()");
-
-    /* Lines */
-    aLineSymb = Vect_get_num_lines(&Map) + 1000;	/* allocated space */
-    LineSymb = (int *)G_malloc((aLineSymb + 1) * sizeof(int));
-    for (i = 1; i <= Vect_get_num_lines(&Map); i++)
-	LineSymb[i] = symb_line_from_map(i);
-}
-
-/* Set symbology for existing or new line */
-void symb_line_set_from_map(int line)
-{
-    G_debug(2, "line_symb_refresh()");
-
-    if (line > aLineSymb) {
-	aLineSymb = line + 1000;
-	LineSymb = (int *)G_realloc(LineSymb, (aLineSymb + 1) * sizeof(int));
-    }
-    LineSymb[line] = symb_line_from_map(line);
-}
-
-/* Update the symbology of lines changed by last write access to the map */
-void symb_updated_lines_set_from_map(void)
-{
-    int i, line;
-
-    G_debug(2, "symb_updated_lines_set_from_map();");
-
-    for (i = 0; i < Vect_get_num_updated_lines(&Map); i++) {
-	line = Vect_get_updated_line(&Map, i);
-	if (!Vect_line_alive(&Map, line))
-	    continue;
-	symb_line_set_from_map(line);
-    }
-}
-
-/* --- NODES --- */
-/* Get node symbology from map */
-int symb_node_from_map(int node)
-{
-    int i, nl, nlines, line, type;
-
-    nlines = 0;
-    nl = Vect_get_node_n_lines(&Map, node);
-
-    G_debug(2, "node = %d nl = %d", node, nl);
-    for (i = 0; i < nl; i++) {
-	line = abs(Vect_get_node_line(&Map, node, i));
-	G_debug(2, "i = %d line = %d", i, line);
-	if (!Vect_line_alive(&Map, line))
-	    continue;
-	type = Vect_read_line(&Map, NULL, NULL, line);
-	if (type & GV_LINES)
-	    nlines++;
-    }
-
-    G_debug(2, "node = %d nlines = %d", node, nlines);
-    if (nlines == 0)
-	return SYMB_NODE_0;
-    else if (nlines == 1)
-	return SYMB_NODE_1;
-    else
-	return SYMB_NODE_2;
-}
-
-/* Add node symbology for new lines if necessary */
-void symb_node_set_from_map(int node)
-{
-    G_debug(2, "line_symb_refresh()");
-
-    if (node > aNodeSymb) {
-	aNodeSymb = node + 1000;
-	NodeSymb = (int *)G_realloc(NodeSymb, (aNodeSymb + 1) * sizeof(int));
-    }
-    NodeSymb[node] = symb_node_from_map(node);
-}
-
-/* Init node symbology table */
-void symb_nodes_init(void)
-{
-    int i;
-
-    G_debug(2, "symb_node_init()");
-
-    /* Nodes */
-    aNodeSymb = Vect_get_num_nodes(&Map) + 1000;	/* allocated space */
-    NodeSymb = (int *)G_malloc((aNodeSymb + 1) * sizeof(int));
-    for (i = 1; i <= Vect_get_num_nodes(&Map); i++)
-	NodeSymb[i] = symb_node_from_map(i);
-}
-
-/* Update the symbology of nodes changed by last write access to the map */
-void symb_updated_nodes_set_from_map(void)
-{
-    int i, node;
-
-    G_debug(2, "node_update();");
-
-    for (i = 0; i < Vect_get_num_updated_nodes(&Map); i++) {
-	node = Vect_get_updated_node(&Map, i);
-	if (!Vect_node_alive(&Map, node))
-	    continue;
-	symb_node_set_from_map(node);
-    }
-}
-
-void updated_lines_and_nodes_erase_refresh_display(void)
-{
-    /* Note: this is a problem if new line is point, and there is a raster on the background, its displays
-     *        (erase) node over the raster, which is a bit confusing */
-    display_updated_nodes(SYMB_BACKGROUND);	/* because the size/shape may decrease for new symbol */
-
-    symb_updated_lines_set_from_map();
-    symb_updated_nodes_set_from_map();
-    display_updated_nodes(SYMB_DEFAULT);
-    display_updated_lines(SYMB_DEFAULT);
-}

+ 0 - 278
vector/v.digit/toolbox.tcl

@@ -1,278 +0,0 @@
-lappend auto_path $env(GISBASE)/bwidget
-package require -exact BWidget 1.2.1
-
-source $env(GISBASE)/etc/gtcltk/gmsg.tcl
-source $env(GISBASE)/etc/gtcltk/select.tcl
-
-#fontcreate balloon-help -family Helvetica -size -12
-DynamicHelp::configure -font balloon-help -fg black -bg "#FFFF77"
-
-set vdpath $env(GISBASE)/etc/v.digit/
-set iconpath $env(GISBASE)/etc/gui/icons/grass/vdigit/
-source $vdpath/settings.tcl
-source $vdpath/cats.tcl
-source $vdpath/form.tcl
-
-set env(GISDBASE) [exec g.gisenv get=GISDBASE]
-set env(LOCATION_NAME) [exec g.gisenv get=LOCATION_NAME]
-set env(MAPSET) [exec g.gisenv get=MAPSET]
-
-set prompt [G_msg "Welcome to v.digit"]
-set prompt_left [G_msg "Left button"]
-set prompt_middle [G_msg "Middle button"]
-set prompt_right [G_msg "Right button"]
-set coor ""
-
-wm title . "v.digit toolbox - $map_name@$map_mapset"
-
-proc get_update_line {ox oy x y} {
-    .screen.canvas delete active
-    .screen.canvas create line $ox $oy $x $y -tags active -dash {4 4}
-}
-
-proc get_update_box {ox oy x y} {
-    .screen.canvas delete active
-    .screen.canvas create line $ox $oy $ox $y $x $y $x $oy $ox $oy -tags active -dash {4 4}
-}
-
-proc create_screen {} {
-    global vdpath iconpath map_name map_mapset
-    if {[winfo exists .screen]} return
-
-    toplevel .screen
-    canvas .screen.canvas -background white -width 640 -height 480
-    pack .screen.canvas -fill both -expand yes
-    bind .screen.canvas <ButtonPress> { c_update_tool %x %y %b }
-    bind .screen.canvas <Motion> { c_update_tool %x %y -1 }
-    wm title .screen "v.digit - $map_name@$map_mapset"
-    wm withdraw .screen
-    wm deiconify .screen
-    update
-
-    image create bitmap cross -file "$iconpath/cross.xbm"
-    image create bitmap cross45 -file "$iconpath/cross45.xbm"
-    image create bitmap box -file "$iconpath/box.xbm"
-}
-
-# GVariable stores variables by key, this variables are (should be) synchronized with
-# variables in Variable array in C (synchronization should be done somehow better). Key is
-# 'name' in VAR structure in C. Variables are initialized by var_init() on startup.
-# For key list see VARN_* in global.h
-
-# GWidget stores names of some widgets we need to access globaly, names:
-# field - field Entry for new line
-# cat - cat Entry for new line
-
-# Create new line options
-proc new_line_options { create } {
-    global GVariable GWidget
-    if { $create } {
-    set lineopt [frame .lineopt]
-    pack $lineopt -fill x -side top
-
-    set row1 [frame $lineopt.row1]
-    pack $row1 -fill x -side top
-
-    Label $row1.flab -padx 2 -pady 2 -relief flat -anchor w -text [G_msg "  Layer"]
-    set GWidget(field) [Entry $row1.fval -width 6 -textvariable GVariable(field) \
-                -bg white -command { c_var_set field $GVariable(field) } ]
-        bind $GWidget(field) <KeyRelease> { c_var_set field $GVariable(field) }
-    Label $row1.clab -padx 2 -pady 2 -relief flat -anchor w -text [G_msg "  Category"]
-    set GWidget(cat) [Entry $row1.cval -width 6 -textvariable GVariable(cat) \
-                -bg white -command { c_var_set cat $GVariable(cat) }]
-        bind $GWidget(cat) <KeyRelease> { c_var_set cat $GVariable(cat) }
-    set GWidget(cat_mode) [ComboBox $row1.cmode -label [G_msg "  Mode "] \
-            -entrybg white -width 12 -textvariable cmode \
-            -modifycmd {
-                set GVariable(cat_mode) [ $GWidget(cat_mode) getvalue]
-                            c_var_set cat_mode $GVariable(cat_mode)
-             }]
-    pack $row1.flab $GWidget(field) $row1.clab $GWidget(cat) $GWidget(cat_mode) -fill x  -side left
-
-    set row2 [frame $lineopt.row2]
-    pack $row2 -fill x -side top
-
-    checkbutton $row2.ins -variable GVariable(insert) \
-            -padx 8 -pady 5 -text [G_msg "Insert new record into table"] \
-            -command { c_var_set insert $GVariable(insert) }
-    pack $row2.ins -fill x  -side left
-
-    } else {
-        destroy .lineopt
-    }
-}
-
-
-# button frame row 2
-set bbox2 [ButtonBox .bbox2 -spacing 1 -padx 1 -pady 1]
-
-# --- Draw new ---
-$bbox2 add -image [image create photo -file "$iconpath/new.point.gif"] \
-        -command "c_next_tool new_point" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Digitize new point"]
-
-$bbox2 add -image [image create photo -file "$iconpath/new.line.gif"] \
-        -command "c_next_tool new_line" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Digitize new line"]
-
-$bbox2 add -image [image create photo -file "$iconpath/new.boundary.gif"] \
-        -command "c_next_tool new_boundary" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Digitize new boundary"]
-
-$bbox2 add -image [image create photo -file "$iconpath/new.centroid.gif"] \
-        -command "c_next_tool new_centroid" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Digitize new centroid"]
-
-# --- Edit old ---
-$bbox2 add -image [image create photo -file "$iconpath/move.vertex.gif"] \
-        -command "c_next_tool move_vertex" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Move vertex"]
-
-$bbox2 add -image [image create photo -file "$iconpath/add.vertex.gif"] \
-        -command "c_next_tool add_vertex" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Add vertex"]
-
-$bbox2 add -image [image create photo -file "$iconpath/rm.vertex.gif"] \
-        -command "c_next_tool rm_vertex" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Remove vertex"]
-
-$bbox2 add -image [image create photo -file "$iconpath/split.line.gif"] \
-        -command "c_next_tool split_line" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Split line"]
-
-$bbox2 add -image [image create photo -file "$iconpath/edit.line.gif"] \
-        -command "c_next_tool edit_line" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Edit line/boundary"]
-
-$bbox2 add -image [image create photo -file "$iconpath/move.line.gif"] \
-        -command "c_next_tool move_line" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Move point, line, boundary, or centroid"]
-
-$bbox2 add -image [image create photo -file "$iconpath/delete.line.gif"] \
-        -command "c_next_tool delete_line" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Delete point, line, boundary, or centroid"]
-
-
-# button frame row 1
-set bbox1 [ButtonBox .bbox1 -spacing 1 -padx 1 -pady 1]
-
-# --- Zoom / Display ---
-
-$bbox1 add -image [image create photo -file "$iconpath/redraw.gif"] \
-        -command "c_next_tool redraw" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Redraw"]
-
-$bbox1 add -image [image create photo -file "$iconpath/zoom.window.gif"] \
-        -command "c_next_tool zoom_window" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Zoom in by window"]
-
-$bbox1 add -image [image create photo -file "$iconpath/zoom.out.centre.gif"] \
-        -command "c_next_tool zoom_out_centre" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Zoom out"]
-
-$bbox1 add -image [image create photo -file "$iconpath/zoom.pan.gif"] \
-        -command "c_next_tool zoom_pan" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Pan"]
-
-$bbox1 add -image [image create photo -file "$iconpath/zoom.default.gif"] \
-        -command "c_next_tool zoom_default" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Zoom to default region"]
-
-proc zoom_region { } {
-    set reg [GSelect windows]
-    if { $reg != "" } {
-        c_var_set zoom_region $reg
-        c_next_tool zoom_region
-    }
-}
-
-$bbox1 add -image [image create photo -file "$iconpath/zoom.region.gif"] \
-        -command "zoom_region" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Zoom to saved region"]
-
-# --- Attributes ---
-$bbox1 add -image [image create photo -file "$iconpath/display.cats.gif"] \
-        -command "c_next_tool display_cats" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Display categories"]
-
-$bbox1 add -image [image create photo -file "$iconpath/copy.cats.gif"] \
-        -command "c_next_tool copy_cats" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Copy categories"]
-
-$bbox1 add -image [image create photo -file "$iconpath/display.attributes.gif"] \
-        -command "c_next_tool display_attributes" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Display attributes"]
-
-# --- Stop ---
-#$bbox1 add -image [image create photo -file "$iconpath/stop.gif"] \
-#        -command "c_cancel" \
-#        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-#        -helptext "Quit running tool"
-
-# --- Others ---
-$bbox1 add -image [image create photo -file "$iconpath/settings.gif"] \
-        -command "c_next_tool settings" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -helptext [G_msg "Open settings"]
-
-$bbox1 add -image [image create photo -file "$iconpath/exit.gif"] \
-        -command "c_next_tool exit" \
-        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-        -bg white \
-        -helptext [G_msg "Save and exit"]
-
-pack $bbox1 -side top -anchor w
-pack $bbox2 -side top -anchor w
-
-
-frame .pf
-pack .pf -fill x -side top
-Label .pf.prompt -padx 3 -pady 2 -relief flat -anchor w -textvariable prompt -fg mediumblue
-pack .pf.prompt -fill x  -side left
-
-LabelFrame .bpf -text [G_msg "mouse button actions (left, middle, right)"] \
-    -side top -anchor n -background HoneyDew2
-# why doesn't the frame render?
-#    -relief groove -borderwidth 1
-
-pack .bpf -fill x -side top -padx 8
-Label .bpf.left -width 10  -pady 5 -relief raised -anchor center -textvariable prompt_left \
-	-wraplength 100 -bg grey95 
-Label .bpf.middle -width 10 -padx 2 -pady 5 -relief raised -anchor center -textvariable prompt_middle \
-	-wraplength 100 -bg grey95
-Label .bpf.right -width 10 -pady 5 -relief raised -anchor center -textvariable prompt_right \
-	-wraplength 100 -bg grey95
-pack .bpf.left .bpf.middle .bpf.right -fill x -side left -expand yes -padx 4 -pady 8
-
-frame .coorf
-pack .coorf -fill x -side top -padx 8 -pady 5
-Label .coorf.prompt -width 50 -padx 3 -pady 2 -relief flat -anchor w -textvariable coor
-pack .coorf.prompt -fill x  -side left
-
-bind . <Destroy> { if { "%W" == "."} { c_next_tool exit } }
-
-# Start tool centre in C
-c_tool_centre
-
-tkwait window .
-exit

+ 0 - 162
vector/v.digit/util.c

@@ -1,162 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <grass/gis.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include "global.h"
-#include "proto.h"
-
-/* Utilities */
-
-/* For given type returns pointer to name */
-char *get_line_type_name(int type)
-{
-    char *name;
-
-    switch (type) {
-    case GV_POINT:
-	name = G_store("point");
-	break;
-    case GV_LINE:
-	name = G_store("line");
-	break;
-    case GV_BOUNDARY:
-	name = G_store("boundary");
-	break;
-    case GV_CENTROID:
-	name = G_store("centroid");
-	break;
-    default:
-	name = G_store("unknown type");
-    }
-
-    return name;
-}
-
-static int sxo, syo, mode;
-
-void set_location(int x, int y)
-{
-    sxo = x;
-    syo = y;
-}
-
-void set_mode(int m)
-{
-    mode = m;
-}
-
-static tool_func_update *tool_update;
-static tool_func_end *tool_end;
-static void *tool_closure;
-
-static void end_tool(void)
-{
-    Tcl_Eval(Toolbox, ".screen.canvas configure -cursor {}");
-    Tcl_Eval(Toolbox, ".screen.canvas delete active");
-
-    if (tool_end)
-	(*tool_end) (tool_closure);
-
-    tool_update = NULL;
-    tool_end = NULL;
-    tool_closure = NULL;
-
-    driver_close();
-    next_tool();
-}
-
-void cancel_tool(void)
-{
-    end_tool();
-}
-
-int c_update_tool(ClientData cdata, Tcl_Interp * interp, int argc,
-		  char *argv[])
-{
-    char buf[100];
-    int x, y, b;
-
-    G_debug(3, "c_update_tool()");
-
-    if (argc < 4) {
-	Tcl_SetResult(interp, "Usage: c_update_tool x y b", TCL_VOLATILE);
-	return (TCL_ERROR);
-    }
-
-    if (!tool_update)
-	return TCL_OK;
-
-    Tcl_GetInt(interp, argv[1], &x);
-    Tcl_GetInt(interp, argv[2], &y);
-    Tcl_GetInt(interp, argv[3], &b);
-
-    switch (mode) {
-    case MOUSE_POINT:
-	break;
-    case MOUSE_LINE:
-	sprintf(buf, "get_update_line %d %d %d %d", sxo, syo, x, y);
-	Tcl_Eval(Toolbox, buf);
-	break;
-    case MOUSE_BOX:
-	sprintf(buf, "get_update_box %d %d %d %d", sxo, syo, x, y);
-	Tcl_Eval(Toolbox, buf);
-	break;
-    }
-
-    if (b < 0) {
-	update(x, y);
-	return TCL_OK;
-    }
-
-    if (b == 0) {
-	end_tool();
-	return TCL_OK;
-    }
-
-    if ((*tool_update) (tool_closure, x, y, b)) {
-	end_tool();
-	return TCL_OK;
-    }
-
-    return TCL_OK;
-}
-
-void set_tool(tool_func_begin * begin_fn, tool_func_update * update_fn,
-	      tool_func_end * end_fn, void *closure)
-{
-    int ret;
-
-    if (tool_update)
-	end_tool();
-
-    driver_open();
-    ret = (*begin_fn) (closure);
-
-    if (ret) {
-	driver_close();
-	return;
-    }
-
-    tool_update = update_fn;
-    tool_end = end_fn;
-    tool_closure = closure;
-
-    Tcl_Eval(Toolbox, ".screen.canvas configure -cursor crosshair");
-}
-
-/* Get snapping/selection threshold from GUI */
-double get_thresh() {
-    /* If not found, fall back to old calculation method */
-    if (!var_geti(VAR_SNAP))
-        return fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
-
-    if (var_geti(VAR_SNAP_MODE) == SNAP_MAP) {
-        return fabs(var_getd(VAR_SNAP_MAP));
-    }
-    else {
-        return fabs(Scale * var_geti(VAR_SNAP_SCREEN));
-    }
-}

+ 0 - 104
vector/v.digit/v.digit.html

@@ -1,104 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>v.digit</em> is a vector map digitizer with TCL/TK-based graphical
-user interface.  Attribute tables can be directly generated while
-digitizing (define in "Settings" first).
-
-
-<h2>NOTES</h2>
-
-The <b>bgcmd</b> option is intended to be used with display (d.*) commands.
-If several display commands are to be used to render the background
-they should be separated with the semi-colon ';' character.
-When run from the command line, these display commands will generally
-need to be "quoted" as they will contain spaces (see examples).
-
-<p>
-<b>Dead (deleted) lines</b>: If a user deletes a line in <em>v.digit</em>,
-it is internally only marked in the geometry file as 'dead' but it remains
-there and occupies space. Any vector module used afterwards on this map
-which really reads and writes vector geometry (so
-not <em><a href="g.copy.html">g.copy</a></em>) will writes only lines
-which are 'alive'.
-
-<p>
-If <em>v.digit</em> crashes for some reason you can repair the vector map
-which was left open with the <em>v.build</em> module.
-
-
-<h2>EXAMPLES</h2>
-
-<h3>Start a monitor and display a raster to help setup and zoom to area of interest</h3>
-
-<div class="code"><pre>
-d.mon x0
-d.rast name_of_raster
-</pre></div>
-
-<h3>Digitizing an area based on a existing raster map; creating a new vector map</h3>
-
-<div class="code"><pre>
-v.digit -n map=name_of_new_vector_map bgcmd="d.rast map=name_of_raster"
-</pre></div>
-
-<p>
-The <b>-n</b> flag specifies that your vector map does not yet exist and
-thus will be created with the name given by <b>map</b>. The <b>bgcmd</b>
-specifies a display (d.*) command and is set in "quotes" as it contains a space.
-
-<p>
-The <em>v.digit</em> GUI appears and vector map "name_of_new_vector_map" is created.
-
-<p>
-After leaving <em>v.digit</em>, run:
-
-<div class="code"><pre>
-d.erase
-d.vect "name_of_new_vector_map" 
-</pre></div>
-
-The display should be cleared and the newly created vector should appear in 
-the monitor.
-
-<h3>Digitizing a second vector, using your first vector and the raster image
-as background</h3>
-
-<div class="code"><pre>
-v.digit -n map=name_of_second_vector \
-bgcmd="d.rast map=name_of_your_raster; d.vect map=name_of_new_vector_map"
-</pre></div>
-
-The <em>v.digit</em> GUI appears and the layers defined with <b>bgcmd</b>
-are displayed in the background. As the <b>bgcmd</b> commands are executed 
-as a series of commands (separated by a ";"), the last command (d.vect)
-displays over the top of the earlier raster image.
-
-
-<h3>Combining <b>bgcmd</b> with <em>d.save</em> to use the existing
-display as a backdrop</h3>
-
-<div class="code"><pre>
-v.digit map=name bgcmd="`d.save -o | cut -f1 -d'#' | tr '\n' ';'`"
-</pre></div>
-
-<em><a href="d.save.html"><em>d.save</em></a></em> will list the commands used to draw
-the current display; <em>cut</em> and <em>tr</em> are UNIX commands which are
-used to remove comments and trade newlines for semi-colons, respectively.
-
-<h2>SEE ALSO</h2>
-
-<em>
-  <a href="r.digit.html">r.digit</a>,
-  <a href="v.clean.html">v.clean</a>,
-  <a href="v.edit.html">v.edit</a>
-</em>
-
-<p>
-See also <em><a href="wxGUI.Vector_Digitizing_Tool.html">wxGUI vector digitizing tool</a></em>.
-
-<h2>AUTHOR</h2>
-
-Radim Blazek, ITC-Irst, Trento, Italy
-
-<p>
-<i>Last changed: $Date$</i>

+ 0 - 232
vector/v.digit/var.c

@@ -1,232 +0,0 @@
-/* ***************************************************************
- * *
- * * MODULE:       v.digit
- * * 
- * * AUTHOR(S):    Radim Blazek
- * *               
- * * PURPOSE:      Edit vector
- * *              
- * * COPYRIGHT:    (C) 2001 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.
- * *
- * **************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/colors.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include "global.h"
-#include "proto.h"
-
-
-/* init variables 
- */
-void var_init(void)
-{
-    G_debug(2, "var_init");
-
-    G_debug(2, "Variable = %p", Variable);
-
-    /* Note: important is that VAR_CMODE is set last, because if it is CAT_MODE_NEXT 
-     *  previously set  VAR_CAT is automaticaly reset to 'next not used' for current field */
-    var_seti(VAR_CAT, 1);
-    var_seti(VAR_FIELD, 1);
-    var_seti(VAR_CAT_MODE, CAT_MODE_NEXT);
-    var_seti(VAR_INSERT, 1);
-
-}
-
-/* set variable value by code 
- *  return  0 ok
- *         -1 error
- */
-int var_seti(int code, int iv)
-{
-    int i, cat;
-
-    G_debug(5, "var_seti(): code = %d val = %d", code, iv);
-
-    i = 0;
-    while (Variable[i].name) {
-	if (code == Variable[i].code) {
-	    Variable[i].i = iv;
-
-	    /* Some variables requires extra actions */
-	    if ((code == VAR_FIELD &&
-		 var_geti(VAR_CAT_MODE) == CAT_MODE_NEXT)) {
-		cat = cat_max_get(var_geti(VAR_FIELD)) + 1;
-		var_seti(VAR_CAT, cat);
-	    }
-	    if (code == VAR_CAT_MODE) {
-		if (var_geti(VAR_CAT_MODE) == CAT_MODE_NEXT) {
-		    cat = cat_max_get(var_geti(VAR_FIELD)) + 1;
-		    var_seti(VAR_CAT, cat);
-		}
-		i_set_cat_mode();
-	    }
-	    i_var_seti(code, iv);	/* if called from C GUI is reset, */
-	    /* if originaly called from GUI it is reset in GUI second time */
-	    return 0;
-	}
-	i++;
-    }
-    G_warning("Cannot set variable code = %d", code);
-    return -1;
-}
-
-/* set variable value by code 
- *  return  0 ok
- *         -1 error
- */
-int var_setd(int code, double d)
-{
-    int i;
-
-    i = 0;
-    while (Variable[i].name) {
-	if (code == Variable[i].code) {
-	    Variable[i].d = d;
-	    i_var_setd(code, d);
-	    return 0;
-	}
-	i++;
-    }
-    G_warning("Cannot set variable code = %d", code);
-    return -1;
-}
-
-/* set variable value by code 
- *  return  0 ok
- *         -1 error
- */
-int var_setc(int code, char *c)
-{
-    int i;
-
-    i = 0;
-    while (Variable[i].name) {
-	if (code == Variable[i].code) {
-	    Variable[i].c = G_store(c);
-	    i_var_setc(code, c);
-	    return 0;
-	}
-	i++;
-    }
-    G_warning("Cannot set variable code = %d", code);
-    return -1;
-}
-
-/* get variable type 
- *  return  type
- *          -1 not found
- */
-int var_get_type_by_name(char *name)
-{
-    int i;
-
-    G_debug(5, "var_get_type_by_name()");
-
-    i = 0;
-    while (Variable[i].name) {
-	if (strcmp(name, Variable[i].name) == 0) {
-	    return (Variable[i].type);
-	}
-	i++;
-    }
-    G_warning("Cannot get type of variable %s", name);
-    return -1;
-}
-
-/* get variable type 
- *  return  type
- *          -1 not found
- */
-int var_get_code_by_name(char *name)
-{
-    int i;
-
-    G_debug(5, "var_get_code_by_name()");
-
-    i = 0;
-    while (Variable[i].name) {
-	if (strcmp(name, Variable[i].name) == 0) {
-	    return (Variable[i].code);
-	}
-	i++;
-    }
-    G_warning("Cannot get code of variable %s", name);
-    return -1;
-}
-
-/* get pointer to variable name
- *  return  pointer to name or NULL
- */
-char *var_get_name_by_code(int code)
-{
-    int i;
-
-    G_debug(5, "var_get_name_by_code()");
-
-    i = 0;
-    while (Variable[i].name) {
-	if (Variable[i].code == code) {
-	    return (Variable[i].name);
-	}
-	i++;
-    }
-    G_warning("Cannot get name of variable %d", code);
-    return NULL;
-}
-
-/* get variable value */
-int var_geti(int code)
-{
-    int i = 0;
-
-    while (Variable[i].name) {
-	if (code == Variable[i].code) {
-	    return (Variable[i].i);
-	}
-	i++;
-    }
-    G_warning("Cannot get value of variable code = %d", code);
-    return 0;
-}
-
-/* get variable value */
-double var_getd(int code)
-{
-    int i = 0;
-
-    while (Variable[i].name) {
-	if (code == Variable[i].code) {
-	    return (Variable[i].d);
-	}
-	i++;
-    }
-
-    G_warning("Cannot get value of variable code = %d", code);
-    return 0;
-}
-
-/* get variable value */
-char *var_getc(int code)
-{
-    int i = 0;
-
-    while (Variable[i].name) {
-	if (code == Variable[i].code) {
-	    return (Variable[i].c);
-	}
-	i++;
-    }
-
-    G_warning("Cannot get value of variable code = %d", code);
-    return NULL;
-}

+ 0 - 689
vector/v.digit/vertex.c

@@ -1,689 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <math.h>
-#include <grass/gis.h>
-#include <grass/Vect.h>
-#include <grass/dbmi.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include <grass/colors.h>
-#include <grass/form.h>
-#include "global.h"
-#include "proto.h"
-
-/* Split line */
-struct split_line
-{
-    struct line_pnts *Points, *NPoints;
-    struct line_cats *Cats;
-    int last_line, last_seg;
-    double thresh;
-    double xo, yo;
-};
-
-int split_line_begin(void *closure)
-{
-    struct split_line *sl = closure;
-
-    G_debug(2, "split_line()");
-
-    sl->Points = Vect_new_line_struct();
-    sl->NPoints = Vect_new_line_struct();
-    sl->Cats = Vect_new_cats_struct();
-
-    i_prompt("Split line:");
-    i_prompt_buttons("Select", "", "Quit tool");
-
-    sl->thresh = get_thresh();
-    G_debug(2, "thresh = %f", sl->thresh);
-
-    sl->last_line = 0;
-    sl->last_seg = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int split_line_update(void *closure, int sxn, int syn, int button)
-{
-    struct split_line *sl = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    if (sl->last_line == 0) {
-	i_prompt_buttons("Select", "", "Quit tool");
-    }
-
-    if (sl->last_line > 0) {
-	display_line(sl->last_line, SYMB_DEFAULT, 1);
-    }
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    if (button == 3)
-	return 1;
-
-    if (button == 1) {		/* Select / split */
-	int line;
-
-	if (sl->last_line > 0) {	/* Line is already selected -> split */
-	    int node1, node2, type, np, i;
-
-	    display_line(sl->last_line, SYMB_BACKGROUND, 1);
-	    Vect_get_line_nodes(&Map, sl->last_line, &node1, &node2);
-	    display_node(node1, SYMB_BACKGROUND, 1);
-	    display_node(node2, SYMB_BACKGROUND, 1);
-	    symb_set_driver_color(SYMB_BACKGROUND);
-	    display_icon(sl->xo, sl->yo, G_ICON_CROSS, 0, 10, 1);
-
-	    /* Read and delete old */
-	    type = Vect_read_line(&Map, sl->Points, sl->Cats, sl->last_line);
-	    Vect_delete_line(&Map, sl->last_line);
-	    updated_lines_and_nodes_erase_refresh_display();
-	    np = sl->Points->n_points;
-
-	    /* First part */
-	    Vect_reset_line(sl->NPoints);
-	    for (i = 0; i < sl->last_seg; i++) {
-		Vect_append_point(sl->NPoints, sl->Points->x[i],
-				  sl->Points->y[i], sl->Points->z[i]);
-	    }
-	    Vect_append_point(sl->NPoints, sl->xo, sl->yo, 0);
-	    Vect_write_line(&Map, type, sl->NPoints, sl->Cats);
-	    updated_lines_and_nodes_erase_refresh_display();
-
-	    /* Second part */
-	    Vect_reset_line(sl->NPoints);
-	    Vect_append_point(sl->NPoints, sl->xo, sl->yo, 0);
-	    for (i = sl->last_seg; i < np; i++) {
-		Vect_append_point(sl->NPoints, sl->Points->x[i],
-				  sl->Points->y[i], sl->Points->z[i]);
-	    }
-	    Vect_write_line(&Map, type, sl->NPoints, sl->Cats);
-	    updated_lines_and_nodes_erase_refresh_display();
-
-	    sl->last_line = 0;
-	}
-
-	/* Select vertex */
-	line =
-	    Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY, sl->thresh,
-			   0, 0);
-	G_debug(2, "line found = %d", line);
-
-	/* Display new selected line if any */
-	if (line > 0) {
-	    int seg;
-
-	    /* Find the nearest vertex on the line */
-	    Vect_read_line(&Map, sl->Points, NULL, line);
-	    seg =
-		Vect_line_distance(sl->Points, x, y, 0, 0, &sl->xo, &sl->yo,
-				   NULL, NULL, NULL, NULL);
-
-	    display_line(line, SYMB_HIGHLIGHT, 1);
-	    symb_set_driver_color(SYMB_HIGHLIGHT);
-	    display_icon(sl->xo, sl->yo, G_ICON_CROSS, 0, 10, 1);
-
-	    i_prompt_buttons("Confirm and select next", "Unselect",
-			     "Quit tool");
-	    sl->last_line = line;
-	    sl->last_seg = seg;
-	}
-    }
-    if (button == 2) {		/* Unselect */
-	if (sl->last_line > 0) {
-	    symb_set_driver_color(SYMB_BACKGROUND);
-	    display_icon(sl->xo, sl->yo, G_ICON_CROSS, 0, 10, 1);
-	    sl->last_line = 0;
-	}
-    }
-
-    return 0;
-}
-
-int split_line_end(void *closure)
-{
-    struct split_line *sl = closure;
-
-    if (sl->last_line == 0) {
-	i_prompt_buttons("Select", "", "Quit tool");
-    }
-
-    if (sl->last_line > 0) {
-	display_line(sl->last_line, SYMB_DEFAULT, 1);
-    }
-
-    if (sl->last_line > 0) {
-	symb_set_driver_color(SYMB_BACKGROUND);
-	display_icon(sl->xo, sl->yo, G_ICON_CROSS, 0, 10, 1);
-    }
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "split_line(): End");
-
-    return 1;
-}
-
-void split_line(void)
-{
-    static struct split_line sl;
-
-    set_tool(split_line_begin, split_line_update, split_line_end, &sl);
-}
-
-/* Remove line vertex */
-struct rm_vertex
-{
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int last_line, last_seg;
-    double thresh;
-    double xo, yo;
-};
-
-int rm_vertex_begin(void *closure)
-{
-    struct rm_vertex *rv = closure;
-
-    G_debug(2, "remove_vertex()");
-
-    rv->Points = Vect_new_line_struct();
-    rv->Cats = Vect_new_cats_struct();
-
-    i_prompt("Remove vertex:");
-    i_prompt_buttons("Select vertex", "", "Quit tool");
-
-    rv->thresh = get_thresh();
-    G_debug(2, "thresh = %f", rv->thresh);
-
-    rv->last_line = 0;
-    rv->last_seg = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int rm_vertex_update(void *closure, int sxn, int syn, int button)
-{
-    struct rm_vertex *rv = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    if (rv->last_line == 0) {
-	i_prompt_buttons("Select vertex", "", "Quit tool");
-    }
-
-    if (rv->last_line > 0) {
-	display_line(rv->last_line, SYMB_DEFAULT, 1);
-    }
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    if (button == 3)
-	return 1;
-
-    if (button == 1) {		/* Select / new location */
-	int line;
-
-	if (rv->last_line > 0) {	/* Line is already selected */
-	    int node1, node2, type, np, i;
-
-	    display_line(rv->last_line, SYMB_BACKGROUND, 1);
-	    Vect_get_line_nodes(&Map, rv->last_line, &node1, &node2);
-	    display_node(node1, SYMB_BACKGROUND, 1);
-	    display_node(node2, SYMB_BACKGROUND, 1);
-	    symb_set_driver_color(SYMB_BACKGROUND);
-	    display_icon(rv->xo, rv->yo, G_ICON_BOX, 0, 10, 1);
-
-	    type = Vect_read_line(&Map, rv->Points, rv->Cats, rv->last_line);
-	    np = rv->Points->n_points;
-	    for (i = rv->last_seg; i < np - 1; i++) {
-		rv->Points->x[i] = rv->Points->x[i + 1];
-		rv->Points->y[i] = rv->Points->y[i + 1];
-		rv->Points->z[i] = rv->Points->z[i + 1];
-	    }
-	    rv->Points->n_points--;
-	    Vect_rewrite_line(&Map, rv->last_line, type, rv->Points,
-			      rv->Cats);
-	    updated_lines_and_nodes_erase_refresh_display();
-	    rv->last_line = 0;
-	}
-
-	/* Select vertex */
-	line =
-	    Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY, rv->thresh,
-			   0, 0);
-	G_debug(2, "line found = %d", line);
-
-	/* Display new selected line if any */
-	if (line > 0) {
-	    int seg;
-	    double dist;
-
-	    /* Find the nearest vertex on the line */
-	    Vect_read_line(&Map, rv->Points, NULL, line);
-	    seg =
-		Vect_line_distance(rv->Points, x, y, 0, 0, &rv->xo, &rv->yo,
-				   NULL, NULL, NULL, NULL);
-
-	    dist =
-		Vect_points_distance(rv->xo, rv->yo, 0,
-				     rv->Points->x[seg - 1],
-				     rv->Points->y[seg - 1], 0, 0);
-
-	    if (dist <
-		Vect_points_distance(rv->xo, rv->yo, 0, rv->Points->x[seg],
-				     rv->Points->y[seg], 0, 0)) {
-		seg -= 1;
-	    }
-
-	    rv->xo = rv->Points->x[seg];
-	    rv->yo = rv->Points->y[seg];
-
-	    display_line(line, SYMB_HIGHLIGHT, 1);
-	    symb_set_driver_color(SYMB_HIGHLIGHT);
-	    display_icon(rv->xo, rv->yo, G_ICON_BOX, 0, 10, 1);
-
-	    i_prompt_buttons("Confirm and select next", "Unselect",
-			     "Quit tool");
-	    rv->last_line = line;
-	    rv->last_seg = seg;
-	}
-    }
-    if (button == 2) {		/* Unselect */
-	if (rv->last_line > 0) {
-	    symb_set_driver_color(SYMB_BACKGROUND);
-	    display_icon(rv->xo, rv->yo, G_ICON_BOX, 0, 10, 1);
-	    rv->last_line = 0;
-	}
-    }
-
-    return 0;
-}
-
-int rm_vertex_end(void *closure)
-{
-    struct rm_vertex *rv = closure;
-
-    if (rv->last_line == 0) {
-	i_prompt_buttons("Select vertex", "", "Quit tool");
-    }
-
-    if (rv->last_line > 0) {
-	display_line(rv->last_line, SYMB_DEFAULT, 1);
-    }
-
-    if (rv->last_line > 0) {
-	symb_set_driver_color(SYMB_BACKGROUND);
-	display_icon(rv->xo, rv->yo, G_ICON_BOX, 0, 10, 1);
-    }
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "remove_vertex(): End");
-
-    return 1;
-}
-
-void rm_vertex(void)
-{
-    static struct rm_vertex rv;
-
-    set_tool(rm_vertex_begin, rm_vertex_update, rm_vertex_end, &rv);
-}
-
-/* Add new vertex to line */
-struct add_vertex
-{
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int last_line, last_seg;
-    int do_snap;
-    double thresh;
-};
-
-int add_vertex_begin(void *closure)
-{
-    struct add_vertex *av = closure;
-
-    G_debug(2, "add_vertex()");
-
-    av->Points = Vect_new_line_struct();
-    av->Cats = Vect_new_cats_struct();
-
-    i_prompt("Add vertex:");
-    i_prompt_buttons("Select", "", "Quit tool");
-
-    av->thresh = get_thresh();
-    G_debug(2, "thresh = %f", av->thresh);
-
-    av->last_line = 0;
-    av->last_seg = 0;
-    av->do_snap = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int add_vertex_update(void *closure, int sxn, int syn, int button)
-{
-    struct add_vertex *av = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    if (button == 3)
-	return 1;
-
-    if (av->last_line > 0) {
-	display_line(av->last_line, SYMB_DEFAULT, 1);
-    }
-
-    if (button == 1) {		/* Select line segment */
-	if (av->last_line == 0) {	/* Select line */
-	    int line =
-		Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY,
-			       av->thresh, 0, 0);
-	    G_debug(2, "line found = %d", line);
-
-	    /* Display new selected line if any */
-	    if (line > 0) {
-		int seg, len;
-		double xo, yo, px, py;
-		double dist;
-
-		display_line(line, SYMB_HIGHLIGHT, 1);
-
-		/* Find the nearest vertex on the line */
-		Vect_read_line(&Map, av->Points, NULL, line);
-		seg =
-		    Vect_line_distance(av->Points, x, y, 0, 0, &px, &py, NULL,
-				       NULL, NULL, NULL);
-
-		G_debug(3, "seg = %d", seg);
-
-		xo = (av->Points->x[seg - 1] + av->Points->x[seg]) / 2;
-		yo = (av->Points->y[seg - 1] + av->Points->y[seg]) / 2;
-
-		/* If close to first or last point insert before / after the line. 
-		 * 'close' is here < 1/4 of segment length */
-		av->do_snap = 0;
-		if (seg == 1) {
-		    dist =
-			Vect_points_distance(px, py, 0, av->Points->x[0],
-					     av->Points->y[0], 0, 0);
-		    len =
-			Vect_points_distance(av->Points->x[0],
-					     av->Points->y[0], 0,
-					     av->Points->x[1],
-					     av->Points->y[1], 0, 0);
-
-		    if (dist < len / 4) {
-			seg = 0;
-			xo = av->Points->x[0];
-			yo = av->Points->y[0];
-			av->do_snap = 1;
-		    }
-		}
-
-		if (seg == av->Points->n_points - 1) {
-		    int np = av->Points->n_points;
-		    double dist =
-			Vect_points_distance(px, py, 0, av->Points->x[np - 1],
-					     av->Points->y[np - 1], 0, 0);
-		    int len =
-			Vect_points_distance(av->Points->x[np - 2],
-					     av->Points->y[np - 2], 0,
-					     av->Points->x[np - 1],
-					     av->Points->y[np - 1], 0, 0);
-		    if (dist < len / 4) {
-			seg++;
-			xo = av->Points->x[np - 1];
-			yo = av->Points->y[np - 1];
-			av->do_snap = 1;
-		    }
-		}
-		G_debug(3, "seg 2 = %d", seg);
-
-		set_location(D_u_to_d_col(xo), D_u_to_d_row(yo));
-
-		i_prompt_buttons("New vertex", "Unselect", "Quit tool");
-		av->last_line = line;
-		av->last_seg = seg;
-	    }
-	}
-	else {			/* Line is already selected -> new vertex */
-	    int node1, node2, type, np, i;
-
-	    if (av->do_snap) {
-		snap(&x, &y);
-	    }
-	    display_line(av->last_line, SYMB_BACKGROUND, 1);
-	    Vect_get_line_nodes(&Map, av->last_line, &node1, &node2);
-	    display_node(node1, SYMB_BACKGROUND, 1);
-	    display_node(node2, SYMB_BACKGROUND, 1);
-
-	    type = Vect_read_line(&Map, av->Points, av->Cats, av->last_line);
-	    np = av->Points->n_points;
-	    /* insert vertex */
-	    Vect_append_point(av->Points, 0, 0, 0);
-	    for (i = np; i > av->last_seg; i--) {
-		av->Points->x[i] = av->Points->x[i - 1];
-		av->Points->y[i] = av->Points->y[i - 1];
-		av->Points->z[i] = av->Points->z[i - 1];
-	    }
-
-	    av->Points->x[av->last_seg] = x;
-	    av->Points->y[av->last_seg] = y;
-	    av->Points->z[av->last_seg] = 0;
-
-	    Vect_rewrite_line(&Map, av->last_line, type, av->Points,
-			      av->Cats);
-	    updated_lines_and_nodes_erase_refresh_display();
-	    av->last_line = 0;
-	}
-
-    }
-
-    if (button == 2) {		/* Unselect */
-	if (av->last_line > 0) {
-	    av->last_line = 0;
-	}
-    }
-
-    if (av->last_line == 0) {
-	i_prompt_buttons("Select", "", "Quit tool");
-	set_mode(MOUSE_POINT);
-    }
-    else
-	set_mode(MOUSE_LINE);
-
-    return 0;
-}
-
-int add_vertex_end(void *closure)
-{
-    struct add_vertex *av = closure;
-
-    if (av->last_line > 0) {
-	display_line(av->last_line, SYMB_DEFAULT, 1);
-    }
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "add_vertex(): End");
-
-    return 1;
-}
-
-void add_vertex(void)
-{
-    static struct add_vertex av;
-
-    set_tool(add_vertex_begin, add_vertex_update, add_vertex_end, &av);
-}
-
-/* Move vertex */
-
-struct move_vertex
-{
-    struct line_pnts *Points;
-    struct line_cats *Cats;
-    int last_line, last_seg;
-    double thresh;
-    double xo, yo;
-};
-
-int move_vertex_begin(void *closure)
-{
-    struct move_vertex *mv = closure;
-
-    G_debug(2, "move_vertex()");
-
-    mv->Points = Vect_new_line_struct();
-    mv->Cats = Vect_new_cats_struct();
-
-    i_prompt("Move vertex:");
-    i_prompt_buttons("Select", "", "Quit tool");
-
-    mv->thresh = get_thresh();
-    G_debug(2, "thresh = %f", mv->thresh);
-
-    mv->last_line = 0;
-    mv->last_seg = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int move_vertex_update(void *closure, int sxn, int syn, int button)
-{
-    struct move_vertex *mv = closure;
-    double x = D_d_to_u_col(sxn);
-    double y = D_d_to_u_row(syn);
-
-    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
-
-    if (mv->last_line > 0) {
-	display_line(mv->last_line, SYMB_DEFAULT, 1);
-    }
-
-    if (button == 3)
-	return 1;
-
-    if (button == 1) {		/* Select / new location */
-	if (mv->last_line == 0) {	/* Select line */
-	    int line = Vect_find_line(&Map, x, y, 0, GV_POINT | GV_LINE | GV_BOUNDARY,
-				      mv->thresh, 0, 0);
-
-	    G_debug(2, "line found = %d", line);
-
-	    /* Display new selected line if any */
-	    if (line > 0) {
-		int seg;
-		double xo, yo, dist;
-
-		display_line(line, SYMB_HIGHLIGHT, 1);
-
-		/* Find the nearest vertex on the line */
-		Vect_read_line(&Map, mv->Points, NULL, line);
-		seg =
-		    Vect_line_distance(mv->Points, x, y, 0, 0, &xo, &yo, NULL,
-				       NULL, NULL, NULL);
-
-		dist =
-		    Vect_points_distance(xo, yo, 0, mv->Points->x[seg - 1],
-					 mv->Points->y[seg - 1], 0, 0);
-
-		if (dist <
-		    Vect_points_distance(xo, yo, 0, mv->Points->x[seg],
-					 mv->Points->y[seg], 0, 0)) {
-		    seg -= 1;
-		}
-
-		mv->xo = mv->Points->x[seg];
-		mv->yo = mv->Points->y[seg];
-		set_location(D_u_to_d_col(mv->xo), D_u_to_d_row(mv->yo));
-
-
-		i_prompt_buttons("New location", "Unselect", "Quit tool");
-		mv->last_line = line;
-		mv->last_seg = seg;
-	    }
-	}
-	else {			/* Line is already selected */
-	    int type, node1, node2;
-
-	    if (mv->last_seg == 0 || mv->last_seg == mv->Points->n_points - 1) {
-		snap(&x, &y);
-	    }
-	    display_line(mv->last_line, SYMB_BACKGROUND, 1);
-	    Vect_get_line_nodes(&Map, mv->last_line, &node1, &node2);
-	    display_node(node1, SYMB_BACKGROUND, 1);
-	    display_node(node2, SYMB_BACKGROUND, 1);
-
-	    type = Vect_read_line(&Map, mv->Points, mv->Cats, mv->last_line);
-	    mv->Points->x[mv->last_seg] =
-		mv->Points->x[mv->last_seg] + x - mv->xo;
-	    mv->Points->y[mv->last_seg] =
-		mv->Points->y[mv->last_seg] + y - mv->yo;
-	    Vect_rewrite_line(&Map, mv->last_line, type, mv->Points,
-			      mv->Cats);
-	    updated_lines_and_nodes_erase_refresh_display();
-	    mv->last_line = 0;
-	}
-
-    }
-    if (button == 2) {		/* Unselect */
-	if (mv->last_line > 0) {
-	    mv->last_line = 0;
-	}
-    }
-
-
-    if (mv->last_line == 0) {
-	i_prompt_buttons("Select", "", "Quit tool");
-	set_mode(MOUSE_POINT);
-    }
-    else
-	set_mode(MOUSE_LINE);
-
-    return 0;
-}
-
-int move_vertex_end(void *closure)
-{
-    struct move_vertex *mv = closure;
-
-    if (mv->last_line > 0) {
-	display_line(mv->last_line, SYMB_DEFAULT, 1);
-    }
-
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "move_vertex(): End");
-
-    return 1;
-}
-
-void move_vertex(void)
-{
-    static struct move_vertex mv;
-
-    set_tool(move_vertex_begin, move_vertex_update, move_vertex_end, &mv);
-}

+ 0 - 260
vector/v.digit/zoom.c

@@ -1,260 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <grass/gis.h>
-#include <grass/Vect.h>
-#include <grass/raster.h>
-#include <grass/display.h>
-#include <grass/colors.h>
-#include "global.h"
-#include "proto.h"
-
-/* Zoom - select new window interactively in the monitor */
-struct zoom_window
-{
-    int mode;			/* 1 - first corner; 2 - first or second corner */
-    int next_mode;
-    int sxo, syo;
-};
-
-int zoom_window_begin(void *closure)
-{
-    struct zoom_window *zw = closure;
-
-    G_debug(2, "zoom_window()");
-
-    i_prompt("Zoom by window");
-    i_prompt_buttons("1. corner", "1. corner", "Quit");
-
-    zw->mode = 1;
-    zw->next_mode = 1;
-    zw->sxo = 0;
-    zw->syo = 0;
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int zoom_window_update(void *closure, int sxn, int syn, int button)
-{
-    struct zoom_window *zw = closure;
-
-    if (zw->mode == 1) {
-	i_prompt_buttons("1. corner", "2. corner", "Quit");
-	zw->next_mode = 2;
-    }
-
-    G_debug(2, "button = %d x = %d y = %d", button, sxn, syn);
-
-    if (button == 3)
-	return 1;
-
-    if (zw->mode == 2 && button == 2) {
-	double x1 = D_d_to_u_col(zw->sxo);
-	double y1 = D_d_to_u_row(zw->syo);
-	double x2 = D_d_to_u_col(sxn);
-	double y2 = D_d_to_u_row(syn);
-
-	G_debug(2, "x1 = %f x2 = %f y1 = %f y2 = %f", x1, x2, y1, y2);
-
-	window.north = y1 > y2 ? y1 : y2;
-	window.south = y1 < y2 ? y1 : y2;
-	window.west = x1 < x2 ? x1 : x2;
-	window.east = x1 > x2 ? x1 : x2;
-
-	G_debug(2, "w = %f e = %f n = %f s = %f", window.west, window.east,
-		window.north, window.south);
-
-	G_adjust_Cell_head(&window, 0, 0);
-	G_put_window(&window);
-	G_set_window(&window);
-
-	display_redraw();
-
-	i_prompt_buttons("1. corner", "1. corner", "Quit");
-	zw->next_mode = 1;
-    }
-
-    zw->sxo = sxn;
-    zw->syo = syn;
-    zw->mode = zw->next_mode;
-
-    set_mode(zw->mode == 2 ? MOUSE_BOX : MOUSE_POINT);
-    set_location(zw->sxo, zw->syo);
-
-    return 0;
-}
-
-int zoom_window_end(void *closure)
-{
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "zoom_window(): End");
-
-    return 1;
-}
-
-void zoom_window(void)
-{
-    static struct zoom_window zw;
-
-    set_tool(zoom_window_begin, zoom_window_update, zoom_window_end, &zw);
-}
-
-/* Zoom - in / out (centre unchanged) */
-int zoom_centre(double factor)
-{
-    double xc, yc, dx, dy;
-
-    G_debug(2, "zoom_centre()");
-
-    driver_open();
-
-    G_debug(2, "1 n = %f s = %f", window.north, window.south);
-
-    dx = (window.east - window.west) / 2;
-    dy = (window.north - window.south) / 2;
-    xc = (window.east + window.west) / 2;
-    yc = (window.north + window.south) / 2;
-
-    G_debug(2, "  yc = %f dy = %f", yc, dy);
-
-    window.north = yc + dy * factor;
-    window.south = yc - dy * factor;
-    window.east = xc + dx * factor;
-    window.west = xc - dx * factor;
-
-
-    G_debug(2, "2 n = %f s = %f", window.north, window.south);
-    G_adjust_Cell_head(&window, 0, 0);
-    G_debug(2, "3 n = %f s = %f", window.north, window.south);
-    G_put_window(&window);
-    G_set_window(&window);
-
-    display_redraw();
-
-    driver_close();
-
-    G_debug(3, "zoom_centre(): End");
-
-    return 1;
-}
-
-/* Zoom - pan */
-
-struct zoom_pan
-{
-    int dummy;			/* zoom_pan is stateless */
-};
-
-int zoom_pan_begin(void *closure)
-{
-    G_debug(2, "zoom_pan()");
-
-    i_prompt("Pan");
-    i_prompt_buttons("New center", "", "Quit");
-
-    set_mode(MOUSE_POINT);
-
-    return 0;
-}
-
-int zoom_pan_update(void *closure, int sxn, int syn, int button)
-{
-    G_debug(2, "button = %d x = %d y = %d", button, sxn, syn);
-
-    if (button == 3)
-	return 1;
-
-    if (button == 1) {
-	double x = D_d_to_u_col(sxn);
-	double y = D_d_to_u_row(syn);
-	double dx = (window.east - window.west) / 2;
-	double dy = (window.north - window.south) / 2;
-
-	window.north = y + dy;
-	window.south = y - dy;
-	window.east = x + dx;
-	window.west = x - dx;
-
-	G_debug(2, "w = %f e = %f n = %f s = %f", window.west, window.east,
-		window.north, window.south);
-	G_adjust_Cell_head(&window, 0, 0);
-	G_put_window(&window);
-	G_set_window(&window);
-
-	display_redraw();
-    }
-
-    return 0;
-}
-
-int zoom_pan_end(void *closure)
-{
-    i_prompt("");
-    i_prompt_buttons("", "", "");
-    i_coor(COOR_NULL, COOR_NULL);
-
-    G_debug(3, "zoom_pan(): End");
-
-    return 1;
-}
-
-void zoom_pan(void)
-{
-    static struct zoom_pan zp;
-
-    set_tool(zoom_pan_begin, zoom_pan_update, zoom_pan_end, &zp);
-}
-
-/* Zoom - default region */
-int zoom_default(void)
-{
-    struct Cell_head defwin;
-
-    G_debug(2, "zoom_default()");
-
-    driver_open();
-
-    G_get_default_window(&defwin);
-    G_put_window(&defwin);
-    G_set_window(&defwin);
-
-    display_redraw();
-
-    driver_close();
-
-    G_debug(3, "zoom_default(): End");
-
-    return 1;
-}
-
-/* Zoom - to region */
-int zoom_region(void)
-{
-    struct Cell_head win;
-    const char *mapset;
-
-    G_debug(2, "zoom_region()");
-
-    driver_open();
-
-    mapset = G_find_file2("windows", var_getc(VAR_ZOOM_REGION), NULL);
-    if (mapset == NULL) {
-	G_warning("Cannot find window '%s'", var_getc(VAR_ZOOM_REGION));
-	return 0;
-    }
-    G__get_window(&win, "windows", var_getc(VAR_ZOOM_REGION), mapset);
-    G_put_window(&win);
-    G_set_window(&win);
-
-    display_redraw();
-
-    driver_close();
-
-    G_debug(3, "zoom_region(): End");
-
-    return 1;
-}