[GRASS-SVN] r69168 - in grass/trunk: display/d.mon gui/wxpython/core gui/wxpython/mapdisp
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 20 15:29:27 PDT 2016
Author: annakrat
Date: 2016-08-20 15:29:26 -0700 (Sat, 20 Aug 2016)
New Revision: 69168
Modified:
grass/trunk/display/d.mon/render_cmd.py
grass/trunk/gui/wxpython/core/render.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/mapdisp/main.py
Log:
d.mon wx: better integration of vector legend, fix d.erase when no legend is there, d.erase now removes overlays properly
Modified: grass/trunk/display/d.mon/render_cmd.py
===================================================================
--- grass/trunk/display/d.mon/render_cmd.py 2016-08-20 22:08:40 UTC (rev 69167)
+++ grass/trunk/display/d.mon/render_cmd.py 2016-08-20 22:29:26 UTC (rev 69168)
@@ -107,7 +107,7 @@
width, height, legfile = read_env_file(os.path.join(path, 'env'))
if mon.startswith('wx'):
mapfile = tempfile.NamedTemporaryFile(dir=path).name
- if cmd[0] in ('d.barscale', 'd.legend', 'd.northarrow'):
+ if cmd[0] in ('d.barscale', 'd.legend', 'd.northarrow', 'd.legend.vect'):
mapfile += '.png'
else:
mapfile += '.ppm'
@@ -117,7 +117,7 @@
render(cmd, mapfile)
update_cmd_file(os.path.join(path, 'cmd'), cmd, mapfile)
- if cmd[0] == 'd.erase':
+ if cmd[0] == 'd.erase' and os.path.exists(legfile):
os.remove(legfile)
Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py 2016-08-20 22:08:40 UTC (rev 69167)
+++ grass/trunk/gui/wxpython/core/render.py 2016-08-20 22:29:26 UTC (rev 69168)
@@ -481,6 +481,9 @@
if os.path.exists(self.Map.mapfile):
os.remove(self.Map.mapfile)
+ def UpdateRenderEnv(self, env):
+ self._render_env.update(env)
+
def _renderLayers(self, env, force=False, overlaysOnly=False):
"""Render all map layers into files
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2016-08-20 22:08:40 UTC (rev 69167)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2016-08-20 22:29:26 UTC (rev 69168)
@@ -142,8 +142,8 @@
properties=self.mapWindowProperties, overlays=self.decorations)
self.MapWindow2D.mapQueried.connect(self.Query)
self.MapWindow2D.overlayActivated.connect(self._activateOverlay)
- self.MapWindow2D.overlayRemoved.connect(self._removeOverlay)
- self.MapWindow2D.overlayRemoved.connect(self._removeOverlay)
+ self.MapWindow2D.overlayRemoved.connect(self.RemoveOverlay)
+ self.MapWindow2D.overlayRemoved.connect(self.RemoveOverlay)
self._setUpMapWindow(self.MapWindow2D)
self.MapWindow2D.mouseHandlerUnregistered.connect(self.ResetPointer)
@@ -407,7 +407,7 @@
self.MapWindow3D.ResetViewHistory()
self.MapWindow3D.UpdateView(None)
self.MapWindow3D.overlayActivated.connect(self._activateOverlay)
- self.MapWindow3D.overlayRemoved.connect(self._removeOverlay)
+ self.MapWindow3D.overlayRemoved.connect(self.RemoveOverlay)
else:
self._switchMapWindow(self.MapWindow3D)
os.environ['GRASS_REGION'] = self.Map.SetRegion(
@@ -1201,7 +1201,7 @@
else:
dlg.Show()
- def _removeOverlay(self, overlayId):
+ def RemoveOverlay(self, overlayId):
"""Hide overlay.
:param overlayId: id of overlay
@@ -1255,14 +1255,12 @@
else:
show = True
cmd = ['d.legend.vect']
- layers = self._giface.GetLayerList().GetSelectedLayers()
GUI(parent=self, giface=self._giface, show=show, modal=False).ParseCommand(
cmd, completed=(self.GetOptData, None, None))
self.MapWindow.mouse['use'] = 'pointer'
-
def AddArrow(self, cmd=None):
"""Handler for north arrow menu selection."""
if self.IsPaneShown('3d'):
Modified: grass/trunk/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/main.py 2016-08-20 22:08:40 UTC (rev 69167)
+++ grass/trunk/gui/wxpython/mapdisp/main.py 2016-08-20 22:29:26 UTC (rev 69168)
@@ -104,6 +104,15 @@
self.renderMgr = RenderMapMgr(self)
+ # update legend file variable with the one d.mon uses
+ with open(monFile['env'], 'r') as f:
+ lines = f.readlines()
+ for line in lines:
+ if 'GRASS_LEGEND_FILE' in line:
+ legfile = line.split('=', 1)[1].strip()
+ self.renderMgr.UpdateRenderEnv({'GRASS_LEGEND_FILE': legfile})
+ break
+
def GetLayersFromCmdFile(self):
"""Get list of map layers from cmdfile
"""
@@ -142,6 +151,12 @@
self.query.emit(ltype=utils.split(dWhatCmd)[
0].split('.')[-1], maps=maps)
return
+ else:
+ # clean overlays after erase
+ self.oldOverlays = []
+ overlays = self._giface.GetMapDisplay().decorations.keys()
+ for each in overlays:
+ self._giface.GetMapDisplay().RemoveOverlay(each)
existingLayers = self.GetListOfLayers()
@@ -177,7 +192,7 @@
args = {}
- if ltype in ('barscale', 'rastleg', 'northarrow', 'text'):
+ if ltype in ('barscale', 'rastleg', 'northarrow', 'text', 'vectleg'):
# TODO: this is still not optimal
# it is there to prevent adding the same overlay multiple times
if cmd in self.oldOverlays:
@@ -190,6 +205,8 @@
self._giface.GetMapDisplay().AddArrow(cmd=cmd)
elif ltype == 'text':
self._giface.GetMapDisplay().AddDtext(cmd=cmd)
+ elif ltype == 'vectleg':
+ self._giface.GetMapDisplay().AddLegendVect(cmd=cmd)
self.oldOverlays.append(cmd)
continue
More information about the grass-commit
mailing list