[GRASS-SVN] r43976 -
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 18 16:38:12 EDT 2010
Author: martinl
Date: 2010-10-18 13:38:11 -0700 (Mon, 18 Oct 2010)
New Revision: 43976
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mcalc_builder.py
Log:
wxGUI/mapcalc: checkbox to add created raster map to layer tree
(merge r43974 from trunk)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py 2010-10-18 20:36:39 UTC (rev 43975)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py 2010-10-18 20:38:11 UTC (rev 43976)
@@ -61,9 +61,8 @@
TREE_ITEM_HEIGHT = 25
class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
+ """!Creates layer tree structure
"""
- Creates layer tree structure
- """
def __init__(self, parent,
id = wx.ID_ANY, style=wx.SUNKEN_BORDER,
ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
@@ -641,7 +640,7 @@
self.EditLabel(self.layer_selected)
def AddLayer(self, ltype, lname=None, lchecked=None,
- lopacity=1.0, lcmd=None, lgroup=None, lvdigit=None, lnviz=None):
+ lopacity=1.0, lcmd=None, lgroup=None, lvdigit=None, lnviz=None, multiple = True):
"""!Add new item to the layer tree, create corresponding MapLayer instance.
Launch property dialog if needed (raster, vector, etc.)
@@ -653,14 +652,25 @@
@param lgroup index of group item (-1 for root) or None
@param lvdigit vector digitizer settings (eg. geometry attributes)
@param lnviz layer Nviz properties
+ @param multiple True to allow multiple map layers in layer tree
"""
+ if lname and not multiple:
+ # check for duplicates
+ item = self.GetFirstVisibleItem()
+ while item and item.IsOk():
+ if self.GetPyData(item)[0]['type'] == 'vector':
+ name = self.GetPyData(item)[0]['maplayer'].GetName()
+ if name == lname:
+ return
+ item = self.GetNextVisible(item)
+
self.first = True
params = {} # no initial options parameters
# deselect active item
if self.layer_selected:
self.SelectItem(self.layer_selected, select=False)
-
+
Debug.msg (3, "LayerTree().AddLayer(): ltype=%s" % (ltype))
if ltype == 'command':
@@ -1369,20 +1379,20 @@
mapWin.ResetView()
def ReorderLayers(self):
- """!Add commands from data associated with
- any valid layers (checked or not) to layer list in order to
- match layers in layer tree."""
+ """!Add commands from data associated with any valid layers
+ (checked or not) to layer list in order to match layers in
+ layer tree."""
# make a list of visible layers
treelayers = []
-
+
vislayer = self.GetFirstVisibleItem()
-
+
if not vislayer or self.GetPyData(vislayer) is None:
return
-
+
itemList = ""
-
+
for item in range(self.GetCount()):
itemList += self.GetItemText(vislayer) + ','
if self.GetPyData(vislayer)[0]['type'] != 'group':
@@ -1392,15 +1402,15 @@
break
else:
vislayer = self.GetNextVisible(vislayer)
-
+
Debug.msg (4, "LayerTree.ReorderLayers(): items=%s" % \
(itemList))
-
+
# reorder map layers
treelayers.reverse()
self.Map.ReorderLayers(treelayers)
self.reorder = False
-
+
def ChangeLayer(self, item):
"""!Change layer"""
type = self.GetPyData(item)[0]['type']
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mcalc_builder.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mcalc_builder.py 2010-10-18 20:36:39 UTC (rev 43975)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mcalc_builder.py 2010-10-18 20:38:11 UTC (rev 43976)
@@ -24,6 +24,8 @@
globalvar.CheckForWx()
import wx
+import grass.script as grass
+
import gcmd
import gselect
try:
@@ -210,6 +212,12 @@
style = wx.CB_DROPDOWN |
wx.CB_READONLY | wx.TE_PROCESS_ENTER)
+ self.addbox = wx.CheckBox(parent=self.panel,
+ label=_('Add created raster map into layer tree'), style = wx.NO_BORDER)
+ self.addbox.SetValue(UserSettings.Get(group='cmd', key='addNewLayer', subkey='enabled'))
+ if not self.parent or self.parent.GetName() != 'LayerManager':
+ self.addbox.Hide()
+
#
# Bindings
#
@@ -313,15 +321,17 @@
sizer.Add(item = expressSizer, proportion = 1,
flag = wx.EXPAND | wx.LEFT | wx.RIGHT,
border = 5)
-
+ if self.addbox.IsShown():
+ sizer.Add(item = self.addbox, proportion = 0,
+ flag = wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT,
+ border = 5)
sizer.Add(item = buttonSizer4, proportion = 0,
flag = wx.ALIGN_RIGHT | wx.ALL, border = 1)
- self.panel.SetAutoLayout(True)
+ self.panel.SetAutoLayout(True)
self.panel.SetSizer(sizer)
sizer.Fit(self.panel)
- self.Fit()
self.Layout()
def AddMark(self,event):
@@ -404,15 +414,28 @@
mctxt = self.text_mcalc.GetValue().strip().replace("\n"," ")
mctxt = mctxt.replace(" " , "")
-
+
if self.log:
cmd = [self.cmd, str('%s = %s' % (name, mctxt))]
- self.log.RunCmd(cmd)
+ self.log.RunCmd(cmd, onDone = self.OnDone)
self.parent.Raise()
else:
gcmd.RunCommand(self.cmd,
"%s=%s" % (name, mctxt))
+ def OnDone(self, cmd, returncode):
+ """!Add create map to the layer tree"""
+ if not self.addbox.IsChecked():
+ return
+ name = self.newmaptxt.GetValue().strip() + '@' + grass.gisenv()['MAPSET']
+ self.parent.GetLayerTree().AddLayer(ltype = 'vector',
+ lname = name,
+ lcmd = ['d.rast', 'map=%s' % name],
+ multiple = False)
+ display = self.parent.GetLayerTree().GetMapDisplay()
+ if display and display.IsAutoRendered():
+ display.GetWindow().UpdateMap(render = True)
+
def OnClear(self, event):
"""!Clears text area
"""
More information about the grass-commit
mailing list