[GRASS-SVN] r57632 - grass/branches/releasebranch_6_4/gui/wxpython/nviz
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 10 19:25:56 PDT 2013
Author: annakrat
Date: 2013-09-10 19:25:55 -0700 (Tue, 10 Sep 2013)
New Revision: 57632
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/nviz/mapwindow.py
grass/branches/releasebranch_6_4/gui/wxpython/nviz/tools.py
grass/branches/releasebranch_6_4/gui/wxpython/nviz/wxnviz.py
Log:
wxNviz: fix displaying 3d points on surface and with z coordinate (merge from trunk, r57631)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/nviz/mapwindow.py 2013-09-11 02:00:41 UTC (rev 57631)
+++ grass/branches/releasebranch_6_4/gui/wxpython/nviz/mapwindow.py 2013-09-11 02:25:55 UTC (rev 57632)
@@ -1305,8 +1305,10 @@
if (vInfo['points']) > 0:
# include vInfo['centroids'] to initially load centroids
self.LoadVector(item, points = True)
- if (vInfo['lines'] + vInfo['boundaries']) > 0 or vInfo['map3d']:
+ if (vInfo['lines'] + vInfo['boundaries']) > 0:
self.LoadVector(item, points = False)
+ if vInfo['map3d'] and (vInfo['kernels'] + vInfo['faces']) > 0:
+ self.LoadVector(item, points=None)
except GException, e:
GError(parent = self,
@@ -2109,17 +2111,21 @@
data['height'].pop('update')
# surface
- if 'update' in data['mode'] and 'surface' in data['mode']:
- for item in range(len(data['mode']['surface']['value'])):
- for type in ('raster', 'constant'):
- sid = self.GetLayerId(type = type,
- name = data['mode']['surface']['value'][item])
- if sid > -1:
- if data['mode']['surface']['show'][item]:
- self._display.SetVectorPointSurface(id, sid)
- else:
- self._display.UnsetVectorPointSurface(id, sid)
- break
+ if 'update' in data['mode']:
+ if data['mode'].get('3d', False):
+ self._display.SetVectorPointZMode(id, True)
+ elif 'surface' in data['mode']:
+ self._display.SetVectorPointZMode(id, False)
+ for item in range(len(data['mode']['surface']['value'])):
+ for type in ('raster', 'constant'):
+ sid = self.GetLayerId(type=type,
+ name=data['mode']['surface']['value'][item])
+ if sid > -1:
+ if data['mode']['surface']['show'][item]:
+ self._display.SetVectorPointSurface(id, sid)
+ else:
+ self._display.UnsetVectorPointSurface(id, sid)
+ break
data['mode'].pop('update')
def GetLayerNames(self, type):
Modified: grass/branches/releasebranch_6_4/gui/wxpython/nviz/tools.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/nviz/tools.py 2013-09-11 02:00:41 UTC (rev 57631)
+++ grass/branches/releasebranch_6_4/gui/wxpython/nviz/tools.py 2013-09-11 02:25:55 UTC (rev 57632)
@@ -1253,7 +1253,7 @@
choices = [_("on surface(s):"),
_("flat")])
self.win['vector']['lines']['flat'] = display.GetId()
- display.Bind(wx.EVT_CHOICE, self.OnVectorDisplay)
+ display.Bind(wx.EVT_CHOICE, self.OnVectorLinesMode)
gridSizer.Add(item = display, flag = wx.ALIGN_CENTER_VERTICAL |
wx.ALIGN_LEFT|wx.EXPAND, pos = (1, 1), span = (1,4))
@@ -1382,20 +1382,24 @@
vertSizer.Add(gridSizer, proportion = 0, flag = wx.EXPAND, border = 0)
# high
gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
- gridSizer.AddGrowableCol(1)
+
+ gridSizer.Add(item=wx.StaticText(parent=panel, label=_("Display")),
+ pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
+ display = wx.Choice(parent=panel)
+ self.win['vector']['points']['3d'] = display.GetId()
+ display.Bind(wx.EVT_CHOICE, self.OnVectorPointsMode)
+ gridSizer.Add(item=display,
+ pos=(0, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("Display on surface(s):")),
- pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
- gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Height above surface:")),
- pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
+ pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL)
surface = wx.CheckListBox(parent = panel, id = wx.ID_ANY, size = (-1, 60),
choices = [], style = wx.LB_NEEDED_SB)
surface.Bind(wx.EVT_CHECKLISTBOX, self.OnVectorSurface)
self.win['vector']['points']['surface'] = surface.GetId()
gridSizer.Add(item = surface,
- pos = (1, 0), span = (3, 1),
+ pos = (1, 0), span = (3, 2),
flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
self._createControl(panel, data = self.win['vector']['points'], name = 'height', size = -1,
@@ -1406,10 +1410,11 @@
self.FindWindowById(self.win['vector']['points']['height']['text']).SetValue(0)
gridSizer.Add(item = self.FindWindowById(self.win['vector']['points']['height']['slider']),
- pos = (2, 1),flag = wx.EXPAND|wx.ALIGN_CENTER_VERTICAL)
+ pos = (2, 2),flag = wx.EXPAND|wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = self.FindWindowById(self.win['vector']['points']['height']['text']),
- pos = (3, 1),
+ pos = (3, 2),
flag = wx.ALIGN_CENTER)
+ gridSizer.AddGrowableCol(2)
vertSizer.Add(gridSizer, proportion = 0, flag = wx.EXPAND, border = 0)
boxSizer.Add(item = vertSizer, proportion = 1,
@@ -3296,7 +3301,7 @@
event.Skip()
- def OnVectorDisplay(self, event):
+ def OnVectorLinesMode(self, event):
"""!Display vector lines on surface/flat"""
rasters = self.mapWindow.GetLayerNames('raster')
if event.GetSelection() == 0: # surface
@@ -3359,7 +3364,32 @@
if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
-
+
+ def OnVectorPointsMode(self, event):
+ rasters = self.mapWindow.GetLayerNames('raster')
+ if event.GetSelection() == 0: # surface
+ if len(rasters) < 1:
+ self.FindWindowById(self.win['vector']['points']['surface']).Enable(False)
+ self.FindWindowById(self.win['vector']['points']['flat']).SetSelection(1)
+ return
+
+ self.FindWindowById(self.win['vector']['points']['surface']).Enable(True)
+ # set first found surface
+ data = self.GetLayerData('vector')
+ data['vector']['points']['mode']['surface']['value'] = rasters
+ data['vector']['points']['mode']['3d'] = False
+ self.FindWindowById(self.win['vector']['points']['surface']).SetStringSelection( \
+ rasters[0])
+ else: # use z coordinate if 3d
+ data = self.GetLayerData('vector')
+ data['vector']['points']['mode']['3d'] = True
+ self.FindWindowById(self.win['vector']['points']['surface']).Enable(False)
+ data['vector']['points']['mode']['update'] = None
+
+ self.OnVectorPoints(event)
+
+ event.Skip()
+
def OnVectorHeight(self, event):
id = event.GetId()
if id in self.win['vector']['lines']['height'].values():
@@ -4553,7 +4583,18 @@
win.SetValue(color)
else:
win.SetValue(data['points'][prop]['value'])
-
+
+ win = self.FindWindowById(self.win['vector']['points']['3d'])
+ if vInfo['map3d']:
+ items = [_("on surface(s):"), _("as 3D")]
+ else:
+ items = [_("on surface")]
+ win.SetItems(items)
+ if data['points']['mode'].get('3d', False):
+ win.SetSelection(1)
+ else:
+ win.SetSelection(0)
+
# height
for type in ('slider', 'text'):
win = self.FindWindowById(self.win['vector']['points']['height'][type])
Modified: grass/branches/releasebranch_6_4/gui/wxpython/nviz/wxnviz.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/nviz/wxnviz.py 2013-09-11 02:00:41 UTC (rev 57631)
+++ grass/branches/releasebranch_6_4/gui/wxpython/nviz/wxnviz.py 2013-09-11 02:25:55 UTC (rev 57632)
@@ -1049,6 +1049,21 @@
return 1
+ def SetVectorPointZMode(self, id, zMode):
+ """!Set z mode (use z coordinate or not)
+
+ @param id volume id
+ @param zMode bool
+
+ @return -1 on failure
+ @return 0 when no 3d
+ @return 1 on success
+ """
+ if not GP_site_exists(id):
+ return -1
+
+ return GP_set_zmode(id, int(zMode))
+
def AddIsosurface(self, id, level, isosurf_id = None):
"""!Add new isosurface
More information about the grass-commit
mailing list