[GRASS-SVN] r34303 - grass/trunk/vector/v.digit
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Nov 15 10:25:59 EST 2008
Author: neteler
Date: 2008-11-15 10:25:59 -0500 (Sat, 15 Nov 2008)
New Revision: 34303
Modified:
grass/trunk/vector/v.digit/attr.c
grass/trunk/vector/v.digit/line.c
grass/trunk/vector/v.digit/proto.h
grass/trunk/vector/v.digit/util.c
grass/trunk/vector/v.digit/vertex.c
Log:
marisn: Use user provided snapping threshold also for vertex selection in editing tools; Add point support to move vertex tool (merge from develbranch_6, r34292)
Modified: grass/trunk/vector/v.digit/attr.c
===================================================================
--- grass/trunk/vector/v.digit/attr.c 2008-11-15 15:21:48 UTC (rev 34302)
+++ grass/trunk/vector/v.digit/attr.c 2008-11-15 15:25:59 UTC (rev 34303)
@@ -190,8 +190,7 @@
i_prompt("Display categories:");
i_prompt_buttons("Select line", "", "Quit tool");
- /* TODO: use some better threshold */
- dc->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ dc->thresh = get_thresh();
G_debug(2, "thresh = %f", dc->thresh);
F_clear();
@@ -301,8 +300,7 @@
i_prompt("Copy attributes:");
i_prompt_buttons("Select source object", "", "Quit tool");
- /* TODO: use some better threshold */
- cc->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ cc->thresh = get_thresh();
G_debug(2, "thresh = %f", cc->thresh);
cc->src_line = 0;
@@ -462,8 +460,7 @@
i_prompt("Display attributes:");
i_prompt_buttons("Select line", "", "Quit tool");
- /* TODO: use some better threshold */
- da->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ da->thresh = get_thresh();
G_debug(2, "thresh = %f", da->thresh);
F_clear();
Modified: grass/trunk/vector/v.digit/line.c
===================================================================
--- grass/trunk/vector/v.digit/line.c 2008-11-15 15:21:48 UTC (rev 34302)
+++ grass/trunk/vector/v.digit/line.c 2008-11-15 15:25:59 UTC (rev 34303)
@@ -102,16 +102,8 @@
G_debug(2, "snap(): x = %f, y = %f", *x, *y);
- if (!var_geti(VAR_SNAP))
- return 0;
+ thresh = get_thresh();
- if (var_geti(VAR_SNAP_MODE) == SNAP_MAP) {
- thresh = var_getd(VAR_SNAP_MAP);
- }
- else {
- thresh = Scale * var_geti(VAR_SNAP_SCREEN);
- }
-
node = Vect_find_node(&Map, *x, *y, 0, thresh, 0);
if (node > 0)
@@ -285,8 +277,7 @@
i_prompt("Edit line or boundary:");
i_prompt_buttons("Select", "", "Quit tool");
- /* TODO: use some better threshold */
- el->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ el->thresh = get_thresh();
G_debug(2, "thresh = %f", el->thresh);
el->phase = 1;
@@ -470,8 +461,7 @@
i_prompt("Delete point, line, boundary, or centroid:");
i_prompt_buttons("Select", "Unselect", "Quit tool");
- /* TODO: use some better threshold */
- dl->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ dl->thresh = get_thresh();
G_debug(2, "thresh = %f", dl->thresh);
dl->line = 0;
@@ -610,8 +600,7 @@
i_prompt("Move point, line, boundary, or centroid:");
i_prompt_buttons("Select", "", "Quit tool");
- /* TODO: use some better threshold */
- ml->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ ml->thresh = get_thresh();
G_debug(2, "thresh = %f", ml->thresh);
ml->last_line = 0;
Modified: grass/trunk/vector/v.digit/proto.h
===================================================================
--- grass/trunk/vector/v.digit/proto.h 2008-11-15 15:21:48 UTC (rev 34302)
+++ grass/trunk/vector/v.digit/proto.h 2008-11-15 15:25:59 UTC (rev 34303)
@@ -137,6 +137,8 @@
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 **);
Modified: grass/trunk/vector/v.digit/util.c
===================================================================
--- grass/trunk/vector/v.digit/util.c 2008-11-15 15:21:48 UTC (rev 34302)
+++ grass/trunk/vector/v.digit/util.c 2008-11-15 15:25:59 UTC (rev 34303)
@@ -1,8 +1,10 @@
#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"
@@ -144,3 +146,17 @@
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));
+ }
+}
Modified: grass/trunk/vector/v.digit/vertex.c
===================================================================
--- grass/trunk/vector/v.digit/vertex.c 2008-11-15 15:21:48 UTC (rev 34302)
+++ grass/trunk/vector/v.digit/vertex.c 2008-11-15 15:25:59 UTC (rev 34303)
@@ -34,8 +34,7 @@
i_prompt("Split line:");
i_prompt_buttons("Select", "", "Quit tool");
- /* TODO: use some better threshold */
- sl->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ sl->thresh = get_thresh();
G_debug(2, "thresh = %f", sl->thresh);
sl->last_line = 0;
@@ -199,8 +198,7 @@
i_prompt("Remove vertex:");
i_prompt_buttons("Select vertex", "", "Quit tool");
- /* TODO: use some better threshold */
- rv->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ rv->thresh = get_thresh();
G_debug(2, "thresh = %f", rv->thresh);
rv->last_line = 0;
@@ -364,8 +362,7 @@
i_prompt("Add vertex:");
i_prompt_buttons("Select", "", "Quit tool");
- /* TODO: use some better threshold */
- av->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ av->thresh = get_thresh();
G_debug(2, "thresh = %f", av->thresh);
av->last_line = 0;
@@ -561,8 +558,7 @@
i_prompt("Move vertex:");
i_prompt_buttons("Select", "", "Quit tool");
- /* TODO: use some better threshold */
- mv->thresh = fabs(D_d_to_u_col(10) - D_d_to_u_col(0));
+ mv->thresh = get_thresh();
G_debug(2, "thresh = %f", mv->thresh);
mv->last_line = 0;
@@ -590,9 +586,9 @@
if (button == 1) { /* Select / new location */
if (mv->last_line == 0) { /* Select line */
- int line =
- Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY,
- mv->thresh, 0, 0);
+ 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 */
More information about the grass-commit
mailing list