[GRASS-SVN] r60594 - in grass/trunk/gui/wxpython: core gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 29 19:30:30 PDT 2014


Author: annakrat
Date: 2014-05-29 19:30:30 -0700 (Thu, 29 May 2014)
New Revision: 60594

Modified:
   grass/trunk/gui/wxpython/core/layerlist.py
   grass/trunk/gui/wxpython/gui_core/simplelmgr.py
Log:
wxGUI/mapswipe: add support for RGB maps

Modified: grass/trunk/gui/wxpython/core/layerlist.py
===================================================================
--- grass/trunk/gui/wxpython/core/layerlist.py	2014-05-30 01:51:37 UTC (rev 60593)
+++ grass/trunk/gui/wxpython/core/layerlist.py	2014-05-30 02:30:30 UTC (rev 60594)
@@ -189,10 +189,11 @@
         self._hidden = False
         self._initialized = False
 
-        self._mapTypes = ['rast', 'vect', 'rast3d']
+        self._mapTypes = ['rast', 'vect', 'rast3d', 'rgb']
         self._internalTypes = {'rast': 'cell',
                                'vect': 'vector',
-                               'rast3d': 'grid3'}
+                               'rast3d': 'grid3',
+                               'rgb': 'rgb'}
 
     def GetName(self):
         return self._name
@@ -206,7 +207,7 @@
         """
         if not self.hidden:
             fullName = name.split('@')
-            if len(fullName) == 1:
+            if len(fullName) == 1 and self._mapType != 'rgb':  # skip checking rgb maps for now
                 if self._mapType is None:
                     raise ValueError("To set layer name, the type of layer must be specified.")
 
@@ -361,6 +362,8 @@
             mapType = 'vector'
         elif layer.mapType == 'rast3d':
             mapType = '3d-raster'
+        elif layer.mapType == 'rgb':
+            mapType = 'rgb'
         self._renderer.AddLayer(ltype=mapType, command=layer.cmd,
                                 name=layer.name, active=layer.active,
                                 hidden=False, opacity=layer.opacity,

Modified: grass/trunk/gui/wxpython/gui_core/simplelmgr.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/simplelmgr.py	2014-05-30 01:51:37 UTC (rev 60593)
+++ grass/trunk/gui/wxpython/gui_core/simplelmgr.py	2014-05-30 02:30:30 UTC (rev 60594)
@@ -33,12 +33,14 @@
 SIMPLE_LMGR_RASTER = 1
 SIMPLE_LMGR_VECTOR = 2
 SIMPLE_LMGR_RASTER3D = 4
-SIMPLE_LMGR_TB_TOP = 8
-SIMPLE_LMGR_TB_BOTTOM = 16
-SIMPLE_LMGR_TB_LEFT = 32
-SIMPLE_LMGR_TB_RIGHT = 64
+SIMPLE_LMGR_RGB = 8
 
+SIMPLE_LMGR_TB_TOP = 16
+SIMPLE_LMGR_TB_BOTTOM = 32
+SIMPLE_LMGR_TB_LEFT = 64
+SIMPLE_LMGR_TB_RIGHT = 128
 
+
 class SimpleLayerManager(wx.Panel):
     """!Simple layer manager class provides similar functionality to
     Layertree, but it's just list, not tree."""
@@ -193,6 +195,15 @@
                                                    completed=(self.GetOptData, layer, ''))
         event.Skip()
 
+    def OnAddRGB(self, event):
+        """!Opens d.rgb dialog and adds layer.
+        Dummy layer is added first."""
+        cmd = ['d.rgb']
+        layer = self.AddRGB(name='', cmd=cmd, hidden=True, dialog=None)
+        GUI(parent=self, giface=None, modal=self._modal).ParseCommand(cmd=cmd,
+                                                    completed=(self.GetOptData, layer, ''))
+        event.Skip()
+
     def OnRemove(self, event):
         """!Removes selected layers from list."""
         layers = self._layerList.GetSelectedLayers(activeOnly=False)
@@ -343,6 +354,13 @@
                                             cmd=cmd, hidden=hidden)
         return layer
 
+    def AddRGB(self, name, cmd, hidden, dialog):
+        """!Ads new vector layer."""
+        layer = self._layerList.AddNewLayer(name=name, mapType='rgb',
+                                            active=True,
+                                            cmd=cmd, hidden=hidden)
+        return layer
+
     def GetLayerInfo(self, layer, key):
         """!Just for compatibility, should be removed in the future"""
         value = getattr(layer, key)
@@ -396,6 +414,9 @@
         if self._style & SIMPLE_LMGR_RASTER3D:
             data.insert(0, ('addRaster3d', icons['addRast3d'],
                             self.parent.OnAddRast3d))
+        if self._style & SIMPLE_LMGR_RGB:
+            data.insert(0, ('addRGB', icons['addRGB'],
+                            self.parent.OnAddRGB))
         if self._style & SIMPLE_LMGR_VECTOR:
             data.insert(0, ('addVector', BaseIcons['addVect'],
                             self.parent.OnAddVector))
@@ -425,6 +446,7 @@
     'addRast3d': MetaIcon(img='layer-raster3d-add',
                           label=_("Add 3D raster map layer"),
                           desc=_("Add 3D raster map layer")),
+    'addRGB': MetaIcon(img='layer-rgb-add', label=_('Add RGB map layer'))
     }
 
 



More information about the grass-commit mailing list