[GRASS-SVN] r30922 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 10 06:34:06 EDT 2008
Author: martinl
Date: 2008-04-10 06:34:06 -0400 (Thu, 10 Apr 2008)
New Revision: 30922
Modified:
grass/trunk/gui/wxpython/gui_modules/gdialogs.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
Log:
wxGUI (decorations): preset raster map name for legend to the currently selected map (if raster), trac #108
Fixing 'PyDeadObjectError' error, trac #107
Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2008-04-10 08:19:12 UTC (rev 30921)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2008-04-10 10:34:06 UTC (rev 30922)
@@ -29,6 +29,7 @@
import globalvar
import gselect
import menuform
+import utils
from preferences import globalSettings as UserSettings
class NewVectorDialog(wx.Dialog):
@@ -283,39 +284,42 @@
for p in self.parent.MapWindow.overlays[self.ovlId]['params']['params']:
if p.get('name', '') == 'map' and p.get('value', '') != '':
self.btnOK.Enable()
+ self.SetTitle(_('Legend of raster map <%s>') % \
+ utils.GetLayerNameFromCmd(self.parent.MapWindow.overlays[self.ovlId]['cmd']))
def _CreateOverlay(self):
if not self.parent.Map.GetOverlay(self.ovlId):
overlay = self.parent.Map.AddOverlay(id=self.ovlId, type=self.name,
- command=[self.cmd],
+ command=self.cmd,
l_active=False, l_render=False, l_hidden=True)
self.parent.MapWindow.overlays[self.ovlId] = {}
self.parent.MapWindow.overlays[self.ovlId] = { 'layer' : overlay,
'params' : None,
'propwin' : None,
- 'cmd' : [self.cmd],
+ 'cmd' : self.cmd,
'coords': (10, 10),
'pdcType': 'image' }
+ # build properties dialog
+ menuform.GUI().ParseCommand(cmd=self.cmd,
+ completed=(self.GetOptData, self.name, ''),
+ parentframe=self.parent, show=False)
+ else:
+ self.parent.MapWindow.overlays[self.ovlId]['propwin'].get_dcmd = self.GetOptData
+
+
def OnOptions(self, event):
""" self.SetSizer(sizer)
sizer.Fit(self)
Sets option for decoration map overlays
"""
- if not self.parent.MapWindow.overlays.has_key(self.ovlId) or \
- self.parent.MapWindow.overlays[self.ovlId]['propwin'] is None:
- # display properties dialog
- menuform.GUI().ParseCommand(cmd=[self.cmd],
- completed=(self.GetOptData, self.name, ''),
- parentframe=self.parent)
+ if self.parent.MapWindow.overlays[self.ovlId]['propwin'].IsShown():
+ self.parent.MapWindow.overlays[self.ovlId]['propwin'].SetFocus()
else:
- if self.parent.MapWindow.overlays[self.ovlId]['propwin'].IsShown():
- self.parent.MapWindow.overlays[self.ovlId]['propwin'].SetFocus()
- else:
- self.parent.MapWindow.overlays[self.ovlId]['propwin'].Show()
-
+ self.parent.MapWindow.overlays[self.ovlId]['propwin'].Show()
+
def OnCancel(self, event):
"""Cancel dialog"""
self.parent.dialogs['barscale'] = None
@@ -352,7 +356,10 @@
params and \
not self.btnOK.IsEnabled():
self.btnOK.Enable()
-
+
+ self.SetTitle(_('Legend of raster map <%s>') % \
+ utils.GetLayerNameFromCmd(self.parent.MapWindow.overlays[self.ovlId]['cmd']))
+
class TextLayerDialog(wx.Dialog):
"""
Controls setting options and displaying/hiding map overlay decorations
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-04-10 08:19:12 UTC (rev 30921)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-04-10 10:34:06 UTC (rev 30922)
@@ -3279,7 +3279,7 @@
gdialogs.DecorationDialog(parent=self, title=_('Scale and North arrow'),
size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE | wx.CENTRE,
- cmd='d.barscale',
+ cmd=['d.barscale'],
ovlId=id,
name='barscale',
checktxt = _("Show/hide scale and North arrow"),
@@ -3296,12 +3296,17 @@
id = 1 # index for overlay layer in render
+ cmd = ['d.legend']
+ if self.tree.layer_selected and \
+ self.tree.GetPyData(self.tree.layer_selected)[0]['type'] == 'raster':
+ cmd.append('map=%s' % self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].name)
+
# Decoration overlay control dialog
self.dialogs['legend'] = \
gdialogs.DecorationDialog(parent=self, title=('Legend'),
size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE | wx.CENTRE,
- cmd='d.legend',
+ cmd=cmd,
ovlId=id,
name='legend',
checktxt = _("Show/hide legend"),
More information about the grass-commit
mailing list