[GRASS-SVN] r30089 - in grass/trunk/gui/wxpython: gui_modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 11 11:34:45 EST 2008


Author: martinl
Date: 2008-02-11 11:34:45 -0500 (Mon, 11 Feb 2008)
New Revision: 30089

Modified:
   grass/trunk/gui/wxpython/gui_modules/digit.py
   grass/trunk/gui/wxpython/vdigit/digit.h
   grass/trunk/gui/wxpython/vdigit/line.cpp
Log:
wxGUI/vdigit: fix snapping to vertex for new feature or when editing existing feature

Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py	2008-02-11 16:21:39 UTC (rev 30088)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py	2008-02-11 16:34:45 UTC (rev 30089)
@@ -938,7 +938,10 @@
             for x in c:
                 listCoords.append(x)
 
-        return self.digit.RewriteLine(lineid, listCoords)
+        snap, thresh = self.__getSnapThreshold()
+        
+        return self.digit.RewriteLine(lineid, listCoords,
+                                      str(self.settings["backgroundMap"]), snap, thresh)
 
     def FlipLine(self):
         """Flip selected lines/boundaries"""

Modified: grass/trunk/gui/wxpython/vdigit/digit.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/digit.h	2008-02-11 16:21:39 UTC (rev 30088)
+++ grass/trunk/gui/wxpython/vdigit/digit.h	2008-02-11 16:34:45 UTC (rev 30089)
@@ -23,7 +23,8 @@
 
     int AddLine(int, std::vector<double>, int, int,
 		const char*, int, double);
-    int RewriteLine(int, std::vector<double>);
+    int RewriteLine(int, std::vector<double>,
+		    const char*, int, double);
     int SplitLine(double, double, double,
 		  double);
 

Modified: grass/trunk/gui/wxpython/vdigit/line.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/line.cpp	2008-02-11 16:21:39 UTC (rev 30088)
+++ grass/trunk/gui/wxpython/vdigit/line.cpp	2008-02-11 16:34:45 UTC (rev 30089)
@@ -116,7 +116,7 @@
     if (snap != NO_SNAP) { /* apply snapping (node or vertex) */
 	Vedit_snap_line(display->mapInfo, BgMap, nbgmaps,
 			-1, Points,
-			threshold, (SNAP) ? 0 : 1); 
+			threshold, (snap == SNAP) ? 0 : 1); 
     }
 
     if (Vect_write_line(display->mapInfo, type, Points, Cats) < 0) {
@@ -140,17 +140,24 @@
 
    \param line line id
    \param coords line geometry
+   \param bgmap  map of background map or NULL
+   \param snap   snapping mode (see vedit.h)
+   \param thresh threshold value for snapping
 
    \return new line id
    \return -1 error
 */
-int Digit::RewriteLine(int line, std::vector<double> coords)
+int Digit::RewriteLine(int line, std::vector<double> coords,
+		       const char *bgmap, int snap, double threshold)
 {
     int ret, type, dim;
     double x, y, z;
     struct line_pnts *points;
     struct line_cats *cats;
 
+    struct Map_info **BgMap; /* backgroud vector maps */
+    int nbgmaps;             /* number of registrated background maps */
+
     if (!display->mapInfo) {
 	return -1;
     }
@@ -159,6 +166,18 @@
     if (!Vect_line_alive(display->mapInfo, line)) {
 	return -1;
     }
+
+    BgMap = NULL;
+    nbgmaps = 0;
+    if (bgmap && strlen(bgmap) > 0) {
+	BgMap = OpenBackgroundVectorMap(bgmap);
+	if (!BgMap) {
+	    return -1;
+	}
+	else {
+	    nbgmaps = 1;
+	}
+    }
     
     ret = 0;
     points = Vect_new_line_struct();
@@ -186,6 +205,12 @@
 	}
     }
 
+    if (snap != NO_SNAP) { /* apply snapping (node or vertex) */
+	Vedit_snap_line(display->mapInfo, BgMap, nbgmaps,
+			-1, points,
+			threshold, (snap == SNAP) ? 0 : 1); 
+    }
+
     /* rewrite line */
     if (ret == 0) {
 	if (Vect_rewrite_line(display->mapInfo, line, type, points, cats) < 0) {
@@ -196,6 +221,10 @@
     Vect_destroy_line_struct(points);
     Vect_destroy_cats_struct(cats);
 
+    if (BgMap && BgMap[0]) {
+	Vect_close(BgMap[0]);
+    }
+
     return ret;
 }
 



More information about the grass-commit mailing list