[GRASS-SVN] r57629 - in grass/trunk/gui/wxpython: core lmgr mapwin

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 10 07:13:53 PDT 2013


Author: annakrat
Date: 2013-09-10 07:13:53 -0700 (Tue, 10 Sep 2013)
New Revision: 57629

Modified:
   grass/trunk/gui/wxpython/core/render.py
   grass/trunk/gui/wxpython/lmgr/layertree.py
   grass/trunk/gui/wxpython/mapwin/buffered.py
Log:
wxGUI/layertree: add more options to 3d raster context menu, fix context menu for multiple different selected maps

Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py	2013-09-10 13:01:10 UTC (rev 57628)
+++ grass/trunk/gui/wxpython/core/render.py	2013-09-10 14:13:53 UTC (rev 57629)
@@ -601,9 +601,9 @@
         Debug.msg(2, "Map.ChangeMapSize(): width=%d, height=%d" % \
                       (self.width, self.height))
         
-    def GetRegion(self, rast = [], zoom = False, vect = [], regionName = None,
-                  n = None, s = None, e = None, w = None, default = False,
-                  update = False, add3d = False):
+    def GetRegion(self, rast=None, zoom=False, vect=None, rast3d=None, regionName=None,
+                  n=None, s=None, e=None, w=None, default=False,
+                  update=False, add3d=False):
         """!Get region settings (g.region -upgc)
         
         Optionally extent, raster or vector map layer can be given.
@@ -611,6 +611,7 @@
         @param rast list of raster maps
         @param zoom zoom to raster map (ignore NULLs)
         @param vect list of vector maps
+        @param rast3d 3d raster map (not list, no support of multiple 3d rasters in g.region)
         @param regionName  named region or None
         @param n,s,e,w force extent
         @param default force default region settings
@@ -663,6 +664,9 @@
         
         if vect:
             cmd['vect'] = ','.join(vect)
+
+        if rast3d:
+            cmd['rast3d'] = rast3d
         
         ret, reg, msg = RunCommand('g.region',
                                    read = True,
@@ -676,6 +680,9 @@
             elif vect:
                 message = _("Unable to zoom to vector map <%s>.") % vect[0] + \
                     "\n\n" + _("Details:") + " %s" % msg
+            elif rast3d:
+                message = _("Unable to zoom to 3d raster map <%s>.") % rast3d + \
+                    "\n\n" + _("Details:") + " %s" % msg
             else:
                 message = _("Unable to get current geographic extent. "
                             "Force quiting wxGUI. Please manually run g.region to "

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2013-09-10 13:01:10 UTC (rev 57628)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2013-09-10 14:13:53 UTC (rev 57629)
@@ -417,21 +417,32 @@
         if ltype != "command" and numSelected == 1:
             self.popupMenu.Append(self.popupID['rename'], text = _("Rename"))
             self.Bind(wx.EVT_MENU, self.OnRenameLayer, id = self.popupID['rename'])
+
+        # when multiple maps are selected of different types
+        # we cannot zoom or change region
+        # because g.region can handle only the same type
+        same = True
+        selected = self.GetSelectedLayers()
+        for layer in selected:
+            if self.GetLayerInfo(layer, key='type') != ltype:
+                same = False
+                break
         
         # map layer items
         if ltype not in ("group", "command"):
             if numSelected == 1:
                 self.popupMenu.AppendSeparator()
-                self.popupMenu.Append(self.popupID['opacity'], text = _("Change opacity level"))
-                self.Bind(wx.EVT_MENU, self.OnPopupOpacityLevel, id = self.popupID['opacity'])
+                if ltype != '3d-raster':
+                    self.popupMenu.Append(self.popupID['opacity'], text=_("Change opacity level"))
+                    self.Bind(wx.EVT_MENU, self.OnPopupOpacityLevel, id=self.popupID['opacity'])
                 self.popupMenu.Append(self.popupID['properties'], text = _("Properties"))
                 self.Bind(wx.EVT_MENU, self.OnPopupProperties, id = self.popupID['properties'])
             
                 if ltype in ('raster', 'vector', '3d-raster') and self.lmgr.IsPaneShown('toolbarNviz'):
                     self.popupMenu.Append(self.popupID['nviz'], _("3D view properties"))
                     self.Bind (wx.EVT_MENU, self.OnNvizProperties, id = self.popupID['nviz'])
-            
-            if ltype in ('raster', 'vector', 'rgb'):
+
+            if same and ltype in ('raster', 'vector', 'rgb', '3d-raster'):
                 self.popupMenu.AppendSeparator()
                 self.popupMenu.Append(self.popupID['zoom'], text = _("Zoom to selected map(s)"))
                 self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToMap, id = self.popupID['zoom'])
@@ -519,10 +530,11 @@
             
         # raster layers (specific items)
         elif mltype and mltype == "raster":
-            self.popupMenu.Append(self.popupID['zoom1'], text = _("Zoom to selected map(s) (ignore NULLs)"))
-            self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToRaster, id = self.popupID['zoom1'])
-            self.popupMenu.Append(self.popupID['region1'], text = _("Set computational region from selected map(s) (ignore NULLs)"))
-            self.Bind(wx.EVT_MENU, self.OnSetCompRegFromRaster, id = self.popupID['region1'])
+            if same:
+                self.popupMenu.Append(self.popupID['zoom1'], text=_("Zoom to selected map(s) (ignore NULLs)"))
+                self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToRaster, id=self.popupID['zoom1'])
+                self.popupMenu.Append(self.popupID['region1'], text=_("Set computational region from selected map(s) (ignore NULLs)"))
+                self.Bind(wx.EVT_MENU, self.OnSetCompRegFromRaster, id=self.popupID['region1'])
 
             if numSelected == 1:
                 self.popupMenu.AppendSeparator()
@@ -542,6 +554,16 @@
                 self.Bind (wx.EVT_MENU, self.OnProfile, id = self.popupID['prof'])
                 self.popupMenu.Append(self.popupID['meta'], _("Metadata"))
                 self.Bind (wx.EVT_MENU, self.OnMetadata, id = self.popupID['meta'])
+
+        elif mltype and mltype == '3d-raster':
+            if numSelected == 1:
+                self.popupMenu.AppendSeparator()
+                self.popupMenu.Append(self.popupID['color'], _("Set color table"))
+                self.Bind(wx.EVT_MENU, self.OnRasterColorTable, id=self.popupID['color'])
+                self.popupMenu.Append(self.popupID['univar'], _("Univariate raster statistics"))
+                self.Bind(wx.EVT_MENU, self.OnUnivariateStats, id=self.popupID['univar'])
+                self.popupMenu.Append(self.popupID['meta'], _("Metadata"))
+                self.Bind(wx.EVT_MENU, self.OnMetadata, id=self.popupID['meta'])
         
         # web service layers (specific item)
         elif mltype and mltype == "wms":
@@ -584,6 +606,8 @@
             cmd = ['r.info']
         elif mltype == 'vector':
             cmd = ['v.info']
+        elif mltype == '3d-raster':
+            cmd = ['r3.info']
         cmd.append('map=%s' % mapLayer.GetName())
 
         # print output to command log area
@@ -631,6 +655,8 @@
         # print output to command log area
         if len(cmd) > 1:
             cmd.append('-p')
+            if mltype == '3d-raster':
+                cmd.append('-3')
             self._giface.RunCmd(cmd, compReg = False)
 
     def OnProfile(self, event):
@@ -647,7 +673,12 @@
     def OnRasterColorTable(self, event):
         """!Set color table for raster map"""
         name = self.GetLayerInfo(self.layer_selected, key = 'maplayer').GetName()
-        GUI(parent = self).ParseCommand(['r.colors',
+        ltype = self.GetLayerInfo(self.layer_selected, key='type')
+        if ltype == '3d-raster':
+            command = 'r3.colors'
+        else:
+            command = 'r.colors'
+        GUI(parent = self).ParseCommand([command,
                                          'map=%s' % name])
 
     def OnVectorColorTable(self, event):
@@ -674,7 +705,12 @@
     def OnUnivariateStats(self, event):
         """!Univariate raster statistics"""
         name = self.GetLayerInfo(self.layer_selected, key = 'maplayer').GetName()
-        self._giface.RunCmd(['r.univar', 'map=%s' % name], switchPage = True)
+        ltype = self.GetLayerInfo(self.layer_selected, key='type')
+        if ltype == '3d-raster':
+            command = 'r3.univar'
+        else:
+            command = 'r.univar'
+        self._giface.RunCmd([command, 'map=%s' % name], switchPage=True)
 
     def OnStartEditing(self, event):
         """!Start editing vector map layer requested by the user

