[GRASS-SVN] r32464 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 2 09:49:48 EDT 2008
Author: martinl
Date: 2008-08-02 09:49:47 -0400 (Sat, 02 Aug 2008)
New Revision: 32464
Modified:
grass/trunk/gui/wxpython/gui_modules/render.py
grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
Log:
wxGUI: fix map layer position in stack, update r32463
Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2008-08-02 13:09:36 UTC (rev 32463)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2008-08-02 13:49:47 UTC (rev 32464)
@@ -797,7 +797,7 @@
(not os.path.isfile(layer.mapfile) or not os.path.getsize(layer.mapfile)):
if not layer.Render():
continue
-
+
# update process bar
if mapWindow is not None:
mapWindow.onRenderCounter += 1
@@ -862,7 +862,8 @@
return self.mapfile
def AddLayer(self, type, command, name=None,
- l_active=True, l_hidden=False, l_opacity=1.0, l_render=False):
+ l_active=True, l_hidden=False, l_opacity=1.0, l_render=False,
+ pos=-1):
"""
Adds generic map layer to list of layers
@@ -873,6 +874,7 @@
@param l_hidden layer not displayed in layer tree if True
@param l_opacity opacity level range from 0(transparent) - 1(not transparent)
@param l_render render an image if True
+ @param pos position in layer list (-1 for append)
@return new layer on success
@return None on failure
@@ -886,14 +888,17 @@
active=l_active, hidden=l_hidden, opacity=l_opacity)
# add maplayer to the list of layers
- self.layers.append(layer)
-
+ if pos > -1:
+ self.layers.insert(pos, layer)
+ else:
+ self.layers.append(layer)
+
Debug.msg (3, "Map.AddLayer(): layer=%s" % layer.name)
if l_render:
if not layer.Render():
raise gcmd.GStdError(_("Unable to render map layer <%s>.") % (name))
- return self.layers[-1]
+ return layer
def DeleteLayer(self, layer, overlay=False):
"""
Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-08-02 13:09:36 UTC (rev 32463)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-08-02 13:49:47 UTC (rev 32464)
@@ -566,10 +566,6 @@
self.CheckItem(layer, checked=checked)
- # select new item
- self.SelectItem(layer, select=True)
- self.layer_selected = layer
-
# add text and icons for each layer ltype
if ltype == 'raster':
self.SetItemImage(layer, self.rast_icon)
@@ -651,7 +647,23 @@
'prowin' : None},
None))
- maplayer = self.Map.AddLayer(type=ltype, command=self.GetPyData(layer)[0]['cmd'], name=name,
+ # find previous map layer instance
+ prevItem = self.GetLastChild(self.root)
+ prevMapLayer = None
+ while prevItem and prevItem.IsOk() and \
+ prevItem != layer:
+ if self.GetPyData(prevItem)[0]['maplayer']:
+ prevMapLayer = self.GetPyData(prevItem)[0]['maplayer']
+
+ prevItem = self.GetPrevSibling(prevItem)
+
+ if prevMapLayer:
+ pos = self.Map.GetLayerIndex(prevMapLayer) + 1
+ else:
+ pos = -1
+
+ maplayer = self.Map.AddLayer(pos=pos,
+ type=ltype, command=self.GetPyData(layer)[0]['cmd'], name=name,
l_active=checked, l_hidden=False,
l_opacity=opacity, l_render=render)
self.GetPyData(layer)[0]['maplayer'] = maplayer
@@ -679,6 +691,10 @@
if checked is True:
self.mapdisplay.onRenderGauge.SetRange(len(self.Map.GetListOfLayers(l_active=True)))
+ # select new item
+ self.SelectItem(layer, select=True)
+ self.layer_selected = layer
+
# layer.SetHeight(TREE_ITEM_HEIGHT)
return layer
More information about the grass-commit
mailing list