[GRASS-SVN] r31983 - in grass/branches/develbranch_6/gui/wxpython:
gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 3 11:21:56 EDT 2008
Author: martinl
Date: 2008-07-03 11:21:55 -0400 (Thu, 03 Jul 2008)
New Revision: 31983
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp
grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
Log:
wxGUI/vdigit:
* 'edit line' tool fixed, trac #214
* avoid adding lines with number of vertices < 2
(merged from trunk, r31982)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2008-07-03 15:16:24 UTC (rev 31982)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2008-07-03 15:21:55 UTC (rev 31983)
@@ -169,7 +169,8 @@
self.Bind(wx.EVT_IDLE, self.OnIdle)
self.Bind(wx.EVT_MOTION, self.MouseActions)
self.Bind(wx.EVT_MOUSE_EVENTS, self.MouseActions)
-
+ self.processMouse = True
+
#
# Render output objects
#
@@ -631,6 +632,7 @@
self.Draw(self.pdc, img=self.textdict[id], drawid=id,
pdctype='text', coords=[10, 10, 10, 10])
+ # optionally draw computational extent box
self.DrawCompRegionExtent()
#
@@ -767,7 +769,7 @@
"""
self.redrawAll = False
-
+
if not pdc:
return
@@ -884,12 +886,16 @@
"""
Mouse motion and button click notifier
"""
+ if not self.processMouse:
+ return
+
if self.redrawAll is False:
self.redrawAll = True
-
+
wheel = event.GetWheelRotation()
# zoom with mouse wheel
if wheel != 0:
+ self.processMouse = False
current = event.GetPositionTuple()[:]
Debug.msg (5, "BufferedWindow.MouseAction(): wheel=%d" % wheel)
# zoom 1/2 of the screen, centered to current mouse position (TODO: settings)
@@ -910,10 +916,12 @@
self.UpdateMap()
self.OnPaint(None)
-
+
# update statusbar
self.parent.StatusbarUpdate()
+ self.processMouse = True
+
# left mouse button pressed
elif event.LeftDown():
self.OnLeftDown(event)
@@ -965,6 +973,7 @@
elif event.Moving():
self.OnMouseMoving(event)
+
event.Skip()
def OnLeftDown(self, event):
@@ -1310,24 +1319,37 @@
if len(digitClass.driver.GetSelected()) == 0:
nselected = digitClass.driver.SelectLineByPoint(pos1, type=VDigit_Lines_Type)
if digitToolbar.action == "editLine":
+ try:
+ selVertex = digitClass.driver.GetSelectedVertex(pos1)[0]
+ except IndexError:
+ selVertex = None
+
+ if selVertex:
+ # self.UpdateMap(render=False)
+ ids = digitClass.driver.GetSelected(grassId=False)
+ # move this line to tmp layer
+ self.polycoords = []
+ for id in ids:
+ if id % 2: # register only vertices
+ self.moveIds.append(id)
+ e, n = self.Pixel2Cell(self.pdcVector.GetIdBounds(id)[0:2])
+ self.polycoords.append((e, n))
+ # self.pdcVector.RemoveId(id)
+ digitClass.driver.DrawSelected(False)
+
+ if selVertex < ids[-1] / 2:
+ # choose first or last node of line
+ self.moveIds.reverse()
+ self.polycoords.reverse()
+ else:
+ # unselect
+ digitClass.driver.SetSelected([])
+ del self.moveBegin
+ del self.moveCoords
+ del self.moveIds
+
self.UpdateMap(render=False)
- selVertex = digitClass.driver.GetSelectedVertex(pos1)[0]
- ids = digitClass.driver.GetSelected(grassId=False)
- # move this line to tmp layer
- self.polycoords = []
- for id in ids:
- if id % 2: # register only vertices
- self.moveIds.append(id)
- e, n = self.Pixel2Cell(self.pdcVector.GetIdBounds(id)[0:2])
- self.polycoords.append((e, n))
- self.pdcVector.RemoveId(id)
- if selVertex < ids[-1] / 2:
- # choose first or last node of line
- self.moveIds.reverse()
- self.polycoords.reverse()
- self.UpdateMap(render=False, renderVector=False)
-
elif digitToolbar.action == "copyCats":
if not hasattr(self, "copyCatsIds"):
# collect categories
@@ -1634,6 +1656,10 @@
line = True
else:
line = False
+
+ if len(self.polycoords) < 2: # ignore 'one-point' lines
+ return
+
digitClass.AddLine(map, line, self.polycoords)
position = self.Cell2Pixel(self.polycoords[-1])
@@ -1753,7 +1779,8 @@
if digitToolbar.action == "editLine":
# remove last vertex & line
- self.moveIds.pop()
+ if len(self.moveIds) > 1:
+ self.moveIds.pop()
self.UpdateMap(render=False, renderVector=False)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py 2008-07-03 15:16:24 UTC (rev 31982)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py 2008-07-03 15:21:55 UTC (rev 31983)
@@ -970,6 +970,10 @@
except:
lineid = -1
+ if len(coords) < 2:
+ self.DeleteSelectedLines()
+ return 0
+
listCoords = []
for c in coords:
for x in c:
@@ -1483,7 +1487,11 @@
"""
return self.__display.GetMapBoundingBox()
-
+
+ def DrawSelected(self, draw=True):
+ """Show/hide selected features"""
+ self.__display.DrawSelected(draw)
+
def UpdateSettings(self):
"""Update display driver settings"""
# TODO map units
Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp 2008-07-03 15:16:24 UTC (rev 31982)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp 2008-07-03 15:21:55 UTC (rev 31983)
@@ -168,7 +168,12 @@
else {
pen = new wxPen(settings.highlight, settings.lineWidth, wxSOLID);
}
- draw = true;
+ if (drawSelected) {
+ draw = true;
+ }
+ else {
+ draw = false;
+ }
dcId = 1;
topology.highlight++;
}
@@ -314,6 +319,9 @@
dcId = 0;
}
else {
+ if (!drawSelected) {
+ return -1;
+ }
if (settings.highlightDupl.enabled && IsDuplicated(line)) {
pen = new wxPen(settings.highlightDupl.color, settings.lineWidth, wxSOLID);
}
@@ -390,6 +398,9 @@
// determine color
if (IsSelected(line)) {
+ if (!drawSelected) {
+ return -1;
+ }
if (settings.highlightDupl.enabled && IsDuplicated(line)) {
pen = new wxPen(settings.highlightDupl.color, settings.lineWidth, wxSOLID);
}
@@ -767,6 +778,7 @@
struct line_pnts *bbox;
drawSegments = false;
+ drawSelected = true;
list = Vect_new_list();
bbox = Vect_new_line_struct();
@@ -818,6 +830,8 @@
std::vector<double> p;
+ drawSelected = true;
+
line = Vect_find_line(mapInfo, x, y, z,
type, thresh, with_z, 0);
@@ -965,6 +979,8 @@
*/
int DisplayDriver::SetSelected(std::vector<int> id)
{
+ drawSelected = true;
+
VectorToList(selected, id);
if (selected->n_values <= 0)
@@ -1205,3 +1221,15 @@
return 0;
}
+
+/**
+ \brief Draw selected features
+
+ \param draw if true draw selected features
+*/
+void DisplayDriver::DrawSelected(bool draw)
+{
+ drawSelected = draw;
+
+ return;
+}
Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h 2008-07-03 15:16:24 UTC (rev 31982)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h 2008-07-03 15:21:55 UTC (rev 31983)
@@ -57,6 +57,7 @@
struct ilist *selected;
struct ilist *selectedDupl;
+ bool drawSelected;
bool drawSegments; // draw segments of selected line
@@ -169,6 +170,7 @@
int SetSelected(std::vector<int>);
int UnSelect(std::vector<int>);
std::vector<int> GetSelectedVertex(double, double, double);
+ void DrawSelected(bool);
/* general */
int CloseMap();
More information about the grass-commit
mailing list