[GRASS-SVN] r36524 -
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 30 03:25:16 EDT 2009
Author: cmbarton
Date: 2009-03-30 03:25:15 -0400 (Mon, 30 Mar 2009)
New Revision: 36524
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/branches/releasebranch_6_4/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/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py 2009-03-30 07:19:32 UTC (rev 36523)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py 2009-03-30 07:25:15 UTC (rev 36524)
@@ -2846,6 +2846,8 @@
self.nvizToolWin = nviz.NvizToolWindow(self, id=wx.ID_ANY,
mapWindow=self.MapWindow3D)
self.MapWindow3D.OnPaint(None) # -> LoadData
+ self.MapWindow3D.Show()
+ self.MapWindow3D.UpdateView(None)
busy.Destroy()
@@ -2899,7 +2901,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()
@@ -2914,6 +2916,7 @@
# update layer tree (-> disable 3d-rasters)
#
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/releasebranch_6_4/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_mapdisp.py 2009-03-30 07:19:32 UTC (rev 36523)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_mapdisp.py 2009-03-30 07:25:15 UTC (rev 36524)
@@ -130,13 +130,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,
@@ -154,9 +160,10 @@
self.nvizClass.InitView()
self.initView = True
+ self.LoadDataLayers()
+ self.UnloadDataLayers()
+
if not self.init:
- self.LoadDataLayers()
-
self.ResetView()
if hasattr(self.parent, "nvizToolWin"):
@@ -176,7 +183,7 @@
win.SetItems(self.GetLayerNames('raster'))
self.init = True
-
+
self.UpdateMap()
def OnMouseAction(self, event):
@@ -233,10 +240,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):
"""
@@ -342,39 +349,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/releasebranch_6_4/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_tools.py 2009-03-30 07:19:32 UTC (rev 36523)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_tools.py 2009-03-30 07:25:15 UTC (rev 36524)
@@ -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.gismanager # GMFrame
@@ -2305,60 +2306,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