[GRASS-SVN] r45035 - in grass/branches/develbranch_6/gui/wxpython:
. gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jan 14 15:47:26 EST 2011
Author: martinl
Date: 2011-01-14 12:47:26 -0800 (Fri, 14 Jan 2011)
New Revision: 45035
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: layer tree popup menu - export data
(merge r45034 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py 2011-01-14 20:41:52 UTC (rev 45034)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py 2011-01-14 20:47:26 UTC (rev 45035)
@@ -236,7 +236,8 @@
return
ltype = self.GetPyData(self.layer_selected)[0]['type']
-
+ mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
+
Debug.msg (4, "LayerTree.OnContextMenu: layertype=%s" % \
ltype)
@@ -257,15 +258,16 @@
self.popupID14 = wx.NewId()
self.popupID15 = wx.NewId()
self.popupID16 = wx.NewId()
-
+ self.popupID17 = wx.NewId()
+
self.popupMenu = wx.Menu()
-
+
numSelected = len(self.GetSelections())
# general item
self.popupMenu.Append(self.popupID1, text=_("Remove"))
self.Bind(wx.EVT_MENU, self.lmgr.OnDeleteLayer, id=self.popupID1)
-
+
if ltype != "command": # rename
self.popupMenu.Append(self.popupID2, text=_("Rename"))
self.Bind(wx.EVT_MENU, self.OnRenameLayer, id=self.popupID2)
@@ -290,23 +292,31 @@
self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToMap, id=self.popupID9)
self.popupMenu.Append(self.popupID10, text=_("Set computational region from selected map(s)"))
self.Bind(wx.EVT_MENU, self.OnSetCompRegFromMap, id=self.popupID10)
+
if numSelected > 1:
self.popupMenu.Enable(self.popupID8, False)
self.popupMenu.Enable(self.popupID3, False)
-
+
# specific items
try:
mltype = self.GetPyData(self.layer_selected)[0]['type']
except:
mltype = None
+
#
# vector layers (specific items)
#
if mltype and mltype == "vector":
self.popupMenu.AppendSeparator()
- self.popupMenu.Append(self.popupID4, text=_("Show attribute data"))
- self.Bind (wx.EVT_MENU, self.lmgr.OnShowAttributeTable, id=self.popupID4)
-
+ self.popupMenu.Append(self.popupID17, text = _("Export"))
+ self.Bind(wx.EVT_MENU, lambda x: self.lmgr.OnMenuCmd(cmd = ['v.out.ogr',
+ 'input=%s' % mapLayer.GetName()]),
+ id = self.popupID17)
+
+ self.popupMenu.AppendSeparator()
+ self.popupMenu.Append(self.popupID4, text = _("Show attribute data"))
+ self.Bind(wx.EVT_MENU, self.lmgr.OnShowAttributeTable, id = self.popupID4)
+
self.popupMenu.Append(self.popupID5, text=_("Start editing"))
self.popupMenu.Append(self.popupID6, text=_("Stop editing"))
self.popupMenu.Enable(self.popupID6, False)
@@ -359,11 +369,13 @@
self.popupMenu.Append(self.popupID7, _("Metadata"))
self.Bind (wx.EVT_MENU, self.OnMetadata, id=self.popupID7)
if numSelected > 1:
- self.popupMenu.Enable(self.popupID4, False)
- self.popupMenu.Enable(self.popupID5, False)
- self.popupMenu.Enable(self.popupID6, False)
- self.popupMenu.Enable(self.popupID7, False)
+ self.popupMenu.Enable(self.popupID4, False)
+ self.popupMenu.Enable(self.popupID5, False)
+ self.popupMenu.Enable(self.popupID6, False)
+ self.popupMenu.Enable(self.popupID7, False)
self.popupMenu.Enable(self.popupID14, False)
+ self.popupMenu.Enable(self.popupID16, False)
+ self.popupMenu.Enable(self.popupID17, False)
#
# raster layers (specific items)
@@ -373,7 +385,14 @@
self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToRaster, id=self.popupID12)
self.popupMenu.Append(self.popupID13, text=_("Set computational region from selected map(s) (ignore NULLs)"))
self.Bind(wx.EVT_MENU, self.OnSetCompRegFromRaster, id=self.popupID13)
+
self.popupMenu.AppendSeparator()
+ self.popupMenu.Append(self.popupID17, text = _("Export"))
+ self.Bind(wx.EVT_MENU, lambda x: self.lmgr.OnMenuCmd(cmd = ['r.out.gdal',
+ 'input=%s' % mapLayer.GetName()]),
+ id = self.popupID17)
+
+ self.popupMenu.AppendSeparator()
self.popupMenu.Append(self.popupID15, _("Set color table"))
self.Bind (wx.EVT_MENU, self.OnColorTable, id=self.popupID15)
self.popupMenu.Append(self.popupID4, _("Histogram"))
@@ -391,6 +410,9 @@
self.popupMenu.Enable(self.popupID5, False)
self.popupMenu.Enable(self.popupID6, False)
self.popupMenu.Enable(self.popupID11, False)
+ self.popupMenu.Enable(self.popupID17, False)
+
+
## self.PopupMenu(self.popupMenu, pos)
self.PopupMenu(self.popupMenu)
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2011-01-14 20:41:52 UTC (rev 45034)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2011-01-14 20:47:26 UTC (rev 45035)
@@ -417,13 +417,13 @@
return cmdlist
- def RunMenuCmd(self, event, cmd = ''):
+ def RunMenuCmd(self, event = None, cmd = []):
"""!Run command selected from menu"""
if event:
cmd = self.GetMenuCmd(event)
self.goutput.RunCmd(cmd, switchPage = False)
- def OnMenuCmd(self, event, cmd = ''):
+ def OnMenuCmd(self, event = None, cmd = []):
"""!Parse command selected from menu"""
if event:
cmd = self.GetMenuCmd(event)
More information about the grass-commit
mailing list