[GRASS-SVN] r46558 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jun 3 12:56:12 EDT 2011
Author: annakrat
Date: 2011-06-03 09:56:12 -0700 (Fri, 03 Jun 2011)
New Revision: 46558
Modified:
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
grass/trunk/gui/wxpython/gui_modules/workspace.py
grass/trunk/gui/wxpython/gui_modules/wxnviz.py
Log:
wxNviz: changes in vector panel, display on surface
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-06-03 16:42:11 UTC (rev 46557)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-06-03 16:56:12 UTC (rev 46558)
@@ -1051,7 +1051,7 @@
color = data['color']['value']
if data['mode']['type'] == 'flat':
flat = True
- if 'surface' in data:
+ if 'surface' in data['mode']:
data.pop('surface')
else:
flat = False
@@ -1073,12 +1073,17 @@
data['height'].pop('update')
# surface
- if 'update' in data['mode']:
- sid = self.GetLayerId(type = 'raster', name = data['mode']['surface'])
- if sid > -1:
- self._display.SetVectorLineSurface(id, sid)
-
- data['mode'].pop('update')
+ if 'surface' in data['mode']:
+ if 'update' in data['mode']['surface']:
+ for item in range(len(data['mode']['surface']['value'])):
+ sid = self.GetLayerId(type = 'raster', name = data['mode']['surface']['value'][item])
+ if sid > -1:
+ if data['mode']['surface']['show'][item]:
+ self._display.SetVectorLineSurface(id, sid)
+ else:
+ self._display.UnsetVectorLineSurface(id, sid)
+
+ data['mode']['surface'].pop('update')
def UpdateVectorPointsProperties(self, id, data):
"""!Update vector point map object properties"""
@@ -1110,12 +1115,17 @@
data['height'].pop('update')
# surface
- if 'update' in data['mode']['surface']:
- sid = self.GetLayerId(type = 'raster', name = data['mode']['surface']['value'])
- if sid > -1:
- ret = self._display.SetVectorPointSurface(id, sid)
- data['mode']['surface'].pop('update')
-
+ if 'surface' in data['mode']:
+ if 'update' in data['mode']['surface']:
+ for item in range(len(data['mode']['surface']['value'])):
+ sid = self.GetLayerId(type = 'raster', 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)
+ data['mode']['surface'].pop('update')
+
def GetLayerNames(self, type):
"""!Return list of map layer names of given type"""
layerName = []
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-06-03 16:42:11 UTC (rev 46557)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-06-03 16:56:12 UTC (rev 46558)
@@ -38,7 +38,7 @@
except ImportError: # if it's not there locally, try the wxPython lib.
try:
import wx.lib.agw.foldpanelbar as fpb
- except:
+ except ImportError:
import wx.lib.foldpanelbar as fpb # versions <=2.5.5.1
import grass.script as grass
@@ -165,8 +165,6 @@
try:
selectedRaster = self.mapWindow.Map.GetListOfLayers(l_type = 'raster')[0].GetName()
self.FindWindowById(self.win['surface']['map']).SetValue(selectedRaster)
- self.FindWindowById(self.win['vector']['lines']['surface']).SetValue(selectedRaster)
- self.FindWindowById(self.win['vector']['points']['surface']).SetValue(selectedRaster)
self.FindWindowById(self.win['fringe']['map']).SetValue(selectedRaster)
except IndexError:
pass
@@ -862,13 +860,14 @@
label = " %s " % (_("Vector lines")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+ gridSizer.AddGrowableCol(5)
# width
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Line:")),
pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("width")),
+ label = _("width:")),
pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL |
wx.ALIGN_RIGHT)
@@ -884,7 +883,7 @@
# color
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("color")),
+ label = _("color:")),
pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL |
wx.ALIGN_RIGHT)
@@ -899,43 +898,42 @@
# display
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("display")),
- pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL |
- wx.ALIGN_RIGHT)
+ label = _("Display")),
+ pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL |
+ wx.ALIGN_LEFT)
- display = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
- choices = [_("on surface"),
+ display = wx.Choice (parent = panel, id = wx.ID_ANY, size = (-1, -1),
+ choices = [_("on surface(s):"),
_("flat")])
self.win['vector']['lines']['flat'] = display.GetId()
display.Bind(wx.EVT_CHOICE, self.OnVectorDisplay)
gridSizer.Add(item = display, flag = wx.ALIGN_CENTER_VERTICAL |
- wx.ALIGN_LEFT, pos = (1, 2), span = (1,2))
+ wx.ALIGN_LEFT|wx.EXPAND, pos = (1, 1), span = (1,4))
# height
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Height above surface:")),
- pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL,
- span = (1, 3))
+ pos = (2, 5), flag = wx.ALIGN_BOTTOM|wx.EXPAND)
- surface = wx.ComboBox(parent = panel, id = wx.ID_ANY, size = (250, -1),
- style = wx.CB_SIMPLE | wx.CB_READONLY,
- choices = [])
- surface.Bind(wx.EVT_COMBOBOX, self.OnVectorSurface)
+ 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']['lines']['surface'] = surface.GetId()
gridSizer.Add(item = surface,
- pos = (2, 3), span = (1, 6),
- flag = wx.ALIGN_CENTER_VERTICAL)
+ pos = (2, 0), span = (3, 5),
+ flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
- self._createControl(panel, data = self.win['vector']['lines'], name = 'height', size = 300,
- range = (0, 1000),
+ self._createControl(panel, data = self.win['vector']['lines'], name = 'height', size = -1,
+ range = (0, 500), sliderHor = True,
bind = (self.OnVectorHeight, self.OnVectorHeightFull, self.OnVectorHeightText))
self.FindWindowById(self.win['vector']['lines']['height']['slider']).SetValue(0)
self.FindWindowById(self.win['vector']['lines']['height']['text']).SetValue(0)
gridSizer.Add(item = self.FindWindowById(self.win['vector']['lines']['height']['slider']),
- pos = (3, 0), span = (1, 7))
+ pos = (3, 5), flag = wx.EXPAND|wx.ALIGN_RIGHT)
gridSizer.Add(item = self.FindWindowById(self.win['vector']['lines']['height']['text']),
- pos = (3, 7),
+ pos = (4, 5),
flag = wx.ALIGN_CENTER)
boxSizer.Add(item = gridSizer, proportion = 1,
@@ -962,13 +960,14 @@
label = " %s " % (_("Vector points")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+ gridSizer.AddGrowableCol(5)
# icon size
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Icon:")),
pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("size")),
+ label = _("size:")),
pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL |
wx.ALIGN_RIGHT)
@@ -986,7 +985,7 @@
# icon color
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("color")),
+ label = _("color:")),
pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL |
wx.ALIGN_RIGHT)
icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
@@ -1002,7 +1001,7 @@
# icon width
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("width")),
- pos = (0, 5), flag = wx.ALIGN_CENTER_VERTICAL |
+ pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL |
wx.ALIGN_RIGHT)
iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
@@ -1014,13 +1013,12 @@
self.win['vector']['points']['width'] = iwidth.GetId()
iwidth.Bind(wx.EVT_SPINCTRL, self.OnVectorPoints)
iwidth.Bind(wx.EVT_TEXT, self.OnVectorPoints)
- gridSizer.Add(item = iwidth, pos = (0, 6),
+ gridSizer.Add(item = iwidth, pos = (1, 2),
flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
-
# icon symbol
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("symbol")),
- pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
+ label = _("symbol:")),
+ pos = (1, 3), flag = wx.ALIGN_CENTER_VERTICAL)
isym = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
choices = UserSettings.Get(group = 'nviz', key = 'vector',
subkey = ['points', 'marker'], internal = True))
@@ -1028,34 +1026,36 @@
self.win['vector']['points']['marker'] = isym.GetId()
isym.Bind(wx.EVT_CHOICE, self.OnVectorPoints)
gridSizer.Add(item = isym, flag = wx.ALIGN_CENTER_VERTICAL,
- pos = (1, 2), span = (1,2))
+ pos = (1, 4))
# high
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Display on surface(s):")),
+ pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL,
+ span = (1, 5))
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Height above surface:")),
- pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL,
- span = (1, 3))
+ pos = (3, 5), flag = wx.ALIGN_CENTER_VERTICAL)
- surface = wx.ComboBox(parent = panel, id = wx.ID_ANY, size = (250, -1),
- style = wx.CB_SIMPLE | wx.CB_READONLY,
- choices = [])
- surface.Bind(wx.EVT_COMBOBOX, self.OnVectorSurface)
+ 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 = (2, 3), span = (1, 5),
- flag = wx.ALIGN_CENTER_VERTICAL)
+ pos = (3, 0), span = (3, 5),
+ flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
- self._createControl(panel, data = self.win['vector']['points'], name = 'height', size = 300,
- range = (0, 1000),
+ self._createControl(panel, data = self.win['vector']['points'], name = 'height', size = -1,
+ range = (0, 500),
bind = (self.OnVectorHeight, self.OnVectorHeightFull, self.OnVectorHeightText))
self.FindWindowById(self.win['vector']['points']['height']['slider']).SetValue(0)
self.FindWindowById(self.win['vector']['points']['height']['text']).SetValue(0)
gridSizer.Add(item = self.FindWindowById(self.win['vector']['points']['height']['slider']),
- pos = (3, 0), span = (1, 7))
+ pos = (4, 5),flag = wx.EXPAND|wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = self.FindWindowById(self.win['vector']['points']['height']['text']),
- pos = (3, 7),
+ pos = (5, 5),
flag = wx.ALIGN_CENTER)
boxSizer.Add(item = gridSizer, proportion = 1,
@@ -1869,9 +1869,11 @@
self.mapWindow.render['quick'] = False
self.mapWindow.Refresh(False)
self.UpdateSettings()
-
- event.Skip()
-
+ try:# when calling event = None
+ event.Skip()
+ except AttributeError:
+ pass
+
def OnViewChangedText(self, event):
"""!View changed, render in full resolution"""
self.mapWindow.render['quick'] = False
@@ -2382,8 +2384,17 @@
mode = {}
if self.FindWindowById(self.win['vector']['lines']['flat']).GetSelection() == 0:
mode['type'] = 'surface'
- mode['surface'] = self.FindWindowById(self.win['vector']['lines']['surface']).GetValue()
- mode['update'] = None
+ mode['surface'] = {}
+ checklist = self.FindWindowById(self.win['vector']['lines']['surface'])
+ value = list()
+ checked = list()
+ for surface in range(checklist.GetCount()):
+ value.append(checklist.GetString(surface))
+ checked.append(checklist.IsChecked(surface))
+
+ mode['surface']['value'] = value
+ mode['surface']['show'] = checked
+ mode['surface']['update'] = None
else:
mode['type'] = 'flat'
@@ -2456,27 +2467,29 @@
# self.OnVectorHeight(event)
self.OnVectorHeightFull(event)
-
+
def OnVectorSurface(self, event):
- """!Reference surface for vector map (lines/points)"""
+ """!Reference surface for vector map (lines/points)"""
id = event.GetId()
if id == self.win['vector']['lines']['surface']:
vtype = 'lines'
else:
vtype = 'points'
-
- value = self.FindWindowById(id).GetValue()
+ checkList = self.FindWindowById(self.win['vector'][vtype]['surface'])
+ checked = checkList.IsChecked(event.GetInt())
+ surface = checkList.GetString(event.GetInt())
data = self.GetLayerData('vector')
- data['vector'][vtype]['mode']['surface'] = { 'value' : value,
- 'update' : None }
-
+ data['vector'][vtype]['mode']['surface'] = { 'value' : (surface,),
+ 'show' : (checked,),
+ 'update': None }
# update properties
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
if self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
+
def OnVectorPoints(self, event):
"""!Set vector points mode, apply changes if auto-rendering is enabled"""
@@ -3012,17 +3025,16 @@
display.SetSelection(1)
else:
display.SetSelection(0)
-
if data[vtype]['mode']['type'] == 'surface':
rasters = self.mapWindow.GetLayerNames('raster')
surface = self.FindWindowById(self.win['vector'][vtype]['surface'])
surface.SetItems(rasters)
if len(rasters) > 0:
- try:
- surface.SetStringSelection(data[vtype]['mode']['surface'])
- except:
- pass
-
+ for item in range(len(rasters)):
+ try:
+ surface.Check(item, data[vtype]['mode']['surface']['show'][item])
+ except (TypeError, IndexError, KeyError):
+ surface.Check(item, True)
for type in ('slider', 'text'):
win = self.FindWindowById(self.win['vector']['lines']['height'][type])
win.SetValue(data['lines']['height']['value'])
Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-06-03 16:42:11 UTC (rev 46557)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-06-03 16:56:12 UTC (rev 46558)
@@ -543,17 +543,14 @@
if UserSettings.Get(group='nviz', key='vector',
subkey=['lines', 'flat']):
type = 'flat'
- map = None
+
else:
- type = 'flat'
- map = None
-
+ type = 'surface'
+
data['mode'] = {}
data['mode']['type'] = type
data['mode']['update'] = None
- if map:
- data['mode']['surface'] = map
-
+
# height
data['height'] = { 'value' : UserSettings.Get(group='nviz', key='vector',
subkey=['lines', 'height']) }
Modified: grass/trunk/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2011-06-03 16:42:11 UTC (rev 46557)
+++ grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2011-06-03 16:56:12 UTC (rev 46558)
@@ -801,6 +801,28 @@
return 1
+ def UnsetVectorLineSurface(self, id, surf_id):
+ """!Unset reference surface of vector set (lines)
+
+ @param id vector set id
+ @param surf_id surface id
+
+ @return 1 on success
+ @return -1 vector set not found
+ @return -2 surface not found
+ @return -3 on failure
+ """
+ if not GV_vect_exists(id):
+ return -1
+
+ if not GS_surf_exists(surf_id):
+ return -2
+
+ if GV_unselect_surf(id, surf_id) < 0:
+ return -3
+
+ return 1
+
def SetVectorPointMode(self, id, color_str, width, size, marker):
"""!Set mode of vector point overlay
@@ -866,6 +888,28 @@
return 1
+ def UnsetVectorPointSurface(self, id, surf_id):
+ """!Unset reference surface of vector set (points)
+
+ @param id vector set id
+ @param surf_id surface id
+
+ @return 1 on success
+ @return -1 vector set not found
+ @return -2 surface not found
+ @return -3 on failure
+ """
+ if not GP_site_exists(id):
+ return -1
+
+ if not GS_surf_exists(surf_id):
+ return -2
+
+ if GP_unselect_surf(id, surf_id) < 0:
+ return -3
+
+ return 1
+
def AddIsosurface(self, id, level):
"""!Add new isosurface
More information about the grass-commit
mailing list