[GRASS-SVN] r58419 - grass/trunk/gui/wxpython/vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 8 16:57:24 PST 2013
Author: martinl
Date: 2013-12-08 16:57:24 -0800 (Sun, 08 Dec 2013)
New Revision: 58419
Modified:
grass/trunk/gui/wxpython/vdigit/mapwindow.py
grass/trunk/gui/wxpython/vdigit/wxdisplay.py
Log:
wxGUI/vdigit: fix deleting areas
Modified: grass/trunk/gui/wxpython/vdigit/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/mapwindow.py 2013-12-08 23:13:29 UTC (rev 58418)
+++ grass/trunk/gui/wxpython/vdigit/mapwindow.py 2013-12-09 00:57:24 UTC (rev 58419)
@@ -6,7 +6,7 @@
Classes:
- mapwindow::VDigitWindow
-(C) 2011 by the GRASS Development Team
+(C) 2011-2013 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@@ -28,6 +28,7 @@
from core.globalvar import QUERYLAYER
from vdigit.dialogs import VDigitCategoryDialog, VDigitZBulkDialog, VDigitDuplicatesDialog
from gui_core import gselect
+from vdigit.wxdigit import GV_CENTROID
class VDigitWindow(BufferedMapWindow):
"""!A Buffered window extended for vector digitizer.
@@ -493,6 +494,7 @@
"queryLine", "breakLine", "typeConv"]:
# various tools -> unselected selected features
self.digit.GetDisplay().SetSelected([])
+
if action in ["moveLine", "moveVertex", "editLine"] and \
hasattr(self, "moveInfo"):
del self.moveInfo
@@ -599,7 +601,7 @@
if action in ("moveVertex",
"editLine"):
if len(self.digit.GetDisplay().GetSelected()) == 0:
- nselected = self.digit.GetDisplay().SelectLineByPoint(pos1)['point']
+ nselected = int(self.digit.GetDisplay().SelectLineByPoint(pos1)['line'] != -1)
if action == "editLine":
try:
@@ -633,7 +635,7 @@
"copyAttrs"):
if not hasattr(self, "copyCatsIds"):
# 'from' -> select by point
- nselected = self.digit.GetDisplay().SelectLineByPoint(pos1)['point']
+ nselected = int(self.digit.GetDisplay().SelectLineByPoint(pos1)['line'] != -1)
if nselected:
self.copyCatsList = self.digit.GetDisplay().GetSelected()
else:
@@ -642,8 +644,7 @@
# return number of selected features (by box/point)
nselected = self.digit.GetDisplay().SelectLinesByBox((pos1, pos2))
if nselected == 0:
- if self.digit.GetDisplay().SelectLineByPoint(pos1) is not None:
- nselected = 1
+ nselected = int(self.digit.GetDisplay().SelectLineByPoint(pos1)['line'] != -1)
if nselected > 0:
self.copyCatsIds = self.digit.GetDisplay().GetSelected()
@@ -660,17 +661,19 @@
len(self.digit.GetDisplay().GetSelected()) > 0:
nselected = 0
else:
- if action == 'moveLine':
- drawSeg = True
+ if action == 'deleteArea':
+ nselected = int(self.digit.GetDisplay().SelectAreaByPoint(pos1)['area'] != -1)
else:
- drawSeg = False
-
- nselected = self.digit.GetDisplay().SelectLinesByBox(bbox = (pos1, pos2),
- drawSeg = drawSeg)
- if nselected == 0:
- if self.digit.GetDisplay().SelectLineByPoint(pos1) is not None:
- nselected = 1
-
+ if action == 'moveLine':
+ drawSeg = True
+ else:
+ drawSeg = False
+
+ nselected = self.digit.GetDisplay().SelectLinesByBox(bbox = (pos1, pos2),
+ drawSeg = drawSeg)
+ if nselected == 0:
+ nselected = int(self.digit.GetDisplay().SelectLineByPoint(pos1)['line'] != -1)
+
if nselected > 0:
if action in ("moveLine", "moveVertex") and \
hasattr(self, "moveInfo"):
@@ -707,7 +710,7 @@
else: # no vector object found
if not (action in ("moveLine",
- "moveVertex") and \
+ "moveVertex") and \
hasattr(self, "moveInfo") and \
len(self.moveInfo['id']) > 0):
# avoid left-click when features are already selected
@@ -720,7 +723,7 @@
pos1 = self.Pixel2Cell(self.mouse['begin'])
pointOnLine = self.digit.GetDisplay().SelectLineByPoint(pos1)['point']
- if not pointOnLine:
+ if pointOnLine['line'] == -1:
return
if self.toolbar.GetAction() in ["splitLine", "addVertex"]:
@@ -817,6 +820,9 @@
def _onLeftUp(self, event):
"""!Left mouse button released"""
+ if event.ControlDown():
+ return
+
if hasattr(self, "moveInfo"):
if len(self.digit.GetDisplay().GetSelected()) == 0:
self.moveInfo['begin'] = self.Pixel2Cell(self.mouse['begin']) # left down
Modified: grass/trunk/gui/wxpython/vdigit/wxdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/wxdisplay.py 2013-12-08 23:13:29 UTC (rev 58418)
+++ grass/trunk/gui/wxpython/vdigit/wxdisplay.py 2013-12-09 00:57:24 UTC (rev 58419)
@@ -243,17 +243,14 @@
if not self.dc or not self.dcTmp:
return -1
- Debug.msg(3, "_drawObject(): line=%d type=%d npoints=%d", robj.fid, robj.type, robj.npoints)
+ Debug.msg(1, "_drawObject(): line=%d type=%d npoints=%d", robj.fid, robj.type, robj.npoints)
brush = None
if self._isSelected(robj.fid):
pdc = self.dcTmp
- if robj.type == TYPE_AREA:
- return 1
- else:
- if self.settings['highlightDupl']['enabled'] and self._isDuplicated(robj.fid):
- pen = wx.Pen(self.settings['highlightDupl']['color'], self.settings['lineWidth'], wx.SOLID)
- else:
- pen = wx.Pen(self.settings['highlight'], self.settings['lineWidth'], wx.SOLID)
+ if self.settings['highlightDupl']['enabled'] and self._isDuplicated(robj.fid):
+ pen = wx.Pen(self.settings['highlightDupl']['color'], self.settings['lineWidth'], wx.SOLID)
+ else:
+ pen = wx.Pen(self.settings['highlight'], self.settings['lineWidth'], wx.SOLID)
dcId = 1
self.topology['highlight'] += 1
@@ -262,6 +259,7 @@
else:
pdc = self.dc
pen, brush = self._definePen(robj.type)
+
dcId = 0
pdc.SetPen(pen)
@@ -508,13 +506,14 @@
return False
- def SelectLinesByBox(self, bbox, drawSeg = False, poMapInfo = None):
+ def SelectLinesByBox(self, bbox, ltype = None, drawSeg = False, poMapInfo = None):
"""!Select vector objects by given bounding box
If line id is already in the list of selected lines, then it will
be excluded from this list.
@param bbox bounding box definition
+ @param ltype feature type or None for default
@param drawSeg True to draw segments of line
@param poMapInfo use external Map_info, None for self.poMapInfo
@@ -545,9 +544,11 @@
Vect_append_point(poBbox, x1, y2, 0.0)
Vect_append_point(poBbox, x1, y1, 0.0)
+ if not ltype:
+ ltype = self._getSelectType()
Vect_select_lines_by_polygon(poMapInfo, poBbox,
0, None, # isles
- self._getSelectType(), poList)
+ ltype, poList)
flist = poList.contents
nlines = flist.n_values
@@ -580,7 +581,32 @@
return nlines
- def SelectLineByPoint(self, point, poMapInfo = None):
+ def SelectAreaByPoint(self, point, poMapInfo = None):
+ thisMapInfo = poMapInfo is None
+ if not poMapInfo:
+ poMapInfo = self.poMapInfo
+
+ if not poMapInfo:
+ return { 'area' : -1, 'centroid': -1 }
+
+ if thisMapInfo:
+ self._drawSelected = True
+
+ box = bound_box()
+ for area in range(1, Vect_get_num_areas(poMapInfo)+1):
+ Vect_get_area_box(poMapInfo, area, byref(box))
+ if Vect_point_in_area(point[0], point[1], poMapInfo, area, byref(box)) == 1:
+ centroid = Vect_get_area_centroid(poMapInfo, area)
+ if not self._isSelected(centroid):
+ self.selected['ids'].append(centroid)
+ else:
+ self.selected['ids'].remove(centroid)
+
+ return { 'area' : area, 'centroid' : centroid}
+
+ return { 'area' : -1, 'centroid': -1 }
+
+ def SelectLineByPoint(self, point, ltype = None, poMapInfo = None):
"""!Select vector feature by given point in given
threshold
@@ -588,6 +614,7 @@
all segments are stores.
@param point points coordinates (x, y)
+ @param ltype feature type or None for default
@param poMapInfo use external Map_info, None for self.poMapInfo
@return dict {'line' : feature id, 'point' : point on line}
@@ -606,9 +633,11 @@
poFound = Vect_new_list()
+ if ltype is None:
+ ltype = self._getSelectType()
lineNearest = Vect_find_line_list(poMapInfo, point[0], point[1], 0,
- self._getSelectType(), self.GetThreshold(), self.is3D,
- None, poFound)
+ ltype, self.GetThreshold(), self.is3D,
+ None, poFound)
Debug.msg(1, "DisplayDriver.SelectLineByPoint() found = %d", lineNearest)
if lineNearest > 0:
More information about the grass-commit
mailing list