[GRASS-SVN] r42355 - in grass/trunk/gui/wxpython: gui_modules icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 26 16:02:23 EDT 2010
Author: martinl
Date: 2010-05-26 16:02:22 -0400 (Wed, 26 May 2010)
New Revision: 42355
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/toolbars.py
grass/trunk/gui/wxpython/gui_modules/wxnviz.py
grass/trunk/gui/wxpython/icons/grass_icons.py
grass/trunk/gui/wxpython/icons/icon.py
Log:
wxGUI/nviz: minor clean up (nviz_mapdisp)
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2010-05-26 14:26:05 UTC (rev 42354)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2010-05-26 20:02:22 UTC (rev 42355)
@@ -308,9 +308,10 @@
Add defined toolbar to the window
Currently known toolbars are:
- - map basic map toolbar
- - digit vector digitizer
- - georect georectifier
+ - 'map' - basic map toolbar
+ - 'vdigit' - vector digitizer
+ - 'georect' - georectifier
+ - 'nviz' - 3D view mode
"""
# default toolbar
if name == "map":
@@ -377,7 +378,7 @@
# nviz
elif name == "nviz":
import nviz
-
+
# check for GLCanvas and OpenGL
msg = None
if not nviz.haveGLCanvas:
@@ -389,7 +390,7 @@
msg = _("Unable to switch to 3D display mode.\nThe Nviz python extension "
"was not found or loaded properly.\n"
"Switching back to 2D display mode.\n\nDetails: %s" % nviz.errorMsg)
-
+
if msg:
self.toolbars['map'].combo.SetValue (_("2D view"))
wx.MessageBox(parent=self,
@@ -397,13 +398,13 @@
caption=_("Error"),
style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
return
-
+
#
# add Nviz toolbar and disable 2D display mode tools
#
self.toolbars['nviz'] = toolbars.NvizToolbar(self, self.Map)
self.toolbars['map'].Enable2D(False)
-
+
#
# update layer tree (-> enable 3d-rasters)
#
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2010-05-26 14:26:05 UTC (rev 42354)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2010-05-26 20:02:22 UTC (rev 42355)
@@ -483,20 +483,20 @@
If self.redrawAll is False on self.pdcTmp content is re-drawn
"""
Debug.msg(4, "BufferedWindow.OnPaint(): redrawAll=%s" % self.redrawAll)
-
+
dc = wx.BufferedPaintDC(self, self.buffer)
### dc.SetBackground(wx.Brush("White"))
dc.Clear()
-
+
# use PrepareDC to set position correctly
self.PrepareDC(dc)
-
+
# create a clipping rect from our position and size
# and update region
rgn = self.GetUpdateRegion().GetBox()
dc.SetClippingRect(rgn)
-
+
switchDraw = False
if self.redrawAll is None:
self.redrawAll = True
@@ -505,7 +505,7 @@
if self.redrawAll: # redraw pdc and pdcVector
# draw to the dc using the calculated clipping rect
self.pdc.DrawToDCClipped(dc, rgn)
-
+
# draw vector map layer
if self.pdcVector:
# decorate with GDDC (transparency)
@@ -515,13 +515,13 @@
except NotImplementedError, e:
print >> sys.stderr, e
self.pdcVector.DrawToDCClipped(dc, rgn)
-
+
self.bufferLast = None
else: # do not redraw pdc and pdcVector
if self.bufferLast is None:
# draw to the dc
self.pdc.DrawToDC(dc)
-
+
if self.pdcVector:
# decorate with GDDC (transparency)
try:
@@ -534,11 +534,11 @@
# store buffered image
# self.bufferLast = wx.BitmapFromImage(self.buffer.ConvertToImage())
self.bufferLast = dc.GetAsBitmap(wx.Rect(0, 0, self.Map.width, self.Map.height))
-
+
pdcLast = self.PseudoDC(vdigit = False)
pdcLast.DrawBitmap(self.bufferLast, 0, 0, False)
pdcLast.DrawToDC(dc)
-
+
# draw decorations (e.g. region box)
try:
gcdc = wx.GCDC(dc)
@@ -546,14 +546,14 @@
except NotImplementedError, e:
print >> sys.stderr, e
self.pdcDec.DrawToDC(dc)
-
+
# draw temporary object on the foreground
### self.pdcTmp.DrawToDCClipped(dc, rgn)
self.pdcTmp.DrawToDC(dc)
-
+
if switchDraw:
self.redrawAll = False
-
+
def OnSize(self, event):
"""!
Scale map image so that it is
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-05-26 14:26:05 UTC (rev 42354)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-05-26 20:02:22 UTC (rev 42355)
@@ -63,11 +63,11 @@
class GLWindow(MapWindow, glcanvas.GLCanvas):
"""!OpenGL canvas for Map Display Window"""
def __init__(self, parent, id,
- pos=wx.DefaultPosition,
- size=wx.DefaultSize,
- style=wx.NO_FULL_REPAINT_ON_RESIZE,
- Map=None, tree=None, lmgr=None):
-
+ pos = wx.DefaultPosition,
+ size = wx.DefaultSize,
+ style = wx.NO_FULL_REPAINT_ON_RESIZE,
+ Map = None, tree = None, lmgr = None):
+
self.parent = parent # MapFrame
self.Map = Map
self.tree = tree
@@ -86,7 +86,7 @@
# do not render vector lines in quick mode
'vlines' : False,
'vpoints' : False }
-
+
# list of loaded map layers (layer tree items)
self.layers = []
@@ -94,7 +94,7 @@
# use display region instead of computational
#
os.environ['GRASS_REGION'] = self.Map.SetRegion()
-
+
#
# create nviz instance
#
@@ -109,15 +109,17 @@
self.nvizThread.start()
time.sleep(.1)
self.nvizClass = self.nvizThread.nvizClass
-
+
# GRASS_REGION needed only for initialization
del os.environ['GRASS_REGION']
+ self.img = wx.Image(self.Map.mapfile, wx.BITMAP_TYPE_ANY)
+
#
# default values
#
- self.view = copy.deepcopy(UserSettings.Get(group='nviz', key='view')) # copy
- self.iview = UserSettings.Get(group='nviz', key='view', internal=True)
+ self.view = copy.deepcopy(UserSettings.Get(group = 'nviz', key = 'view')) # copy
+ self.iview = UserSettings.Get(group = 'nviz', key = 'view', internal = True)
self.nvizDefault = NvizDefault()
self.size = None
@@ -128,7 +130,7 @@
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
self.Bind(wx.EVT_MOTION, self.OnMouseAction)
self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseAction)
-
+
self.Bind(EVT_UPDATE_PROP, self.UpdateMapObjProperties)
self.Bind(EVT_UPDATE_VIEW, self.UpdateView)
@@ -137,14 +139,14 @@
def OnClose(self, event):
# cleanup when window actually closes (on quit) and not just is hidden
self.Reset()
-
+
def OnEraseBackground(self, event):
pass # do nothing, to avoid flashing on MSW
-
+
def OnSize(self, event):
self.size = self.parent.GetClientSize()
if self.GetContext():
- Debug.msg(3, "GLCanvas.OnSize(): w=%d, h=%d" % \
+ Debug.msg(3, "GLCanvas.OnSize(): w = %d, h = %d" % \
(self.size.width, self.size.height))
self.SetCurrent()
self.nvizClass.ResizeWindow(self.size.width,
@@ -154,14 +156,14 @@
def OnPaint(self, event):
Debug.msg(3, "GLCanvas.OnPaint()")
-
+
dc = wx.PaintDC(self)
self.SetCurrent()
if not self.initView:
self.nvizClass.InitView()
self.initView = True
-
+
self.LoadDataLayers()
self.UnloadDataLayers()
@@ -172,22 +174,22 @@
self.parent.nvizToolWin.UpdatePage('view')
layer = self.GetSelectedLayer()
if layer:
- if layer.type == 'raster':
+ if layer.type == 'raster':
self.parent.nvizToolWin.UpdatePage('surface')
- elif layer.type == 'vector':
+ elif layer.type == 'vector':
self.parent.nvizToolWin.UpdatePage('vector')
-
+
self.parent.nvizToolWin.UpdateSettings()
-
+
# update widgets
win = self.parent.nvizToolWin.FindWindowById( \
self.parent.nvizToolWin.win['vector']['lines']['surface'])
win.SetItems(self.GetLayerNames('raster'))
-
+
self.init = True
self.UpdateMap()
-
+
def OnMouseAction(self, event):
# change position
if event.Dragging() and event.LeftIsDown():
@@ -195,25 +197,25 @@
### self.x, self.y = event.GetPosition()
### self.Refresh(False)
pass
-
+
# change perspective with mouse wheel
wheel = event.GetWheelRotation()
-
- if wheel != 0:
+
+ if wheel != 0:
current = event.GetPositionTuple()[:]
- Debug.msg (5, "GLWindow.OnMouseMotion(): wheel=%d" % wheel)
+ Debug.msg (5, "GLWindow.OnMouseMotion(): wheel = %d" % wheel)
prev_value = self.view['persp']['value']
if wheel > 0:
value = -1 * self.view['persp']['step']
else:
value = self.view['persp']['step']
- self.view['persp']['value'] += value
+ self.view['persp']['value'] += value
if self.view['persp']['value'] < 1:
self.view['persp']['value'] = 1
elif self.view['persp']['value'] > 100:
self.view['persp']['value'] = 100
-
- if prev_value != self.view['persp']['value']:
+
+ if prev_value != self.view['persp']['value']:
if hasattr(self.parent, "nvizToolWin"):
self.parent.nvizToolWin.UpdateSettings()
@@ -221,48 +223,46 @@
self.iview['height']['value'],
self.view['persp']['value'],
self.view['twist']['value'])
-
+
# redraw map
self.OnPaint(None)
-
+
# update statusbar
### self.parent.StatusbarUpdate()
-
+
def OnLeftDown(self, event):
self.CaptureMouse()
- ### self.x, self.y = self.lastX, self.lastY = event.GetPosition()
-
+
def OnLeftUp(self, event):
self.ReleaseMouse()
-
+
def UpdateView(self, event):
"""!Change view settings"""
self.nvizClass.SetView(self.view['pos']['x'], self.view['pos']['y'],
self.iview['height']['value'],
self.view['persp']['value'],
self.view['twist']['value'])
-
+
if event and event.zExag:
self.nvizClass.SetZExag(self.view['z-exag']['value'])
if event: event.Skip()
- def UpdateMap(self, render=True):
- """
- Updates the canvas anytime there is a change to the
+ def UpdateMap(self, render = True):
+ """!Updates the canvas anytime there is a change to the
underlaying images or to the geometry of the canvas.
-
+
@param render re-render map composition
"""
start = time.clock()
-
+
self.resize = False
if self.render['quick'] is False:
self.parent.statusbarWin['progress'].Show()
self.parent.statusbarWin['progress'].SetRange(2)
self.parent.statusbarWin['progress'].SetValue(0)
-
+
if self.render['quick'] is False:
self.parent.statusbarWin['progress'].SetValue(1)
self.nvizClass.Draw(False, -1)
@@ -270,58 +270,55 @@
# quick
mode = wxnviz.DRAW_QUICK_SURFACE | wxnviz.DRAW_QUICK_VOLUME
if self.render['vlines']:
- mode |= wxnviz.DRAW_QUICK_VLINES
+ mode |= wxnviz.DRAW_QUICK_VLINES
if self.render['vpoints']:
- mode |= wxnviz.DRAW_QUICK_VPOINTS
+ mode |= wxnviz.DRAW_QUICK_VPOINTS
self.nvizClass.Draw(True, mode)
else: # None -> reuse last rendered image
pass # TODO
-
+
self.SwapBuffers()
-
+
stop = time.clock()
-
+
if self.render['quick'] is False:
self.parent.statusbarWin['progress'].SetValue(2)
# hide process bar
self.parent.statusbarWin['progress'].Hide()
-
+
#
# update statusbar
#
# self.parent.StatusbarUpdate()
-
- Debug.msg(3, "GLWindow.UpdateMap(): quick=%d, -> time=%g" % \
+
+ Debug.msg(3, "GLWindow.UpdateMap(): quick = %d, -> time = %g" % \
(self.render['quick'], (stop-start)))
-
- # print stop-start
-
+
def EraseMap(self):
+ """!Erase the canvas
"""
- Erase the canvas
- """
self.nvizClass.EraseMap()
self.SwapBuffers()
-
+
def IsLoaded(self, item):
"""!Check if layer (item) is already loaded
-
+
@param item layer item
"""
layer = self.tree.GetPyData(item)[0]['maplayer']
data = self.tree.GetPyData(item)[0]['nviz']
-
+
if not data:
return 0
-
- if layer.type == 'raster':
+
+ if layer.type == 'raster':
if not data['surface'].has_key('object'):
return 0
- elif layer.type == 'vector':
+ elif layer.type == 'vector':
if not data['vlines'].has_key('object') and \
not data['points'].has_key('object'):
return 0
-
+
return 1
def _GetDataLayers(self, item, litems):
@@ -329,7 +326,7 @@
# load raster & vector maps
while item and item.IsOk():
type = self.tree.GetPyData(item)[0]['type']
- if type == 'group':
+ if type == 'group':
subItem = self.tree.GetFirstChild(item)[0]
self._GetDataLayers(subItem, litems)
item = self.tree.GetNextSibling(item)
@@ -338,14 +335,14 @@
type not in ('raster', 'vector', '3d-raster'):
item = self.tree.GetNextSibling(item)
continue
-
+
litems.append(item)
-
+
item = self.tree.GetNextSibling(item)
def LoadDataLayers(self):
"""!Load raster/vector from current layer tree
-
+
@todo volumes
"""
if not self.tree:
@@ -356,21 +353,21 @@
self._GetDataLayers(item, listOfItems)
start = time.time()
-
+
while(len(listOfItems) > 0):
item = listOfItems.pop()
type = self.tree.GetPyData(item)[0]['type']
if item not in self.layers:
try:
- if type == 'raster':
+ if type == 'raster':
self.LoadRaster(item)
- elif type == '3d-raster':
+ elif type == '3d-raster':
self.LoadRaster3d(item)
except gcmd.NvizError, e:
print >> sys.stderr, "Nviz:" + e.message
-
+
try:
- if type == 'vector':
+ if type == 'vector':
data = self.tree.GetPyData(item)[0]['nviz']
vecType = []
if data and data.has_key('vector'):
@@ -381,13 +378,11 @@
except gcmd.NvizError, e:
print >> sys.stderr, "Nviz:" + e.message
self.init = False
-
+
stop = time.time()
- Debug.msg(3, "GLWindow.LoadDataLayers(): time=%f" % (stop-start))
-
- # print stop - start
-
+ Debug.msg(3, "GLWindow.LoadDataLayers(): time = %f" % (stop-start))
+
def UnloadDataLayers(self):
"""!Unload any layers that have been deleted from layer tree"""
if not self.tree:
@@ -403,11 +398,11 @@
if layer not in listOfItems:
ltype = self.tree.GetPyData(layer)[0]['type']
try:
- if ltype == 'raster':
+ if ltype == 'raster':
self.UnloadRaster(layer)
- elif ltype == '3d-raster':
+ elif ltype == '3d-raster':
self.UnloadRaster3d(layer)
- elif ltype == 'vector':
+ elif ltype == 'vector':
data = self.tree.GetPyData(layer)[0]['nviz']
vecType = []
if data and data.has_key('vector'):
@@ -419,19 +414,19 @@
self.UpdateView(None)
except gcmd.NvizError, e:
print >> sys.stderr, "Nviz:" + e.message
-
+
self.parent.nvizToolWin.UpdateSettings()
-
+
stop = time.time()
- Debug.msg(3, "GLWindow.UnloadDataLayers(): time=%f" % (stop-start))
+ Debug.msg(3, "GLWindow.UnloadDataLayers(): time = %f" % (stop-start))
def SetMapObjProperties(self, item, id, nvizType):
"""!Set map object properties
-
+
Properties must be afterwards updated by
UpdateMapObjProperties().
-
+
@param item layer item
@param id nviz layer id (or -1)
@param nvizType nviz data type (surface, points, vector)
@@ -444,24 +439,24 @@
# init data structure
self.tree.GetPyData(item)[0]['nviz'] = {}
data = self.tree.GetPyData(item)[0]['nviz']
-
- if type == 'raster':
+
+ if type == 'raster':
# reset to default properties
data[nvizType] = self.nvizDefault.SetSurfaceDefaultProp()
- elif type == 'vector':
+ elif type == 'vector':
# reset to default properties (lines/points)
data['vector'] = self.nvizDefault.SetVectorDefaultProp()
-
- elif type == '3d-raster':
+
+ elif type == '3d-raster':
# reset to default properties
data[nvizType] = self.nvizDefault.SetVolumeDefaultProp()
else:
# complete data (use default values)
- if type == 'raster':
+ if type == 'raster':
data['surface'] = self.nvizDefault.SetSurfaceDefaultProp()
- if type == 'vector':
+ if type == 'vector':
if not data['vector']['lines']:
self.nvizDefault.SetVectorLinesDefaultProp(data['vector']['lines'])
if not data['vector']['points']:
@@ -471,18 +466,18 @@
for sec in data.keys():
for sec1 in data[sec].keys():
for sec2 in data[sec][sec1].keys():
- if sec2 != 'all':
+ if sec2 != 'all':
data[sec][sec1][sec2]['update'] = None
-
- event = wxUpdateProperties(data=data)
+
+ event = wxUpdateProperties(data = data)
wx.PostEvent(self, event)
-
+
# set id
if id > 0:
if type in ('raster', '3d-raster'):
data[nvizType]['object'] = { 'id' : id,
'init' : False }
- elif type == 'vector':
+ elif type == 'vector':
data['vector'][nvizType]['object'] = { 'id' : id,
'init' : False }
@@ -490,33 +485,33 @@
def LoadRaster(self, item):
"""!Load 2d raster map and set surface attributes
-
+
@param layer item
"""
return self._loadRaster(item)
-
+
def LoadRaster3d(self, item):
"""!Load 3d raster map and set surface attributes
-
+
@param layer item
"""
return self._loadRaster(item)
-
+
def _loadRaster(self, item):
"""!Load 2d/3d raster map and set its attributes
-
+
@param layer item
"""
layer = self.tree.GetPyData(item)[0]['maplayer']
-
+
if layer.type not in ('raster', '3d-raster'):
return
-
- if layer.type == 'raster':
+
+ if layer.type == 'raster':
id = self.nvizClass.LoadSurface(str(layer.name), None, None)
nvizType = 'surface'
errorMsg = _("Loading raster map")
- elif layer.type == '3d-raster':
+ elif layer.type == '3d-raster':
id = self.nvizClass.LoadVolume(str(layer.name), None, None)
nvizType = 'volume'
errorMsg = _("Loading 3d raster map")
@@ -535,50 +530,50 @@
data = self.SetMapObjProperties(item, id, nvizType)
# update properties
- event = wxUpdateProperties(data=data)
+ event = wxUpdateProperties(data = data)
wx.PostEvent(self, event)
# update tools window
if hasattr(self.parent, "nvizToolWin") and \
- item == self.GetSelectedLayer(type='item'):
+ item == self.GetSelectedLayer(type = 'item'):
toolWin = self.parent.nvizToolWin
- if layer.type == 'raster':
+ if layer.type == 'raster':
win = toolWin.FindWindowById( \
toolWin.win['vector']['lines']['surface'])
win.SetItems(self.GetLayerNames(layer.type))
-
+
#toolWin.UpdatePage(nvizType)
#toolWin.SetPage(nvizType)
return id
-
+
def UnloadRaster(self, item):
"""!Unload 2d raster map
-
+
@param layer item
"""
return self._unloadRaster(item)
-
+
def UnloadRaster3d(self, item):
"""!Unload 3d raster map
-
+
@param layer item
"""
return self._unloadRaster(item)
-
+
def _unloadRaster(self, item):
"""!Unload 2d/3d raster map
-
+
@param item layer item
"""
layer = self.tree.GetPyData(item)[0]['maplayer']
-
+
if layer.type not in ('raster', '3d-raster'):
return
-
+
data = self.tree.GetPyData(item)[0]['nviz']
-
- if layer.type == 'raster':
+
+ if layer.type == 'raster':
nvizType = 'surface'
unloadFn = self.nvizClass.UnloadSurface
errorMsg = _("Unable to unload raster map")
@@ -588,58 +583,58 @@
unloadFn = self.nvizClass.UnloadVolume
errorMsg = _("Unable to unload 3d raster map")
successMsg = _("3d raster map")
-
+
id = data[nvizType]['object']['id']
-
- if unloadFn(id) == 0:
+
+ if unloadFn(id) == 0:
print >> sys.stderr, "Nviz:" + "%s <%s>" % (errorMsg, layer.name)
else:
print "Nviz:" + "%s <%s> %s" % (successMsg, layer.name, _("unloaded successfully"))
-
+
data[nvizType].pop('object')
-
+
self.layers.remove(item)
# update tools window
if hasattr(self.parent, "nvizToolWin") and \
- layer.type == 'raster':
+ layer.type == 'raster':
toolWin = self.parent.nvizToolWin
win = toolWin.FindWindowById( \
toolWin.win['vector']['lines']['surface'])
win.SetItems(self.GetLayerNames(layer.type))
# remove surface page
- if toolWin.notebook.GetSelection() == toolWin.page[nvizType]['id']:
+ if toolWin.notebook.GetSelection() == toolWin.page[nvizType]['id']:
toolWin.notebook.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, vecType = None):
"""!Load 2D or 3D vector map overlay
-
+
@param item layer item
@param vecType vector type (lines / points)
"""
layer = self.tree.GetPyData(item)[0]['maplayer']
-
- if layer.type != 'vector':
+
+ 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']):
+ 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')
-
+
id = -1
for type in vecType:
- if type == 'lines':
+ if type == 'lines':
id = self.nvizClass.LoadVector(str(layer.name), False)
else:
id = self.nvizClass.LoadVector(str(layer.name), True)
@@ -648,7 +643,7 @@
print >> sys.stderr, "Nviz:" + _("Loading vector map <%(name)s> (%(type)s) failed") % \
{ 'name' : layer.name, 'type' : type }
continue
-
+
# update layer properties
self.SetMapObjProperties(item, id, type)
@@ -656,63 +651,62 @@
# update properties
data = self.tree.GetPyData(item)[0]['nviz']
- event = wxUpdateProperties(data=data)
+ event = wxUpdateProperties(data = data)
wx.PostEvent(self, event)
# update tools window
if hasattr(self.parent, "nvizToolWin") and \
- item == self.GetSelectedLayer(type='item'):
+ item == self.GetSelectedLayer(type = 'item'):
toolWin = self.parent.nvizToolWin
-
+
toolWin.UpdatePage('vector')
toolWin.SetPage('vector')
return id
- def UnloadVector(self, item, vecType=None):
+ def UnloadVector(self, item, vecType = None):
"""!Unload vector map overlay
-
+
@param item layer item
@param vecType vector type (lines, points)
"""
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']):
+ if UserSettings.Get(group = 'nviz', key = 'vector',
+ subkey = [v, 'show']):
vecType.append(v)
-
+
for vtype in vecType:
if not data[vtype].has_key('object'):
continue
-
+
id = data[vtype]['object']['id']
-
- if vtype == 'lines':
+
+ if vtype == 'lines':
ret = self.nvizClass.UnloadVector(id, False)
else:
ret = self.nvizClass.UnloadVector(id, True)
- if ret == 0:
+ if ret == 0:
print >> sys.stderr, "Nviz:" + _("Unable to unload vector map <%(name)s> (%(type)s)") % \
{ 'name': layer.name, 'type' : vtype }
else:
print "Nviz:" + _("Vector map <%(name)s> (%(type)s) unloaded successfully") % \
{ 'name' : layer.name, 'type' : vtype }
-
data[vtype].pop('object')
-
- self.layers.remove(id)
+ self.layers.remove(id)
+
# update tools window
if hasattr(self.parent, "nvizToolWin") and \
vecType is None:
toolWin = self.parent.nvizToolWin
# remove surface page
- if toolWin.notebook.GetSelection() == toolWin.page['surface']['id']:
+ if toolWin.notebook.GetSelection() == toolWin.page['surface']['id']:
toolWin.notebook.RemovePage(toolWin.page['surface']['id'])
toolWin.page['surface']['id'] = -1
toolWin.page['settings']['id'] = 1
@@ -721,30 +715,29 @@
"""!Reset (unload data)"""
for item in self.layers:
type = self.tree.GetPyData(item)[0]['maplayer'].type
- if type == 'raster':
+ if type == 'raster':
self.UnloadRaster(item)
- elif type == '3d-raster':
+ elif type == '3d-raster':
self.UnloadRaster3d(item)
- elif type == 'vector':
+ elif type == 'vector':
self.UnloadVector(item)
self.init = False
def OnZoomToMap(self, event):
- """
- Set display extents to match selected raster
- or vector map or volume.
-
+ """!Set display extents to match selected raster or vector
+ map or volume.
+
@todo vector, volume
"""
layer = self.GetSelectedLayer()
-
+
if layer is None:
return
-
- Debug.msg (3, "GLWindow.OnZoomToMap(): layer=%s, type=%s" % \
+
+ Debug.msg (3, "GLWindow.OnZoomToMap(): layer = %s, type = %s" % \
(layer.name, layer.type))
-
+
self.nvizClass.SetViewportDefault()
def ResetView(self):
@@ -754,17 +747,17 @@
self.iview['height']['min'], \
self.iview['height']['max'] = self.nvizClass.SetViewDefault()
- self.view['pos']['x'] = UserSettings.Get(group='nviz', key='view',
- subkey=('pos', 'x'))
- self.view['pos']['y'] = UserSettings.Get(group='nviz', key='view',
- subkey=('pos', 'x'))
- self.view['persp']['value'] = UserSettings.Get(group='nviz', key='view',
- subkey=('persp', 'value'))
-
- self.view['twist']['value'] = UserSettings.Get(group='nviz', key='view',
- subkey=('twist', 'value'))
-
- event = wxUpdateView(zExag=False)
+ self.view['pos']['x'] = UserSettings.Get(group = 'nviz', key = 'view',
+ subkey = ('pos', 'x'))
+ self.view['pos']['y'] = UserSettings.Get(group = 'nviz', key = 'view',
+ subkey = ('pos', 'x'))
+ self.view['persp']['value'] = UserSettings.Get(group = 'nviz', key = 'view',
+ subkey = ('persp', 'value'))
+
+ self.view['twist']['value'] = UserSettings.Get(group = 'nviz', key = 'view',
+ subkey = ('twist', 'value'))
+
+ event = wxUpdateView(zExag = False)
wx.PostEvent(self, event)
def UpdateMapObjProperties(self, event):
@@ -776,13 +769,13 @@
self.UpdateSurfaceProperties(id, data['surface'])
# -> initialized
data['surface']['object']['init'] = True
-
+
elif data.has_key('volume'):
id = data['volume']['object']['id']
self.UpdateVolumeProperties(id, data['volume'])
# -> initialized
data['volume']['object']['init'] = True
-
+
elif data.has_key('vector'):
for type in ('lines', 'points'):
if data['vector'][type].has_key('object'):
@@ -799,45 +792,45 @@
if not data['attribute'].has_key(attrb) or \
not data['attribute'][attrb].has_key('update'):
continue
-
+
map = data['attribute'][attrb]['map']
value = data['attribute'][attrb]['value']
-
+
if map is None: # unset
# only optional attributes
- if attrb == 'mask':
+ if attrb == 'mask':
# TODO: invert mask
# TODO: broken in NVIZ
self.nvizClass.UnsetSurfaceMask(id)
- elif attrb == 'transp':
+ elif attrb == 'transp':
self.nvizClass.UnsetSurfaceTransp(id)
- elif attrb == 'emit':
+ elif attrb == 'emit':
self.nvizClass.UnsetSurfaceEmit(id)
else:
- if type(value) == type('') and \
- len(value) <= 0: # ignore empty values (TODO: warning)
+ if type(value) == type('') and \
+ len(value) <= 0: # ignore empty values (TODO: warning)
continue
- if attrb == 'topo':
+ if attrb == 'topo':
self.nvizClass.SetSurfaceTopo(id, map, str(value))
- elif attrb == 'color':
+ elif attrb == 'color':
self.nvizClass.SetSurfaceColor(id, map, str(value))
- elif attrb == 'mask':
+ elif attrb == 'mask':
# TODO: invert mask
# TODO: broken in NVIZ
self.nvizClass.SetSurfaceMask(id, False, str(value))
- elif attrb == 'transp':
+ elif attrb == 'transp':
self.nvizClass.SetSurfaceTransp(id, map, str(value))
- elif attrb == 'shine':
+ elif attrb == 'shine':
self.nvizClass.SetSurfaceShine(id, map, str(value))
- elif attrb == 'emit':
+ elif attrb == 'emit':
self.nvizClass.SetSurfaceEmit(id, map, str(value))
data['attribute'][attrb].pop('update')
-
+
# draw res
if data['draw']['resolution'].has_key('update'):
coarse = data['draw']['resolution']['coarse']
fine = data['draw']['resolution']['fine']
-
+
if data['draw']['all']:
self.nvizClass.SetSurfaceRes(-1, fine, coarse)
else:
@@ -848,17 +841,17 @@
if data['draw']['mode'].has_key('update'):
if data['draw']['mode']['value'] < 0: # need to calculate
data['draw']['mode']['value'] = \
- self.nvizDefault.GetDrawMode(mode=data['draw']['mode']['desc']['mode'],
- style=data['draw']['mode']['desc']['style'],
- shade=data['draw']['mode']['desc']['shading'],
- string=True)
+ self.nvizDefault.GetDrawMode(mode = data['draw']['mode']['desc']['mode'],
+ style = data['draw']['mode']['desc']['style'],
+ shade = data['draw']['mode']['desc']['shading'],
+ string = True)
style = data['draw']['mode']['value']
if data['draw']['all']:
self.nvizClass.SetSurfaceStyle(-1, style)
else:
self.nvizClass.SetSurfaceStyle(id, style)
data['draw']['mode'].pop('update')
-
+
# wire color
if data['draw']['wire-color'].has_key('update'):
color = data['draw']['wire-color']['value']
@@ -876,11 +869,8 @@
self.nvizClass.SetSurfacePosition(id, x, y, z)
data['position'].pop('update')
- def UpdateVolumeProperties(self, id, data, isosurfId=None):
+ def UpdateVolumeProperties(self, id, data, isosurfId = None):
"""!Update volume (isosurface/slice) map object properties"""
- #
- # draw
- #
if data['draw']['resolution'].has_key('update'):
self.nvizClass.SetIsosurfaceRes(id, data['draw']['resolution']['value'])
data['draw']['resolution'].pop('update')
@@ -888,8 +878,8 @@
if data['draw']['shading'].has_key('update'):
if data['draw']['shading']['value'] < 0: # need to calculate
data['draw']['shading']['value'] = \
- self.nvizDefault.GetDrawMode(shade=data['draw']['shading'],
- string=False)
+ self.nvizDefault.GetDrawMode(shade = data['draw']['shading'],
+ string = False)
data['draw']['shading'].pop('update')
#
@@ -904,48 +894,48 @@
continue
map = isosurf[attrb]['map']
value = isosurf[attrb]['value']
-
+
if map is None: # unset
# only optional attributes
- if attrb == 'mask':
+ if attrb == 'mask':
# TODO: invert mask
# TODO: broken in NVIZ
self.nvizClass.UnsetIsosurfaceMask(id, isosurfId)
- elif attrb == 'transp':
+ elif attrb == 'transp':
self.nvizClass.UnsetIsosurfaceTransp(id, isosurfId)
- elif attrb == 'emit':
+ elif attrb == 'emit':
self.nvizClass.UnsetIsosurfaceEmit(id, isosurfId)
else:
- if type(value) == type('') and \
- len(value) <= 0: # ignore empty values (TODO: warning)
+ if type(value) == type('') and \
+ len(value) <= 0: # ignore empty values (TODO: warning)
continue
- elif attrb == 'color':
+ elif attrb == 'color':
self.nvizClass.SetIsosurfaceColor(id, isosurfId, map, str(value))
- elif attrb == 'mask':
+ elif attrb == 'mask':
# TODO: invert mask
# TODO: broken in NVIZ
self.nvizClass.SetIsosurfaceMask(id, isosurfId, False, str(value))
- elif attrb == 'transp':
+ elif attrb == 'transp':
self.nvizClass.SetIsosurfaceTransp(id, isosurfId, map, str(value))
- elif attrb == 'shine':
+ elif attrb == 'shine':
self.nvizClass.SetIsosurfaceShine(id, isosurfId, map, str(value))
- elif attrb == 'emit':
+ elif attrb == 'emit':
self.nvizClass.SetIsosurfaceEmit(id, isosurfId, map, str(value))
isosurf[attrb].pop('update')
- isosurfId += 1
+ isosurfId += 1
def UpdateVectorProperties(self, id, data, type):
"""!Update vector layer properties
-
+
@param id layer id
@param data properties
@param type lines/points
"""
- if type == 'points':
+ if type == 'points':
self.UpdateVectorPointsProperties(id, data[type])
else:
self.UpdateVectorLinesProperties(id, data[type])
-
+
def UpdateVectorLinesProperties(self, id, data):
"""!Update vector line map object properties"""
# mode
@@ -954,13 +944,13 @@
data['mode'].has_key('update'):
width = data['width']['value']
color = data['color']['value']
- if data['mode']['type'] == 'flat':
+ if data['mode']['type'] == 'flat':
flat = True
if data.has_key('surface'):
data.pop('surface')
else:
flat = False
-
+
self.nvizClass.SetVectorLineMode(id, color,
width, flat)
@@ -979,7 +969,7 @@
# surface
if data['mode'].has_key('update'):
- sid = self.GetLayerId(type='raster', name=data['mode']['surface'])
+ sid = self.GetLayerId(type = 'raster', name = data['mode']['surface'])
if sid > -1:
self.nvizClass.SetVectorLineSurface(id, sid)
@@ -994,17 +984,17 @@
ret = self.nvizClass.SetVectorPointMode(id, data['color']['value'],
data['width']['value'], float(data['size']['value']),
data['marker']['value'] + 1)
-
+
error = None
- if ret == -1:
- error = _("Vector point layer not found (id=%d)") % id
- elif ret == -2:
- error = _("Unable to set data layer properties (id=%d)") % id
+ if ret == -1:
+ error = _("Vector point layer not found (id = %d)") % id
+ elif ret == -2:
+ error = _("Unable to set data layer properties (id = %d)") % id
if error:
- raise gcmd.NvizError(parent=self.parent,
- message=_("Setting data layer properties failed.\n\n%s") % error)
-
+ raise gcmd.NvizError(parent = self.parent,
+ message = _("Setting data layer properties failed.\n\n%s") % error)
+
for prop in ('size', 'width', 'marker', 'color'):
if data[prop].has_key('update'):
data[prop].pop('update')
@@ -1017,19 +1007,19 @@
# surface
if data['mode'].has_key('update'):
- sid = self.GetLayerId(type='raster', name=data['mode']['surface'])
+ sid = self.GetLayerId(type = 'raster', name = data['mode']['surface'])
if sid > -1:
self.nvizClass.SetVectorPointSurface(id, sid)
data['mode'].pop('update')
-
+
def GetLayerNames(self, type):
"""!Return list of map layer names of given type"""
layerName = []
for item in self.layers:
mapLayer = self.tree.GetPyData(item)[0]['maplayer']
- if type != mapLayer.GetType():
+ if type != mapLayer.GetType():
continue
layerName.append(mapLayer.GetName())
@@ -1043,7 +1033,7 @@
"""
for item in self.layers:
mapLayer = self.tree.GetPyData(item)[0]['maplayer'].GetName()
- if mapLayer == name:
+ if mapLayer == name:
return self.tree.GetPyData(item)[0]['nviz']
return {}
@@ -1055,20 +1045,21 @@
for item in self.layers:
mapLayer = self.tree.GetPyData(item)[0]['maplayer']
- if type != mapLayer.GetType() or \
- name != mapLayer.GetName():
+ if type != mapLayer.GetType() or \
+ name != mapLayer.GetName():
continue
-
+
data = self.tree.GetPyData(item)[0]['nviz']
- if type == 'raster':
+ if type == 'raster':
return data['surface']['object']['id']
- elif type == 'vpoint':
+ elif type == 'vpoint':
return data['vector']['points']['object']['id']
- elif type == 'vline':
+ elif type == 'vline':
return data['vector']['lines']['object']['id']
- elif type == '3d-raster':
+ elif type == '3d-raster':
return data['volume']['object']['id']
-
+
return -1
-
+
+
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2010-05-26 14:26:05 UTC (rev 42354)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2010-05-26 20:02:22 UTC (rev 42355)
@@ -1350,8 +1350,8 @@
(self.settings, "settings", Icons["nvizSettings"].GetBitmap(),
wx.ITEM_NORMAL, Icons["nvizSettings"].GetLabel(), Icons["nvizSettings"].GetDesc(),
self.OnSettings),
- (self.quit, 'quit', Icons["quit"].GetBitmap(),
- wx.ITEM_NORMAL, Icons["quit"].GetLabel(), Icons["quit"].GetDesc(),
+ (self.quit, 'quit', Icons["nvizQuit"].GetBitmap(),
+ wx.ITEM_NORMAL, Icons["nvizQuit"].GetLabel(), Icons["nvizQuit"].GetDesc(),
self.OnExit),
)
Modified: grass/trunk/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2010-05-26 14:26:05 UTC (rev 42354)
+++ grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2010-05-26 20:02:22 UTC (rev 42355)
@@ -119,7 +119,7 @@
return Nviz_change_exag(self.data, z_exag)
def Draw(self, quick, quick_mode):
- """!Draw map
+ """!Draw canvas
Draw quick mode:
- DRAW_QUICK_SURFACE
@@ -130,6 +130,8 @@
@param quick if true draw in wiremode
@param quick_mode quick mode
"""
+ Debug.msg(3, "Nviz::Draw(): quick=%d", quick)
+
Nviz_draw_cplane(self.data, -1, -1) # ?
if quick:
@@ -137,8 +139,6 @@
else:
Nviz_draw_all(self.data)
- Debug.msg(3, "Nviz::Draw(): quick=%d", quick)
-
def EraseMap(self):
"""!Erase map display (with background color)
"""
@@ -1092,3 +1092,4 @@
ret = GVL_isosurf_set_drawres(id, res, res, res)
return -2 if ret < 0 else 1
+
Modified: grass/trunk/gui/wxpython/icons/grass_icons.py
===================================================================
--- grass/trunk/gui/wxpython/icons/grass_icons.py 2010-05-26 14:26:05 UTC (rev 42354)
+++ grass/trunk/gui/wxpython/icons/grass_icons.py 2010-05-26 20:02:22 UTC (rev 42355)
@@ -105,7 +105,7 @@
"grGcpReload" : 'gui-redraw.gif',
"grSettings" : 'edit-color.gif',
# nviz
- "nvizSettings" : 'edit-color.gif',
+ "nvizSettings" : 'edit-color.gif',
# modeler
"modelActionAdd" : wx.ART_ERROR,
"modelDataAdd" : wx.ART_ERROR,
Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py 2010-05-26 14:26:05 UTC (rev 42354)
+++ grass/trunk/gui/wxpython/icons/icon.py 2010-05-26 20:02:22 UTC (rev 42355)
@@ -138,10 +138,11 @@
Icons = {
# map display
"displaymap" : MetaIcon (img=Icons["displaymap"],
- label=_("Display map")),
+ label=_("Display map"),
+ desc = _("Re-render modified map layers")),
"rendermap" : MetaIcon (img=Icons["rendermap"],
label=_("Re-render map"),
- desc=_("Force re-rendering of all layers")),
+ desc=_("Force re-rendering all map layers")),
"erase" : MetaIcon (img=Icons["erase"],
label=_("Erase display")),
"pointer" : MetaIcon (img=Icons["pointer"],
@@ -334,8 +335,11 @@
desc=_("Settings dialog for georectification tool")),
# nviz
"nvizSettings": MetaIcon (img=Icons["nvizSettings"],
- label=_("Settings"),
- desc=_("Show Nviz settings dialog")),
+ label=_("3D view mode tools"),
+ desc=_("Show/hide 3D view mode tools dialog")),
+ "nvizQuit": MetaIcon (img=Icons["quit"],
+ label=_("Quit 3D view mode"),
+ desc=_("Switch back to 2D view mode")),
# modeler
"modelNew" : MetaIcon (img=Icons["fileNew"],
label=_("Create new model (Ctrl+N)")),
More information about the grass-commit
mailing list