[GRASS-SVN] r60756 - in grass/branches/releasebranch_7_0/gui/wxpython: core gui_core mapswipe
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jun 8 11:58:42 PDT 2014
Author: annakrat
Date: 2014-06-08 11:58:42 -0700 (Sun, 08 Jun 2014)
New Revision: 60756
Modified:
grass/branches/releasebranch_7_0/gui/wxpython/core/layerlist.py
grass/branches/releasebranch_7_0/gui/wxpython/gui_core/simplelmgr.py
grass/branches/releasebranch_7_0/gui/wxpython/mapswipe/dialogs.py
Log:
wxGUI/mapswipe: add support for RGB maps - #2315 (merge from trunk, r60594,r60611,r60753)
Modified: grass/branches/releasebranch_7_0/gui/wxpython/core/layerlist.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/core/layerlist.py 2014-06-08 16:41:33 UTC (rev 60755)
+++ grass/branches/releasebranch_7_0/gui/wxpython/core/layerlist.py 2014-06-08 18:58:42 UTC (rev 60756)
@@ -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/branches/releasebranch_7_0/gui/wxpython/gui_core/simplelmgr.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/simplelmgr.py 2014-06-08 16:41:33 UTC (rev 60755)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/simplelmgr.py 2014-06-08 18:58:42 UTC (rev 60756)
@@ -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)
@@ -278,6 +289,12 @@
items = []
active = []
selected = []
+
+ # remove hidden (temporary) layers first
+ for layer in reversed(self._layerList):
+ if layer.hidden:
+ self._layerList.RemoveLayer(layer)
+
for layer in self._layerList:
if layer.opacity < 1:
items.append("{name} (opacity {opacity}%)".format(name=layer.name,
@@ -343,6 +360,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 +420,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 +452,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'))
}
Modified: grass/branches/releasebranch_7_0/gui/wxpython/mapswipe/dialogs.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/mapswipe/dialogs.py 2014-06-08 16:41:33 UTC (rev 60755)
+++ grass/branches/releasebranch_7_0/gui/wxpython/mapswipe/dialogs.py 2014-06-08 18:58:42 UTC (rev 60756)
@@ -28,7 +28,7 @@
from core.layerlist import LayerList
from core.settings import UserSettings
from gui_core.simplelmgr import SimpleLayerManager, SIMPLE_LMGR_RASTER, \
- SIMPLE_LMGR_VECTOR, SIMPLE_LMGR_TB_LEFT, SIMPLE_LMGR_TB_RIGHT
+ SIMPLE_LMGR_VECTOR, SIMPLE_LMGR_RGB, SIMPLE_LMGR_TB_LEFT, SIMPLE_LMGR_TB_RIGHT
from grass.pydispatch.signal import Signal
@@ -137,10 +137,10 @@
sizer = wx.BoxSizer(wx.HORIZONTAL)
self._firstLmgr = SimpleLayerManager(parent=panel, layerList=self._firstLayerList,
- lmgrStyle=SIMPLE_LMGR_RASTER |
+ lmgrStyle=SIMPLE_LMGR_RASTER | SIMPLE_LMGR_RGB |
SIMPLE_LMGR_VECTOR | SIMPLE_LMGR_TB_LEFT)
self._secondLmgr = SimpleLayerManager(parent=panel, layerList=self._secondLayerList,
- lmgrStyle=SIMPLE_LMGR_RASTER |
+ lmgrStyle=SIMPLE_LMGR_RASTER | SIMPLE_LMGR_RGB |
SIMPLE_LMGR_VECTOR | SIMPLE_LMGR_TB_RIGHT)
sizer.Add(self._firstLmgr, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
sizer.Add(self._secondLmgr, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
More information about the grass-commit
mailing list