Modified: grass/trunk/gui/wxpython/mapwin/buffered.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/buffered.py	2013-09-10 13:01:10 UTC (rev 57628)
+++ grass/trunk/gui/wxpython/mapwin/buffered.py	2013-09-10 14:13:53 UTC (rev 57629)
@@ -1542,12 +1542,15 @@
             return
         
         rast = []
+        rast3d = None
         vect = []
         updated = False
         for l in layers:
-            # only raster/vector layers are currently supported
+            # only one raster is used: g.region does not support multiple
             if l.type == 'raster':
                 rast.append(l.GetName())
+            elif l.type == '3d-raster':
+                rast3d = l.GetName()
             elif l.type == 'vector':
                 if hasattr(self, "digit") and \
                         self.toolbar.GetLayer() == l:
@@ -1562,10 +1565,11 @@
                     rast.append(rname)
             
         if not updated:
-            self.Map.GetRegion(rast = rast,
-                               vect = vect,
-                               zoom = ignoreNulls,
-                               update = True)
+            self.Map.GetRegion(rast=rast,
+                               rast3d=rast3d,
+                               vect=vect,
+                               zoom=ignoreNulls,
+                               update=True)
         
         self.ZoomHistory(self.Map.region['n'], self.Map.region['s'],
                          self.Map.region['e'], self.Map.region['w'])



More information about the grass-commit mailing list