[GRASS-SVN] r57753 - grass/trunk/gui/wxpython/animation
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Sep 19 17:31:11 PDT 2013
Author: annakrat
Date: 2013-09-19 17:31:10 -0700 (Thu, 19 Sep 2013)
New Revision: 57753
Modified:
grass/trunk/gui/wxpython/animation/controller.py
grass/trunk/gui/wxpython/animation/dialogs.py
grass/trunk/gui/wxpython/animation/mapwindow.py
Log:
wxGUI/animation: fix legend placement
Modified: grass/trunk/gui/wxpython/animation/controller.py
===================================================================
--- grass/trunk/gui/wxpython/animation/controller.py 2013-09-19 21:06:27 UTC (rev 57752)
+++ grass/trunk/gui/wxpython/animation/controller.py 2013-09-20 00:31:10 UTC (rev 57753)
@@ -382,8 +382,15 @@
prov.Load()
if animationData.legendCmd:
try:
+ # place legend
+ x, y = 0.1, 0.1
bitmap = prov.LoadOverlay(animationData.legendCmd)
- self.mapwindows[animationData.windowIndex].SetOverlay(bitmap)
+ for param in animationData.legendCmd:
+ if param.startswith('at'):
+ b, t, l, r = param.split('=')[1].split(',')
+ x, y = float(l) / 100., 1 - float(t) / 100.
+ break
+ self.mapwindows[animationData.windowIndex].SetOverlay(bitmap, x, y)
except GException:
GError(message=_("Failed to display legend."))
Modified: grass/trunk/gui/wxpython/animation/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/animation/dialogs.py 2013-09-19 21:06:27 UTC (rev 57752)
+++ grass/trunk/gui/wxpython/animation/dialogs.py 2013-09-20 00:31:10 UTC (rev 57753)
@@ -535,7 +535,8 @@
self.animationData.legendCmd = self._tmpLegendCmd
else:
if self.legend.IsChecked():
- self.animationData.legendCmd = ['d.legend', 'at=5,50,2,5',
+ self.animationData.legendCmd = ['d.legend',
+ 'at=5,50,2,5',
'map=%s' % self._getLegendMapHint()]
if self.threeDPanel.IsShown():
Modified: grass/trunk/gui/wxpython/animation/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/animation/mapwindow.py 2013-09-19 21:06:27 UTC (rev 57752)
+++ grass/trunk/gui/wxpython/animation/mapwindow.py 2013-09-20 00:31:10 UTC (rev 57753)
@@ -24,7 +24,7 @@
from core.gcmd import RunCommand, GException
from core.debug import Debug
from core.settings import UserSettings
-from core.utils import _, CmdToTuple
+from core.utils import _, CmdToTuple, autoCropImageFromFile
from grass.pydispatch.signal import Signal
@@ -150,22 +150,30 @@
self.text = text
self.UpdateDrawing()
- def DrawOverlay(self):
+ def DrawOverlay(self, x, y):
self._pdc.BeginDrawing()
self._pdc.SetId(1)
- self._pdc.DrawBitmap(bmp=self._overlay, x=0, y=0)
- self._pdc.SetIdBounds(1, wx.Rect(0, 0, self._overlay.GetWidth(),
+ self._pdc.DrawBitmap(bmp=self._overlay, x=x, y=y)
+ self._pdc.SetIdBounds(1, wx.Rect(x, y, self._overlay.GetWidth(),
self._overlay.GetHeight()))
self._pdc.EndDrawing()
- def SetOverlay(self, bitmap):
- """!Sets overlay bitmap (legend)"""
+ def SetOverlay(self, bitmap, xperc, yperc):
+ """!Sets overlay bitmap (legend)
+
+ @param bitmap instance of wx.Bitmap
+ @param xperc x coordinate of bitmap top left corner in % of screen
+ @param yperc y coordinate of bitmap top left corner in % of screen
+ """
Debug.msg(3, "AnimationWindow.SetOverlay()")
if bitmap:
if self._overlay:
self._pdc.RemoveAll()
self._overlay = bitmap
- self.DrawOverlay()
+ size = self.GetClientSize()
+ x = xperc * size[0]
+ y = yperc * size[1]
+ self.DrawOverlay(x, y)
else:
self._overlay = None
self._pdc.RemoveAll()
@@ -480,8 +488,7 @@
returncode, stdout, messages = read2_command(cmdTuple[0], **cmdTuple[1])
if returncode == 0:
- bitmap = wx.Bitmap(filename, wx.BITMAP_TYPE_PNG)
- return bitmap
+ return wx.BitmapFromImage(autoCropImageFromFile(filename))
else:
os.remove(filename)
raise GException(messages)
More information about the grass-commit
mailing list