[GRASS-SVN] r49923 - in grass/trunk/gui/wxpython: dbmgr mapdisp
vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Dec 26 15:02:39 EST 2011
Author: martinl
Date: 2011-12-26 12:02:39 -0800 (Mon, 26 Dec 2011)
New Revision: 49923
Modified:
grass/trunk/gui/wxpython/dbmgr/manager.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/vdigit/mapwindow.py
grass/trunk/gui/wxpython/vdigit/wxdigit.py
grass/trunk/gui/wxpython/vdigit/wxdisplay.py
Log:
wxGUI/vdigit: fix highlighting/deleting features from dbmgr
Modified: grass/trunk/gui/wxpython/dbmgr/manager.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/manager.py 2011-12-26 17:28:02 UTC (rev 49922)
+++ grass/trunk/gui/wxpython/dbmgr/manager.py 2011-12-26 20:02:39 UTC (rev 49923)
@@ -1260,12 +1260,12 @@
digitToolbar = self.mapdisplay.toolbars['vdigit']
if digitToolbar and digitToolbar.GetLayer() and \
digitToolbar.GetLayer().GetName() == self.vectorName:
-
- self.mapdisplay.digit.driver.SetSelected(cats, field=self.layer)
+ display = self.mapdisplay.GetMapWindow().GetDisplay()
+ display.SetSelected(cats, layer = self.layer)
if zoom:
- n, s, w, e = self.mapdisplay.digit.driver.GetRegionSelected()
- self.mapdisplay.Map.GetRegion(n=n, s=s, w=w, e=e,
- update=True)
+ n, s, w, e = display.GetRegionSelected()
+ self.mapdisplay.Map.GetRegion(n = n, s = s, w = w, e = e,
+ update = True)
else:
# add map layer with higlighted vector features
self.AddQueryMapLayer() # -> self.qlayer
@@ -2101,13 +2101,19 @@
wx.MessageBox(parent=self,
message=_('Nothing to delete.'),
caption=_('Message'), style=wx.CENTRE)
-
- if self.OnDataItemDelete(None):
+
+ display = None
+ if 'vdigit' in self.mapdisplay.toolbars:
digitToolbar = self.mapdisplay.toolbars['vdigit']
if digitToolbar and digitToolbar.GetLayer() and \
digitToolbar.GetLayer().GetName() == self.vectorName:
- self.mapdisplay.digit.driver.SetSelected(map(int, cats), field=self.layer)
- self.mapdisplay.digit.DeleteSelectedLines()
+ display = self.mapdisplay.GetMapWindow().GetDisplay()
+ display.SetSelected(map(int, cats), layer = self.layer)
+ self.mapdisplay.MapWindow.UpdateMap(render=True, renderVector=True)
+
+ if self.OnDataItemDelete(None):
+ if display:
+ self.mapdisplay.GetMapWindow().digit.DeleteSelectedLines()
else:
RunCommand('v.edit',
parent = self,
@@ -2115,7 +2121,7 @@
map = self.vectorName,
tool = 'delete',
cats = ListOfCatsToRange(cats))
-
+
self.mapdisplay.MapWindow.UpdateMap(render=True, renderVector=True)
def AddQueryMapLayer(self):
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2011-12-26 17:28:02 UTC (rev 49922)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2011-12-26 20:02:39 UTC (rev 49923)
@@ -182,7 +182,9 @@
self.decorationDialog = None # decoration/overlays
-
+ def GetMapWindow(self):
+ return self.MapWindow
+
def _addToolbarVDigit(self):
"""!Add vector digitizer toolbar
"""
Modified: grass/trunk/gui/wxpython/vdigit/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/mapwindow.py 2011-12-26 17:28:02 UTC (rev 49922)
+++ grass/trunk/gui/wxpython/vdigit/mapwindow.py 2011-12-26 20:02:39 UTC (rev 49923)
@@ -40,6 +40,11 @@
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
+ def GetDisplay(self):
+ if self.digit:
+ return self.digit.GetDisplay()
+ return None
+
def SetToolbar(self, toolbar):
"""!Set up related toolbar
"""
Modified: grass/trunk/gui/wxpython/vdigit/wxdigit.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/wxdigit.py 2011-12-26 17:28:02 UTC (rev 49922)
+++ grass/trunk/gui/wxpython/vdigit/wxdigit.py 2011-12-26 20:02:39 UTC (rev 49923)
@@ -507,25 +507,21 @@
# collect categories for delete if requested
if deleteRec:
- poCats = Vect_new_cats_struct()
poCatsDel = Vect_new_cats_struct()
for i in self._display.selected['ids']:
- if Vect_read_line(self.poMapInfo, None, poCats, i) < 0:
+ if Vect_read_line(self.poMapInfo, None, self.poCats, i) < 0:
Vect_destroy_cats_struct(poCatsDel)
self._error.ReadLine(i)
-
- cats = poCats.contents
+ cats = self.poCats.contents
for j in range(cats.n_cats):
Vect_cat_set(poCatsDel, cats.field[j], cats.cat[j])
-
- Vect_destroy_cats_struct(poCats)
# register changeset
changeset = self._addActionsBefore()
-
poList = self._display.GetSelectedIList()
nlines = Vedit_delete_lines(self.poMapInfo, poList)
+
Vect_destroy_list(poList)
self._display.selected['ids'] = list()
Modified: grass/trunk/gui/wxpython/vdigit/wxdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/wxdisplay.py 2011-12-26 17:28:02 UTC (rev 49922)
+++ grass/trunk/gui/wxpython/vdigit/wxdisplay.py 2011-12-26 20:02:39 UTC (rev 49923)
@@ -410,8 +410,9 @@
# select by id
if line in self.selected['ids']:
return True
- else:
+ else:
# select by cat
+ Vect_read_line(self.poMapInfo, None, self.poCats, line)
cats = self.poCats.contents
for i in range(cats.n_cats):
if cats.field[i] == self.selected['field'] and \
@@ -716,13 +717,34 @@
self._drawSelected = True
else:
self._drawSelected = False
-
+
+ self.selected['field'] = layer
if layer > 0:
- self.selected['field'] = layer
- self.selected['cats'] = ids
+ self.selected['cats'] = ids
+ self.selected['ids'] = list()
+ ### cidx is not up-to-date
+ # Vect_cidx_find_all(self.poMapInfo, layer, GV_POINTS | GV_LINES, lid, ilist)
+ nlines = Vect_get_num_lines(self.poMapInfo)
+ for line in range(1, nlines + 1):
+ if not Vect_line_alive(self.poMapInfo, line):
+ continue
+
+ ltype = Vect_read_line (self.poMapInfo, None, self.poCats, line)
+ if not (ltype & (GV_POINTS | GV_LINES)):
+ continue
+
+ found = False
+ cats = self.poCats.contents
+ for i in range(0, cats.n_cats):
+ for cat in self.selected['cats']:
+ if cats.cat[i] == cat:
+ found = True
+ break
+ if found:
+ self.selected['ids'].append(line)
else:
- field = -1
- self.selected['ids'] = ids
+ self.selected['ids'] = ids
+ self.selected['cats'] = []
def GetSelectedVertex(self, pos):
"""!Get PseudoDC vertex id of selected line
@@ -790,6 +812,34 @@
return returnId
+ def GetRegionSelected(self):
+ """!Get minimal region extent of selected features
+
+ @return n,s,w,e
+ """
+ regionBox = bound_box()
+ lineBox = bound_box()
+ setRegion = True
+
+ nareas = Vect_get_num_areas(self.poMapInfo)
+ for line in self.selected['ids']:
+ area = Vect_get_centroid_area(self.poMapInfo, line)
+
+ if area > 0 and area <= nareas:
+ if not Vect_get_area_box(self.poMapInfo, area, byref(lineBox)):
+ continue
+ else:
+ if not Vect_get_line_box(self.poMapInfo, line, byref(lineBox)):
+ continue
+
+ if setRegion:
+ Vect_box_copy(byref(regionBox), byref(lineBox))
+ setRegion = False
+ else:
+ Vect_box_extend(byref(regionBox), byref(lineBox))
+
+ return regionBox.N, regionBox.S, regionBox.W, regionBox.E
+
def DrawSelected(self, flag):
"""!Draw selected features
More information about the grass-commit
mailing list