[GRASS-SVN] r36522 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 30 03:15:36 EDT 2009
Author: cmbarton
Date: 2009-03-30 03:15:36 -0400 (Mon, 30 Mar 2009)
New Revision: 36522
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
Log:
Bug fix for wxnviz. It now starts and quits and restarts without errors. It also does not have to reload maps previously loaded. Panel switching works without duplicate pages and overlayed panels.
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2009-03-29 21:16:34 UTC (rev 36521)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2009-03-30 07:15:36 UTC (rev 36522)
@@ -392,6 +392,7 @@
mapWindow=self.MapWindow3D)
self.MapWindow3D.OnPaint(None) # -> LoadData
self.MapWindow3D.Show()
+ self.MapWindow3D.UpdateView(None)
self.nvizToolWin.Show()
@@ -443,7 +444,7 @@
# hide nviz tools
self.nvizToolWin.Hide()
# unload data
- self.MapWindow3D.Reset()
+# self.MapWindow3D.Reset()
# switch from MapWindowGL to MapWindow
self._mgr.DetachPane(self.MapWindow3D)
self.MapWindow3D.Hide()
@@ -459,6 +460,7 @@
#
if self.tree:
self.tree.EnableItemType(type='3d-raster', enable=False)
+ self.MapWindow.UpdateMap()
self.toolbars['map'].combo.SetValue (_("2D view"))
self.toolbars['map'].Enable2D(True)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py 2009-03-29 21:16:34 UTC (rev 36521)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py 2009-03-30 07:15:36 UTC (rev 36522)
@@ -128,13 +128,19 @@
self.Bind(EVT_UPDATE_PROP, self.UpdateMapObjProperties)
self.Bind(EVT_UPDATE_VIEW, self.UpdateView)
+ self.Bind(wx.EVT_CLOSE, self.OnClose)
+
+ 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.OnPaint(): 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,
@@ -152,9 +158,10 @@
self.nvizClass.InitView()
self.initView = True
+ self.LoadDataLayers()
+ self.UnloadDataLayers()
+
if not self.init:
- self.LoadDataLayers()
-
self.ResetView()
if hasattr(self.parent, "nvizToolWin"):
@@ -174,7 +181,7 @@
win.SetItems(self.GetLayerNames('raster'))
self.init = True
-
+
self.UpdateMap()
def OnMouseAction(self, event):
@@ -231,10 +238,10 @@
self.view['persp']['value'],
self.view['twist']['value'])
- if event.zExag:
+ if event and event.zExag:
self.nvizClass.SetZExag(self.view['z-exag']['value'])
- event.Skip()
+ if event: event.Skip()
def UpdateMap(self, render=True):
"""
@@ -343,39 +350,78 @@
listOfItems = []
item = self.tree.GetFirstChild(self.tree.root)[0]
self._GetDataLayers(item, listOfItems)
-
+
start = time.time()
while(len(listOfItems) > 0):
item = listOfItems.pop()
type = self.tree.GetPyData(item)[0]['type']
-
- try:
- if type == 'raster':
- self.LoadRaster(item)
- elif type == '3d-raster':
- self.LoadRaster3d(item)
- except gcmd.NvizError, e:
- print >> sys.stderr, "Nviz:" + e.message
+ if item not in self.layers:
+ try:
+ if type == 'raster':
+ self.LoadRaster(item)
+ elif type == '3d-raster':
+ self.LoadRaster3d(item)
+ except gcmd.NvizError, e:
+ print >> sys.stderr, "Nviz:" + e.message
- 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.NvizError, e:
- print >> sys.stderr, "Nviz:" + e.message
+ 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.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
+
+ def UnloadDataLayers(self):
+ """Unload any layers that have been deleted from layer tree"""
+ if not self.tree:
+ return
+
+ listOfItems = []
+ item = self.tree.GetFirstChild(self.tree.root)[0]
+ self._GetDataLayers(item, listOfItems)
+
+ start = time.time()
+
+ for layer in self.layers:
+ if layer not in listOfItems:
+ ltype = self.tree.GetPyData(layer)[0]['type']
+ try:
+ if ltype == 'raster':
+ self.UnloadRaster(layer)
+ elif ltype == '3d-raster':
+ self.UnloadRaster3d(layer)
+ elif ltype == 'vector':
+ data = self.tree.GetPyData(layer)[0]['nviz']
+ vecType = []
+ if data and data.has_key('vector'):
+ for v in ('lines', 'points'):
+ if data['vector'][v]:
+ vecType.append(v)
+ self.UnloadVector(layer, vecType)
+
+ 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))
+
def SetMapObjProperties(self, item, id, nvizType):
"""Set map object properties
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py 2009-03-29 21:16:34 UTC (rev 36521)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_tools.py 2009-03-30 07:15:36 UTC (rev 36522)
@@ -39,7 +39,8 @@
"""
def __init__(self, parent=None, id=wx.ID_ANY, title=_("Nviz tools"),
pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=wx.DEFAULT_FRAME_STYLE, mapWindow=None):
+ mapWindow=None,
+ style=wx.CAPTION|wx.MINIMIZE_BOX|wx.RESIZE_BORDER):
self.parent = parent # MapFrame
self.lmgr = self.parent.GetLayerManager() # GMFrame
@@ -2304,60 +2305,32 @@
max)
self.FindWindowById(self.win['view']['height'][control]).SetRange(hmin,
hmax)
- elif pageId == 'surface':
- if self.notebook.GetSelection() != self.page['surface']['id']:
- for page in ('vector', 'volume'):
+ elif pageId in ('surface', 'vector', 'volume'):
+ if self.notebook.GetSelection() != self.page[pageId]['id']:
+ for page in ('surface', 'vector', 'volume'):
if self.page[page]['id'] > -1:
self.notebook.RemovePage(self.page[page]['id'])
self.page[page]['id'] = -1
+ oldpanel = wx.FindWindowById(self.page[page]['panel'])
+ oldpanel.Hide()
- self.page['surface']['id'] = 1
+ self.page[pageId]['id'] = 1
self.page['settings']['id'] = 2
- panel = wx.FindWindowById(self.page['surface']['panel'])
- self.notebook.InsertPage(n=self.page['surface']['id'],
+ panel = wx.FindWindowById(self.page[pageId]['panel'])
+ self.notebook.InsertPage(n=self.page[pageId]['id'],
page=panel,
text=" %s " % _("Layer properties"),
select=True)
-
- self.UpdateSurfacePage(layer, data['surface'])
+ if pageId == 'surface':
+ self.UpdateSurfacePage(layer, data['surface'])
+ elif pageId == 'vector':
+ self.UpdateVectorPage(layer, data['vector'])
+ elif pageId == 'volume':
+ self.UpdateVectorPage(layer, data['vector'])
- elif pageId == 'vector':
- if self.notebook.GetSelection() != self.page['vector']['id']:
- for page in ('surface', 'volume'):
- if self.page[page]['id'] > -1:
- self.notebook.RemovePage(self.page[page]['id'])
- self.page[page]['id'] = -1
-
- self.page['vector']['id'] = 1
- self.page['settings']['id'] = 2
-
- panel = wx.FindWindowById(self.page['vector']['panel'])
- self.notebook.InsertPage(n=self.page['vector']['id'],
- page=panel,
- text=" %s " % _("Layer properties"),
- select=True)
- self.UpdateVectorPage(layer, data['vector'])
-
- elif pageId == 'volume':
- if self.notebook.GetSelection() != self.page['volume']['id']:
- for page in ('surface', 'vector'):
- if self.page[page]['id'] > -1:
- self.notebook.RemovePage(self.page[page]['id'])
- self.page[page]['id'] = -1
-
- self.page['volume']['id'] = 1
- self.page['settings']['id'] = 2
-
- panel = wx.FindWindowById(self.page['volume']['panel'])
- self.notebook.InsertPage(n=self.page['volume']['id'],
- page=panel,
- text=" %s " % _("Layer properties"),
- select=True)
-
- self.UpdateVolumePage(layer, data['volume'])
-
+ self.notebook.Update()
self.pageChanging = False
def UpdateSurfacePage(self, layer, data):
More information about the grass-commit
mailing list