[GRASS-SVN] r29960 - in grass/trunk/vector/v.edit: cmd lib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 5 15:35:51 EST 2008


Author: martinl
Date: 2008-02-05 15:35:51 -0500 (Tue, 05 Feb 2008)
New Revision: 29960

Modified:
   grass/trunk/vector/v.edit/cmd/main.c
   grass/trunk/vector/v.edit/lib/move.c
   grass/trunk/vector/v.edit/lib/vedit.h
Log:
v.edit: support snapping to background vector objects (node, vertex) also when object from edited vector map is moved

Modified: grass/trunk/vector/v.edit/cmd/main.c
===================================================================
--- grass/trunk/vector/v.edit/cmd/main.c	2008-02-05 18:41:41 UTC (rev 29959)
+++ grass/trunk/vector/v.edit/cmd/main.c	2008-02-05 20:35:51 UTC (rev 29960)
@@ -243,7 +243,8 @@
     case MODE_MOVE:
 	move_x = atof(params.move -> answers[0]);
 	move_y = atof(params.move -> answers[1]);
-	ret = Vedit_move_lines(&Map, List,
+	ret = Vedit_move_lines(&Map, BgMap, nbgmaps,
+			       List,
 			       move_x, move_y, 0.0, snap, thresh); /* TODO: 3D */
 	G_message(_("%d features moved"), ret);
 	break;

Modified: grass/trunk/vector/v.edit/lib/move.c
===================================================================
--- grass/trunk/vector/v.edit/lib/move.c	2008-02-05 18:41:41 UTC (rev 29959)
+++ grass/trunk/vector/v.edit/lib/move.c	2008-02-05 20:35:51 UTC (rev 29960)
@@ -19,6 +19,7 @@
    \brief Move selected features
    
    \param[in] Map vector map
+   \param[in] BgMap, nbgmaps list of background vector maps for snapping   
    \param[in] List list of features to be moved
    \param[in] move_x,move_y,move_z direction (move_z used only if map is 3D)
    \param[in] snap enable snapping (see globals.h)
@@ -26,7 +27,8 @@
    \return number of modified features
    \return -1 on error
 */
-int Vedit_move_lines(struct Map_info *Map, struct ilist *List, 
+int Vedit_move_lines(struct Map_info *Map, struct Map_info **BgMap, int nbgmaps,
+		     struct ilist *List,
 		     double move_x, double move_y, double move_z,
 		     int snap, double thresh)
 {
@@ -67,6 +69,12 @@
 		if (Vedit_snap_point(Map, line, &x[j], &y[j], &z[j], thresh,
 				     (snap == SNAPVERTEX) ? 1 : 0) == 0) {
 		    /* check also background maps */
+		    int bgi;
+		    for (bgi = 0; bgi < nbgmaps; bgi++) {
+			if (Vedit_snap_point(BgMap[i], line, &x[j], &y[j], &z[j], thresh,
+					     (snap == SNAPVERTEX) ? 1 : 0))
+			    break; /* snapped, don't continue */
+		    }
 		}
 	    }
         } /* for each point at line */

Modified: grass/trunk/vector/v.edit/lib/vedit.h
===================================================================
--- grass/trunk/vector/v.edit/lib/vedit.h	2008-02-05 18:41:41 UTC (rev 29959)
+++ grass/trunk/vector/v.edit/lib/vedit.h	2008-02-05 20:35:51 UTC (rev 29960)
@@ -43,7 +43,8 @@
 int Vedit_merge_lines(struct Map_info *, struct ilist *);
 
 /* move.c */
-int Vedit_move_lines(struct Map_info *, struct ilist *, 
+int Vedit_move_lines(struct Map_info *, struct Map_info **, int,
+		     struct ilist *, 
 		     double, double, double, int, double);
 
 /* select.c */



More information about the grass-commit mailing list