[GRASS-SVN] r42968 - in grass/trunk/gui/wxpython: gui_modules icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 2 16:46:04 EDT 2010
Author: martinl
Date: 2010-08-02 20:46:04 +0000 (Mon, 02 Aug 2010)
New Revision: 42968
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
grass/trunk/gui/wxpython/icons/icon.py
Log:
wxGUI/nviz: various fixes cont'ed
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2010-08-02 20:13:13 UTC (rev 42967)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2010-08-02 20:46:04 UTC (rev 42968)
@@ -1448,6 +1448,9 @@
kind=wx.ITEM_CHECK)
toolsmenu.AppendItem(modify)
self.Bind(wx.EVT_MENU, self.OnQueryModify, modify)
+ if self.toolbars['nviz']:
+ modify.Enable(False)
+
digitToolbar = self.toolbars['vdigit']
if self.tree.layer_selected:
layer_selected = self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer']
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2010-08-02 20:13:13 UTC (rev 42967)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2010-08-02 20:46:04 UTC (rev 42968)
@@ -172,7 +172,6 @@
if dataType == 'layer':
return mapLayer
-
item = self.tree.FindItemByData('maplayer', mapLayer)
if not item:
return None
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-08-02 20:13:13 UTC (rev 42967)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-08-02 20:46:04 UTC (rev 42968)
@@ -408,29 +408,30 @@
while(len(listOfItems) > 0):
item = listOfItems.pop()
type = self.tree.GetPyData(item)[0]['type']
- if item not in self.layers:
- try:
- if type == 'raster':
- self.LoadRaster(item)
- elif type == '3d-raster':
- self.LoadRaster3d(item)
- except gcmd.GException, e:
- GError(parent = self,
- message = e)
-
- try:
- if type == 'vector':
- data = self.tree.GetPyData(item)[0]['nviz']
- vecType = []
- if data and data.has_key('vector'):
- for v in ('lines', 'points'):
- if data['vector'][v]:
- vecType.append(v)
- self.LoadVector(item, vecType)
- except gcmd.GException, e:
- GError(parent = self,
- message = e)
- self.init = False
+ if item in self.layers:
+ continue
+ try:
+ if type == 'raster':
+ self.LoadRaster(item)
+ elif type == '3d-raster':
+ self.LoadRaster3d(item)
+ elif type == 'vector':
+ # data = self.tree.GetPyData(item)[0]['nviz']
+ # vecType = []
+ # if data and data.has_key('vector'):
+ # for v in ('lines', 'points'):
+ # if data['vector'][v]:
+ # vecType.append(v)
+ layer = self.tree.GetPyData(item)[0]['maplayer']
+ npoints, nlines, nfeatures = self.lmgr.nviz.VectorInfo(layer)
+ if npoints > 0:
+ self.LoadVector(item, points = True)
+ if nlines > 0:
+ self.LoadVector(item, points = False)
+ except gcmd.GException, e:
+ GError(parent = self,
+ message = e)
+ self.init = False
stop = time.time()
@@ -488,7 +489,6 @@
type = self.tree.GetPyData(item)[0]['maplayer'].type
# reference to original layer properties (can be None)
data = self.tree.GetPyData(item)[0]['nviz']
-
if data is None:
# init data structure
self.tree.GetPyData(item)[0]['nviz'] = {}
@@ -656,50 +656,49 @@
win = toolWin.FindWindowById( \
toolWin.win['vector']['lines']['surface'])
win.SetItems(self.GetLayerNames(layer.type))
-
- # remove surface page
- if toolWin.GetSelection() == toolWin.page[nvizType]['id']:
- toolWin.RemovePage(toolWin.page[nvizType]['id'])
- toolWin.page[nvizType]['id'] = -1
- toolWin.page['settings']['id'] = 1
-
- def LoadVector(self, item, vecType = None):
+
+ def LoadVector(self, item, points = None):
"""!Load 2D or 3D vector map overlay
@param item layer item
- @param vecType vector type (lines / points)
+ @param points True to load points, False to load lines, None
+ to load both
"""
layer = self.tree.GetPyData(item)[0]['maplayer']
-
if layer.type != 'vector':
return
- if vecType is None:
- # load data type by default
- vecType = []
- for v in ('lines', 'points'):
- if UserSettings.Get(group = 'nviz', key = 'vector',
- subkey = [v, 'show']):
- vecType.append(v)
+ # if vecType is None:
+ # # load data type by default
+ # vecType = []
+ # for v in ('lines', 'points'):
+ # if UserSettings.Get(group = 'nviz', key = 'vector',
+ # subkey = [v, 'show']):
+ # vecType.append(v)
# set default properties
- self.SetMapObjProperties(item, -1, 'lines')
- self.SetMapObjProperties(item, -1, 'points')
+ if points is None:
+ self.SetMapObjProperties(item, -1, 'lines')
+ self.SetMapObjProperties(item, -1, 'points')
+ vecTypes = ('points', 'lines')
+ elif points:
+ self.SetMapObjProperties(item, -1, 'points')
+ vecTypes = ('points', )
+ else:
+ self.SetMapObjProperties(item, -1, 'lines')
+ vecTypes = ('lines', )
id = -1
- for type in vecType:
- if type == 'lines':
- id = self._display.LoadVector(str(layer.name), False)
+ for vecType in vecTypes:
+ if vecType == 'lines':
+ id = self._display.LoadVector(str(layer.GetName()), False)
else:
- id = self._display.LoadVector(str(layer.name), True)
-
+ id = self._display.LoadVector(str(layer.GetName()), True)
if id < 0:
print >> sys.stderr, "Nviz:" + _("Loading vector map <%(name)s> (%(type)s) failed") % \
- { 'name' : layer.name, 'type' : type }
- continue
-
+ { 'name' : layer.name, 'type' : vecType }
# update layer properties
- self.SetMapObjProperties(item, id, type)
+ self.SetMapObjProperties(item, id, vecType)
self.layers.append(item)
@@ -718,29 +717,36 @@
return id
- def UnloadVector(self, item, vecType = None):
+ def UnloadVector(self, item, points = None):
"""!Unload vector map overlay
@param item layer item
- @param vecType vector type (lines, points)
+ @param points,lines True to unload given feature type
"""
layer = self.tree.GetPyData(item)[0]['maplayer']
data = self.tree.GetPyData(item)[0]['nviz']['vector']
- if vecType is None:
- vecType = []
- for v in ('lines', 'points'):
- if UserSettings.Get(group = 'nviz', key = 'vector',
- subkey = [v, 'show']):
- vecType.append(v)
+ # if vecType is None:
+ # vecType = []
+ # for v in ('lines', 'points'):
+ # if UserSettings.Get(group = 'nviz', key = 'vector',
+ # subkey = [v, 'show']):
+ # vecType.append(v)
- for vtype in vecType:
- if not data[vtype].has_key('object'):
+ if points is None:
+ vecTypes = ('points', 'lines')
+ elif points:
+ vecTypes = ('points', )
+ else:
+ vecTypes = ('lines', )
+
+ for vecType in vecTypes:
+ if not data[vecType].has_key('object'):
continue
id = data[vtype]['object']['id']
- if vtype == 'lines':
+ if vecType == 'lines':
ret = self._display.UnloadVector(id, False)
else:
ret = self._display.UnloadVector(id, True)
@@ -751,8 +757,8 @@
print "Nviz:" + _("Vector map <%(name)s> (%(type)s) unloaded successfully") % \
{ 'name' : layer.name, 'type' : vtype }
- data[vtype].pop('object')
-
+ data[vecType].pop('object')
+
### self.layers.remove(id)
def Reset(self):
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2010-08-02 20:13:13 UTC (rev 42967)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2010-08-02 20:46:04 UTC (rev 42968)
@@ -1499,8 +1499,8 @@
return
layer = self.mapWindow.GetLayerByName(name, mapType = 'raster')
+ self.EnablePage('surface', True)
self.UpdateSurfacePage(layer, data, updateName = False)
- self.EnablePage('surface', True)
def OnSetVector(self, event):
"""!Vector map selected, update properties page"""
@@ -1512,8 +1512,8 @@
return
layer = self.mapWindow.GetLayerByName(name, mapType = 'vector')
+ self.EnablePage('vector', True)
self.UpdateVectorPage(layer, data, updateName = False)
- self.EnablePage('vector', True)
def OnSetRaster3D(self, event):
"""!3D Raster map selected, update surface page"""
@@ -1525,9 +1525,9 @@
return
layer = self.mapWindow.GetLayerByName(name, mapType = 'raster3d')
+ self.EnablePage('volume', True)
self.UpdateVolumePage(layer, data, updateName = False)
- self.EnablePage('volume', True)
-
+
def OnViewChange(self, event):
"""!Change view, render in quick mode"""
# find control
@@ -1969,18 +1969,22 @@
winId = event.GetId()
if winId == self.win['vector']['lines']['show']:
vecType = 'lines'
+ lines = True
+ points = False
else: # points
- vecType = 'points'
-
+ vecType = 'points'
+ lines = False
+ points = True
+
checked = event.IsChecked()
name = self.FindWindowById(self.win['vector']['map']).GetValue()
item = self.mapWindow.GetLayerByName(name, mapType = 'vector', dataType = 'item')
data = self.GetLayerData('vector')['vector']
if checked:
- self.mapWindow.LoadVector(item, (vecType,))
+ self.mapWindow.LoadVector(item, lines = lines, points = points)
else:
- self.mapWindow.UnloadVector(item, (vecType,))
+ self.mapWindow.UnloadVector(item, lines = lines, points = points)
self.UpdateVectorShow(vecType, checked)
@@ -2458,15 +2462,16 @@
elif pageId in ('surface', 'vector', 'volume'):
name = self.FindWindowById(self.win[pageId]['map']).GetValue()
data = self.GetLayerData(pageId)
- if pageId == 'surface':
- layer = self.mapWindow.GetLayerByName(name, mapType = 'raster')
- self.UpdateSurfacePage(layer, data['surface'])
- elif pageId == 'vector':
- layer = self.mapWindow.GetLayerByName(name, mapType = 'vector')
- self.UpdateVectorPage(layer, data['vector'])
- elif pageId == 'volume':
- layer = self.mapWindow.GetLayerByName(name, mapType = 'raster3d')
- self.UpdateVectorPage(layer, data['vector'])
+ if data:
+ if pageId == 'surface':
+ layer = self.mapWindow.GetLayerByName(name, mapType = 'raster')
+ self.UpdateSurfacePage(layer, data['surface'])
+ elif pageId == 'vector':
+ layer = self.mapWindow.GetLayerByName(name, mapType = 'vector')
+ self.UpdateVectorPage(layer, data['vector'])
+ elif pageId == 'volume':
+ layer = self.mapWindow.GetLayerByName(name, mapType = 'raster3d')
+ self.UpdateVectorPage(layer, data['vector'])
elif pageId == 'light':
zval = self.mapWindow.light['position']['z']
bval = self.mapWindow.light['bright']
@@ -2477,7 +2482,7 @@
self.FindWindowById(self.win['light']['ambient'][control]).SetValue(aval)
elif pageId == 'fringe':
win = self.FindWindowById(self.win['fringe']['surface'])
- win.SetValue(self.FindWindowById(self.win['raster']['map']).GetValue())
+ win.SetValue(self.FindWindowById(self.win['surface']['map']).GetValue())
self.Update()
self.pageChanging = False
@@ -2569,24 +2574,29 @@
# enable/disable res widget + set draw mode
self.SetSurfaceMode()
color = self.FindWindowById(self.win['surface']['draw']['wire-color'])
+
+ def VectorInfo(self, layer):
+ """!Get number of points/lines
- def UpdateVectorPage(self, layer, data, updateName = True):
- """!Update vector page"""
+ @param layer MapLayer instance
+
+ @return num of points/features (expect of points)
+ @return None
+ """
vInfo = gcmd.RunCommand('v.info',
parent = self,
read = True,
flags = 't',
- map = layer.name)
+ map = layer.GetName())
if not vInfo:
- return
-
- npoints = nprimitives = 0
+ return None
+
+ npoints = nlines = nprimitives = 0
for line in vInfo.splitlines():
key, value = line.split('=')
if key == 'map3d':
mapIs3D = int(value)
-
elif key == 'points':
npoints = int(value)
nprimitives = npoints
@@ -2595,16 +2605,22 @@
'centroids',
'faces',
'kernels'):
+ nlines = int(value)
nprimitives += int(value)
+ return (npoints, nlines, nprimitives)
+
+ def UpdateVectorPage(self, layer, data, updateName = True):
+ """!Update vector page"""
+ npoints, nlines, nfeatures = self.VectorInfo(layer)
if mapIs3D:
desc = _("Vector map is 3D")
enable = False
else:
desc = _("Vector map is 2D")
enable = True
- desc += " - " + _("%(primitives)d primitives (%(points)d points)") % \
- { 'primitives' : nprimitives, 'points' : npoints }
+ desc += " - " + _("%(features)d features (%(points)d points)") % \
+ { 'features' : nfeatures, 'points' : npoints }
if updateName:
self.FindWindowById(self.win['vector']['map']).SetValue(layer.name)
@@ -2624,7 +2640,7 @@
showLines.SetValue(True)
else:
showLines.SetValue(False)
- if nprimitives - npoints > 0:
+ if nlines > 0:
showLines.Enable(True)
else:
showLines.Enable(False)
Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py 2010-08-02 20:13:13 UTC (rev 42967)
+++ grass/trunk/gui/wxpython/icons/icon.py 2010-08-02 20:46:04 UTC (rev 42968)
@@ -192,21 +192,21 @@
"addvect" : MetaIcon (img=Icons["addvect"],
label=_("Add vector map layer (Ctrl+V)")),
"addcmd" : MetaIcon (img=Icons["addcmd"],
- label=_("Add command layer")),
+ label=_("Add command map layer")),
"addgrp" : MetaIcon (img=Icons["addgrp"],
- label=_("Add layer group")),
+ label=_("Add map layer group")),
"addovl" : MetaIcon (img=Icons["addovl"],
label=_("Add grid or vector labels overlay")),
"delcmd" : MetaIcon (img=Icons["delcmd"],
- label=_("Delete selected layer")),
+ label=_("Delete selected map layer")),
"quit" : MetaIcon (img=Icons["quit"],
label=_("Quit")),
"attrtable" : MetaIcon (img=Icons["attrtable"],
label=_("Show attribute table")),
"addrgb" : MetaIcon (img=Icons["addrgb"],
- label=_("Add RGB layer")),
+ label=_("Add RGB map layer")),
"addhis" : MetaIcon (img=Icons["addhis"],
- label=_("Add HIS layer")),
+ label=_("Add HIS map layer")),
"addshaded" : MetaIcon (img=Icons["addshaded"],
label=_("Add shaded relief map layer")),
"addrarrow" : MetaIcon (img=Icons["addrarrow"],
More information about the grass-commit
mailing list