[GRASS-SVN] r48284 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 13 18:13:45 EDT 2011


Author: martinl
Date: 2011-09-13 15:13:45 -0700 (Tue, 13 Sep 2011)
New Revision: 48284

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_vdigit.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxvdigit.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxvdriver.py
Log:
wxGUI/vdigit: fix copying feature from background map
             (merge r48282 from trunk)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_vdigit.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_vdigit.py	2011-09-13 22:09:46 UTC (rev 48283)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_vdigit.py	2011-09-13 22:13:45 UTC (rev 48284)
@@ -21,10 +21,11 @@
 import dbm_dialogs
 
 import gcmd
-from debug import Debug
+from debug          import Debug
 from mapdisp_window import BufferedWindow
-from preferences import globalSettings as UserSettings
-
+from preferences    import globalSettings as UserSettings
+from utils          import ListOfCatsToRange
+from globalvar      import QUERYLAYER
 from vdigit import VDigitCategoryDialog
 from vdigit import VDigitZBulkDialog
 from vdigit import VDigitDuplicatesDialog
@@ -705,7 +706,7 @@
         if UserSettings.Get(group = 'vdigit', key = 'bgmap',
                             subkey = 'value', internal = True) == '':
             # no background map -> copy from current vector map layer
-            nselected = self.digit.GetDisplay().SelectLinesByBox((pos1, pos2))
+            nselected = self.bdigit.GetDisplay().SelectLinesByBox((pos1, pos2))
             
             if nselected > 0:
                 # highlight selected features
@@ -714,17 +715,15 @@
                 self.UpdateMap(render = False, renderVector = False)
         else:
             # copy features from background map
-            self.copyIds += self.digit.SelectLinesFromBackgroundMap(bbox = (pos1, pos2))
+            self.copyIds = self.digit.SelectLinesFromBackgroundMap(bbox = (pos1, pos2))
             if len(self.copyIds) > 0:
                 color = UserSettings.Get(group = 'vdigit', key = 'symbol',
                                          subkey = ['highlight', 'color'])
-                colorStr = str(color[0]) + ":" + \
-                    str(color[1]) + ":" + \
-                    str(color[2])
+                colorStr = str(color[0]) + ":" + str(color[1]) + ":" + str(color[2])
                 dVectTmp = ['d.vect',
                             'map=%s' % UserSettings.Get(group = 'vdigit', key = 'bgmap',
                                                         subkey = 'value', internal = True),
-                            'cats=%s' % utils.ListOfCatsToRange(self.copyIds),
+                            'cats=%s' % ListOfCatsToRange(self.copyIds),
                             '-i',
                             'color=%s' % colorStr,
                             'fcolor=%s' % colorStr,
@@ -733,16 +732,16 @@
                 
                 if not self.layerTmp:
                     self.layerTmp = self.Map.AddLayer(type = 'vector',
-                                                      name = globalvar.QUERYLAYER,
+                                                      name = QUERYLAYER,
                                                       command = dVectTmp)
                 else:
                     self.layerTmp.SetCmd(dVectTmp)
-                
-                self.UpdateMap(render = True, renderVector = False)
             else:
-                self.UpdateMap(render = False, renderVector = False)
+                if self.layerTmp:
+                    self.Map.DeleteLayer(self.layerTmp)
+                    self.layerTmp = None
             
-            self.redrawAll = None
+            self.UpdateMap(render = True, renderVector = True)
             
     def OnLeftUpBulkLine(self, event):
         """!Left mouse button released - vector digitizer z-bulk line

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxvdigit.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxvdigit.py	2011-09-13 22:09:46 UTC (rev 48283)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxvdigit.py	2011-09-13 22:13:45 UTC (rev 48284)
@@ -196,7 +196,7 @@
         """
         name   = create_string_buffer(GNAME_MAX)
         mapset = create_string_buffer(GMAPSET_MAX)
-        if not G_name_is_fully_qualified(bgmap, name, mapset):
+        if not G__name_is_fully_qualified(bgmap, name, mapset):
             name   = str(bgmap)
             mapset = str(G_find_vector2(bgmap, ''))
         else:
@@ -1722,15 +1722,12 @@
         
         @return list of selected feature ids
         """
-        ret = list()
+        # try select features by box first
+        if self._display.SelectLinesByBox(bbox, poMapInfo = self.poBgMapInfo) < 1:
+            self._display.SelectLineByPoint(bbox[0], poMapInfo = self.poBgMapInfo)['line']
+            
+        return self._display.selected['ids']
         
-        # try select features by Box
-        ids = self._display.SelectLinesByBox(bbox, poMapInfo = self.poBgMapInfo)
-        if not ids:
-            ids = [self._display.SelectLineByPoint(bbox[0], poMapInfo = self.poBgMapInfo)['line'], ]
-        
-        return ids
-
     def GetUndoLevel(self):
         """!Get undo level (number of active changesets)
         

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxvdriver.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxvdriver.py	2011-09-13 22:09:46 UTC (rev 48283)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/wxvdriver.py	2011-09-13 22:13:45 UTC (rev 48284)
@@ -524,11 +524,6 @@
             # select by ids
             self.selected['cats'] = list()
         
-        if thisMapInfo:
-            selected = self.selected['ids']
-        else:
-            selected = list()
-        
         poList = Vect_new_list()
         x1, y1 = bbox[0]
         x2, y2 = bbox[1]
@@ -565,9 +560,9 @@
                     continue # skip lines just overlapping bbox
             
             if not self._isSelected(line):
-                selected.append(line)
+                self.selected['ids'].append(line)
             else:
-                selected.remove(line)
+                self.selected['ids'].remove(line)
         
         Vect_destroy_line_struct(poBbox)
         Vect_destroy_list(poList)
@@ -598,11 +593,6 @@
             # select by ids 
             self.selected['cats'] = list()
         
-        if thisMapInfo:
-            selected = self.selected['ids']
-        else:
-            selected = list()
-        
         poFound = Vect_new_list()
         
         lineNearest = Vect_find_line_list(poMapInfo, point[0], point[1], 0,
@@ -612,9 +602,9 @@
         
         if lineNearest > 0:
             if not self._isSelected(lineNearest):
-                selected.append(lineNearest)
+                self.selected['ids'].append(lineNearest)
             else:
-                selected.remove(lineNearest)
+                self.selected['ids'].remove(lineNearest)
         
         px = c_double()
         py = c_double()
@@ -632,14 +622,14 @@
 	    for i in range(found.n_values):
 		line = found.value[i]
 		if line != lineNearest:
-                    selected.append(line)
+                    self.selected['ids'].append(line)
 	    
             self.GetDuplicates()
 	    
 	    for i in range(found.n_values):
 		line = found.value[i]
 		if line != lineNearest and not self._isDuplicated(line):
-                    selected.remove(line)
+                    self.selected['ids'].remove(line)
         
         Vect_destroy_list(poFound)
         



More information about the grass-commit mailing list