[GRASS-SVN] r32465 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 2 10:00:05 EDT 2008
Author: martinl
Date: 2008-08-02 10:00:05 -0400 (Sat, 02 Aug 2008)
New Revision: 32465
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
Log:
wxGUI: add new layer as previous sibling of selected layer (first item from the list is rendered as the last one)
some goutput quick fixes
(merge from trunk, r32463 and r32464)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2008-08-02 13:49:47 UTC (rev 32464)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2008-08-02 14:00:05 UTC (rev 32465)
@@ -695,18 +695,17 @@
txt += os.linesep
if '\r' in txt:
- self.linePos = -1
+ self.parent.linePos = -1
for seg in txt.split('\r'):
- if self.linePos > -1:
- self.cmd_output.SetCurrenPos()
- self.ReplaceText(iseg) + ' ' * (self.lineWidth - len(iseg))
+ if self.parent.linePos > -1:
+ self.SetCurrentPos(self.parent.linePos)
+ self.ReplaceSelection(seg)
else:
- self.AddText(iseg)
- self.linePos = self.GetCurrentPos()
-
- iseg += 1
+ self.parent.linePos = self.GetCurrentPos()
+ self.AddText(seg)
else:
+ self.parent.linePos = self.GetCurrentPos()
self.AddText(txt)
- self.linePos = self.GetCurrentPos()
+
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2008-08-02 13:49:47 UTC (rev 32464)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2008-08-02 14:00:05 UTC (rev 32465)
@@ -684,7 +684,7 @@
Returns list of layers of selected properties or list of all
layers.
- @param l_type layer type, e.g. raster/vector/wms/overlay
+ @param l_type layer type, e.g. raster/vector/wms/overlay (value or tuple of values)
@param l_mapset all layers from given mapset (only for maplayers)
@param l_name all layers with given name
@param l_active only layers with 'active' attribute set to True or False
@@ -695,7 +695,12 @@
selected = []
- if l_type == 'overlay':
+ if type(l_type) == type(''):
+ one_type = True
+ else:
+ one_type = False
+
+ if one_type and l_type == 'overlay':
list = self.overlays
else:
list = self.layers
@@ -703,8 +708,11 @@
# ["raster", "vector", "wms", ... ]
for layer in list:
# specified type only
- if l_type != None and layer.type != l_type:
- continue
+ if l_type != None:
+ if one_type and layer.type != l_type:
+ continue
+ elif not one_type and layer.type not in l_type:
+ continue
# mapset
if (l_mapset != None and type != 'overlay') and \
@@ -789,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
@@ -854,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
@@ -865,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
@@ -878,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/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py 2008-08-02 13:49:47 UTC (rev 32464)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py 2008-08-02 14:00:05 UTC (rev 32465)
@@ -511,23 +511,28 @@
if self.layer_selected and self.layer_selected != self.GetRootItem():
if self.GetPyData(self.layer_selected)[0]['type'] != 'group':
if lgroup is False:
- # last child of root
+ # -> last child of root (loading from workspace)
layer = self.AppendItem(parentId=self.root,
text='', ct_type=1, wnd=ctrl)
- elif lgroup is None or lgroup is True:
- # insert item as last child
+ elif lgroup is True:
+ # -> last child of group (loading from workspace)
parent = self.GetItemParent(self.layer_selected)
- # layer = self.InsertItem(parentId=parent, input=self.GetPrevSibling(self.layer_selected),
- # text='', ct_type=1, wnd=ctrl)
layer = self.AppendItem(parentId=parent,
text='', ct_type=1, wnd=ctrl)
+ elif lgroup is None:
+ # -> previous sibling of selected layer
+ parent = self.GetItemParent(self.layer_selected)
+ layer = self.InsertItem(parentId=parent,
+ input=self.GetPrevSibling(self.layer_selected),
+ text='', ct_type=1, wnd=ctrl)
- else: # group (first child of self.layer_selected)
+ else: # group -> first child of selected layer
layer = self.PrependItem(parent=self.layer_selected,
text='', ct_type=1, wnd=ctrl)
self.Expand(self.layer_selected)
- else: # add first layer to the layer tree (first child of root)
- layer = self.PrependItem(parent=self.root, text='', ct_type=1, wnd=ctrl)
+ else: # add first layer to the layer tree (i.e. first child of root)
+ layer = self.PrependItem(parent=self.root,
+ text='', ct_type=1, wnd=ctrl)
# layer is initially unchecked as inactive (beside 'command')
# use predefined value if given
@@ -538,10 +543,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)
@@ -622,7 +623,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
@@ -650,6 +667,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