[GRASS-SVN] r68998 - in grass/trunk/gui/wxpython: lmgr mapdisp
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 18 06:34:52 PDT 2016
Author: annakrat
Date: 2016-07-18 06:34:52 -0700 (Mon, 18 Jul 2016)
New Revision: 68998
Modified:
grass/trunk/gui/wxpython/lmgr/frame.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/mapdisp/main.py
Log:
wxGUI: fix overlays in d.mon
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2016-07-17 08:11:01 UTC (rev 68997)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2016-07-18 13:34:52 UTC (rev 68998)
@@ -754,9 +754,9 @@
self.GetMapDisplay().AddBarscale()
elif layertype == 'rastleg':
if len(command) > 1:
- self.GetMapDisplay().AddLegend(cmd=command, showDialog=False)
+ self.GetMapDisplay().AddLegend(cmd=command)
else:
- self.GetMapDisplay().AddLegend(showDialog=True)
+ self.GetMapDisplay().AddLegend()
elif layertype == 'northarrow':
if len(command) > 1:
self.GetMapDisplay().AddArrow(cmd=command)
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2016-07-17 08:11:01 UTC (rev 68997)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2016-07-18 13:34:52 UTC (rev 68998)
@@ -1228,7 +1228,7 @@
self.MapWindow.mouse['use'] = 'pointer'
- def AddLegend(self, cmd=None, showDialog=None):
+ def AddLegend(self, cmd=None):
"""Handler for legend map decoration menu selection."""
if cmd:
Modified: grass/trunk/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/main.py 2016-07-17 08:11:01 UTC (rev 68997)
+++ grass/trunk/gui/wxpython/mapdisp/main.py 2016-07-18 13:34:52 UTC (rev 68998)
@@ -83,6 +83,7 @@
# TODO temporary solution, layer managment by different tools in GRASS
# should be resovled
self.ownedLayers = []
+ self.oldOverlays = []
if mapfile:
self.mapfileCmd = mapfile
@@ -175,28 +176,34 @@
layerType=ltype)[0]
args = {}
- if ltype in ('barscale', 'rastleg', 'northarrow'):
- classLayer = Overlay
+
+ if ltype in ('barscale', 'rastleg', 'northarrow', 'text'):
+ # TODO: this is still not optimal
+ # it is there to prevent adding the same overlay multiple times
+ if cmd in self.oldOverlays:
+ continue
if ltype == 'rastleg':
- args['id'] = 0
+ self._giface.GetMapDisplay().AddLegend(cmd=cmd)
elif ltype == 'barscale':
- args['id'] = 1
- else:
- args['id'] = 2
- else:
- classLayer = MapLayer
- args['ltype'] = ltype
+ self._giface.GetMapDisplay().AddBarscale(cmd=cmd)
+ elif ltype == 'northarrow':
+ self._giface.GetMapDisplay().AddArrow(cmd=cmd)
+ elif ltype == 'text':
+ self._giface.GetMapDisplay().AddDtext(cmd=cmd)
+ self.oldOverlays.append(cmd)
+ continue
- mapLayer = classLayer(
- name=name,
- cmd=cmd,
- Map=None,
- hidden=True,
- render=False,
- mapfile=mapFile,
- **args)
- mapLayer.GetRenderMgr().updateProgress.connect(
- self.GetRenderMgr().ReportProgress)
+ classLayer = MapLayer
+ args['ltype'] = ltype
+
+ mapLayer = classLayer(name=name,
+ cmd=cmd,
+ Map=None,
+ hidden=True,
+ render=False,
+ mapfile=mapFile,
+ **args)
+ mapLayer.GetRenderMgr().updateProgress.connect(self.GetRenderMgr().ReportProgress)
if render_env:
mapLayer.GetRenderMgr().UpdateRenderEnv(render_env)
render_env = dict()
@@ -316,7 +323,23 @@
def __init__(self, map, giface):
self._map = map
self._giface = giface
+ self._index = 0
+ def __len__(self):
+ return len(self._map.GetListOfLayers())
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ items = self._map.GetListOfLayers()
+ try:
+ result = items[self._index]
+ except IndexError:
+ raise StopIteration
+ self._index += 1
+ return result
+
def GetSelectedLayers(self, checkedOnly=True):
# hidden and selected vs checked and selected
items = self._map.GetListOfLayers()
More information about the grass-commit
mailing list