[GRASS-SVN] r38260 - in grass/branches/develbranch_6/gui/wxpython:
. gui_modules xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jul 5 13:31:02 EDT 2009
Author: martinl
Date: 2009-07-05 13:31:02 -0400 (Sun, 05 Jul 2009)
New Revision: 38260
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py
grass/branches/develbranch_6/gui/wxpython/wxgui.py
grass/branches/develbranch_6/gui/wxpython/xml/grass-gxw.dtd
Log:
wxGUI: projection statusbar info checkbox moved to the mapdisplay
status and stored in workspace file
(merge from trunk, r38258 & r38259)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py 2009-07-05 17:23:24 UTC (rev 38259)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py 2009-07-05 17:31:02 UTC (rev 38260)
@@ -99,7 +99,8 @@
_("Display mode"),
_("Display geometry"),
_("Map scale"),
- _("Go to")]
+ _("Go to"),
+ _("Projection"),]
"""!File name extension binaries/scripts"""
if subprocess.mswindows:
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2009-07-05 17:23:24 UTC (rev 38259)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2009-07-05 17:31:02 UTC (rev 38260)
@@ -207,6 +207,18 @@
self.statusbarWin['goto'].Hide()
self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnGoTo, self.statusbarWin['goto'])
+ # projection
+ self.statusbarWin['projection'] = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY,
+ label=_("Use defined projection"))
+ self.statusbarWin['projection'].SetValue(False)
+ size = self.statusbarWin['projection'].GetSize()
+ self.statusbarWin['projection'].SetMinSize((size[0] + 150, size[1]))
+ self.statusbarWin['projection'].SetToolTip(wx.ToolTip (_("Reproject coordinates displayed "
+ "in the statusbar. Projection can be "
+ "defined in GUI preferences dialog "
+ "(tab 'Display')")))
+ self.statusbarWin['projection'].Hide()
+
# mask
self.statusbarWin['mask'] = wx.StaticText(parent = self.statusbar, id = wx.ID_ANY,
label = '')
@@ -549,22 +561,24 @@
self.statusbar.SetStatusText("%.2f, %.2f (seg: %.2f; tot: %.2f)" % \
(e, n, distance_seg, distance_tot), 0)
else:
- if UserSettings.Get(group='display', key='projection', subkey='enabled') and \
- UserSettings.Get(group='display', key='projection', subkey='proj4'):
- proj, coord = utils.ReprojectCoordinates(coord = (e, n),
- projOut = UserSettings.Get(group='display',
- key='projection',
- subkey='proj4'),
- flags = 'd')
+ if self.statusbarWin['projection'].IsChecked():
+ if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+ self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
+ else:
+ proj, coord = utils.ReprojectCoordinates(coord = (e, n),
+ projOut = UserSettings.Get(group='display',
+ key='projection',
+ subkey='proj4'),
+ flags = 'd')
- if coord:
- e, n = coord
- if proj in ('ll', 'latlong', 'longlat'):
- self.statusbar.SetStatusText("%s" % utils.Deg2DMS(e, n), 0)
+ if coord:
+ e, n = coord
+ if proj in ('ll', 'latlong', 'longlat'):
+ self.statusbar.SetStatusText("%s" % utils.Deg2DMS(e, n), 0)
+ else:
+ self.statusbar.SetStatusText("%.2f; %.2f" % (e, n), 0)
else:
- self.statusbar.SetStatusText("%.2f; %.2f" % (e, n), 0)
- else:
- self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
+ self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
else:
if self.Map.projinfo['proj'] == 'll':
self.statusbar.SetStatusText("%s" % utils.Deg2DMS(e, n), 0)
@@ -790,29 +804,31 @@
Go to position
"""
try:
- if UserSettings.Get(group='display', key='projection', subkey='enabled') and \
- UserSettings.Get(group='display', key='projection', subkey='proj4'):
- # reproject values
- projIn = UserSettings.Get(group='display',
- key='projection',
- subkey='proj4')
- projOut = gcmd.RunCommand('g.proj',
- flags = 'jf',
- read = True)
- proj = projIn.split(' ')[0].split('=')[1]
- if proj in ('ll', 'latlong', 'longlat'):
- e, n = self.statusbarWin['goto'].GetValue().split(';')
- e, n = utils.DMS2Deg(e, n)
- proj, coord1 = utils.ReprojectCoordinates(coord = (e, n),
- projIn = projIn,
- projOut = projOut, flags = 'd')
- e, n = coord1
+ if self.statusbarWin['projection'].IsChecked():
+ if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+ self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
else:
- e, n = map(float, self.statusbarWin['goto'].GetValue().split(';'))
- proj, coord1 = utils.ReprojectCoordinates(coord = (e, n),
- projIn = projIn,
- projOut = projOut, flags = 'd')
- e, n = coord1
+ # reproject values
+ projIn = UserSettings.Get(group='display',
+ key='projection',
+ subkey='proj4')
+ projOut = gcmd.RunCommand('g.proj',
+ flags = 'jf',
+ read = True)
+ proj = projIn.split(' ')[0].split('=')[1]
+ if proj in ('ll', 'latlong', 'longlat'):
+ e, n = self.statusbarWin['goto'].GetValue().split(';')
+ e, n = utils.DMS2Deg(e, n)
+ proj, coord1 = utils.ReprojectCoordinates(coord = (e, n),
+ projIn = projIn,
+ projOut = projOut, flags = 'd')
+ e, n = coord1
+ else:
+ e, n = map(float, self.statusbarWin['goto'].GetValue().split(';'))
+ proj, coord1 = utils.ReprojectCoordinates(coord = (e, n),
+ projIn = projIn,
+ projOut = projOut, flags = 'd')
+ e, n = coord1
else:
if self.Map.projinfo['proj'] == 'll':
e, n = self.statusbarWin['goto'].GetValue().split(';')
@@ -820,9 +836,11 @@
e, n = map(float, self.statusbarWin['goto'].GetValue().split(';'))
region = self.Map.GetCurrentRegion()
- if UserSettings.Get(group='display', key='projection', subkey='enabled') and \
- UserSettings.Get(group='display', key='projection', subkey='proj4'):
- region['center_easting'], region['center_northing'] = e, n
+ if self.statusbarWin['projection'].IsChecked():
+ if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+ self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
+ else:
+ region['center_easting'], region['center_northing'] = e, n
else:
if self.Map.projinfo['proj'] == 'll':
region['center_easting'], region['center_northing'] = utils.DMS2Deg(e, n)
@@ -863,6 +881,7 @@
self.statusbarWin['resolution'].Hide()
self.statusbarWin['mapscale'].Hide()
self.statusbarWin['goto'].Hide()
+ self.statusbarWin['projection'].Hide()
self.mapScaleValue = self.ppm = None
if self.statusbarWin['toggle'].GetSelection() == 0: # Coordinates
@@ -877,45 +896,47 @@
else:
region = self.Map.GetRegion() # computation region
- if UserSettings.Get(group='display', key='projection', subkey='enabled') and \
- UserSettings.Get(group='display', key='projection', subkey='proj4'):
- projOut = UserSettings.Get(group='display',
- key='projection',
- subkey='proj4')
- proj, coord1 = utils.ReprojectCoordinates(coord = (region["w"], region["s"]),
+ if self.statusbarWin['projection'].IsChecked():
+ if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+ self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
+ else:
+ projOut = UserSettings.Get(group='display',
+ key='projection',
+ subkey='proj4')
+ proj, coord1 = utils.ReprojectCoordinates(coord = (region["w"], region["s"]),
+ projOut = projOut, flags = 'd')
+ proj, coord2 = utils.ReprojectCoordinates(coord = (region["e"], region["n"]),
projOut = projOut, flags = 'd')
- proj, coord2 = utils.ReprojectCoordinates(coord = (region["e"], region["n"]),
- projOut = projOut, flags = 'd')
- if sel == 2:
- proj, coord3 = utils.ReprojectCoordinates(coord = (0.0, 0.0),
- projOut = projOut, flags = 'd')
- proj, coord4 = utils.ReprojectCoordinates(coord = (region["ewres"], region["nsres"]),
- projOut = projOut, flags = 'd')
- if coord1 and coord2:
- if proj in ('ll', 'latlong', 'longlat'):
- w, s = utils.Deg2DMS(coord1[0], coord1[1], string = False)
- e, n = utils.Deg2DMS(coord2[0], coord2[1], string = False)
- if sel == 1:
- self.statusbar.SetStatusText("%s - %s, %s - %s" %
+ if sel == 2:
+ proj, coord3 = utils.ReprojectCoordinates(coord = (0.0, 0.0),
+ projOut = projOut, flags = 'd')
+ proj, coord4 = utils.ReprojectCoordinates(coord = (region["ewres"], region["nsres"]),
+ projOut = projOut, flags = 'd')
+ if coord1 and coord2:
+ if proj in ('ll', 'latlong', 'longlat'):
+ w, s = utils.Deg2DMS(coord1[0], coord1[1], string = False)
+ e, n = utils.Deg2DMS(coord2[0], coord2[1], string = False)
+ if sel == 1:
+ self.statusbar.SetStatusText("%s - %s, %s - %s" %
+ (w, e, s, n), 0)
+ else:
+ ewres, nsres = utils.Deg2DMS(abs(coord3[0]) - abs(coord4[0]),
+ abs(coord3[1]) - abs(coord4[1]),
+ string = False, hemisphere = False)
+ self.statusbar.SetStatusText("%s - %s, %s - %s (%s, %s)" %
+ (w, e, s, n, ewres, nsres), 0)
+ else:
+ w, s = coord1
+ e, n = coord2
+ if sel == 1:
+ self.statusbar.SetStatusText("%.2f - %.2f, %.2f - %.2f" %
(w, e, s, n), 0)
- else:
- ewres, nsres = utils.Deg2DMS(abs(coord3[0]) - abs(coord4[0]),
- abs(coord3[1]) - abs(coord4[1]),
- string = False, hemisphere = False)
- self.statusbar.SetStatusText("%s - %s, %s - %s (%s, %s)" %
- (w, e, s, n, ewres, nsres), 0)
+ else:
+ ewres, nsres = coord3
+ self.statusbar.SetStatusText("%.2f - %.2f, %.2f - %.2f (%.2f, %.2f)" %
+ (w, e, s, n, ewres, nsres), 0)
else:
- w, s = coord1
- e, n = coord2
- if sel == 1:
- self.statusbar.SetStatusText("%.2f - %.2f, %.2f - %.2f" %
- (w, e, s, n), 0)
- else:
- ewres, nsres = coord3
- self.statusbar.SetStatusText("%.2f - %.2f, %.2f - %.2f (%.2f, %.2f)" %
- (w, e, s, n, ewres, nsres), 0)
- else:
- self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
+ self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
else:
if self.Map.projinfo['proj'] == 'll':
w, s = utils.Deg2DMS(region["w"], region["s"],
@@ -1014,23 +1035,25 @@
elif self.statusbarWin['toggle'].GetSelection() == 7: # go to
self.statusbar.SetStatusText("")
region = self.Map.GetCurrentRegion()
- if UserSettings.Get(group='display', key='projection', subkey='enabled') and \
- UserSettings.Get(group='display', key='projection', subkey='proj4'):
- proj, coord = utils.ReprojectCoordinates(coord = (region['center_easting'],
- region['center_northing']),
- projOut = UserSettings.Get(group='display',
- key='projection',
- subkey='proj4'),
- flags = 'd')
- if coord:
- if proj in ('ll', 'latlong', 'longlat'):
- self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(coord[0],
+ if self.statusbarWin['projection'].IsChecked():
+ if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+ self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
+ else:
+ proj, coord = utils.ReprojectCoordinates(coord = (region['center_easting'],
+ region['center_northing']),
+ projOut = UserSettings.Get(group='display',
+ key='projection',
+ subkey='proj4'),
+ flags = 'd')
+ if coord:
+ if proj in ('ll', 'latlong', 'longlat'):
+ self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(coord[0],
coord[1]))
+ else:
+ self.statusbarWin['goto'].SetValue("%.2f; %.2f" % (coord[0],
+ coord[1]))
else:
- self.statusbarWin['goto'].SetValue("%.2f; %.2f" % (coord[0],
- coord[1]))
- else:
- self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
+ self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
else:
if self.Map.projinfo['proj'] == 'll':
self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(region['center_easting'],
@@ -1043,6 +1066,19 @@
# disable long help
self.StatusbarEnableLongHelp(False)
+ elif self.statusbarWin['toggle'].GetSelection() == 8: # projection
+ self.statusbar.SetStatusText("")
+ epsg = UserSettings.Get(group='display', key='projection', subkey='epsg')
+ if epsg:
+ label = '%s (EPSG: %s)' % (_("Use defined projection"), epsg)
+ self.statusbarWin['projection'].SetLabel(label)
+ else:
+ self.statusbarWin['projection'].SetLabel(_("Use defined projection"))
+ self.statusbarWin['projection'].Show()
+
+ # disable long help
+ self.StatusbarEnableLongHelp(False)
+
else:
self.statusbar.SetStatusText("", 1)
@@ -1059,6 +1095,7 @@
(0, self.statusbarWin['resolution']),
(0, self.statusbarWin['mapscale']),
(0, self.statusbarWin['progress']),
+ (0, self.statusbarWin['projection']),
(1, self.statusbarWin['toggle']),
(2, self.statusbarWin['mask']),
(3, self.statusbarWin['render'])]
@@ -1868,16 +1905,17 @@
zoommenu.Destroy()
def SetProperties(self, render=False, mode=0, showCompExtent=False,
- constrainRes=False):
+ constrainRes=False, projection=False):
"""!Set properies of map display window"""
self.statusbarWin['render'].SetValue(render)
self.statusbarWin['toggle'].SetSelection(mode)
self.StatusbarUpdate()
self.statusbarWin['region'].SetValue(showCompExtent)
self.statusbarWin['resolution'].SetValue(constrainRes)
+ self.statusbarWin['projection'].SetValue(projection)
if showCompExtent:
self.MapWindow.regionCoords = []
-
+
def IsStandalone(self):
"""!Check if Map display is standalone"""
if self._layerManager:
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2009-07-05 17:23:24 UTC (rev 38259)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2009-07-05 17:31:02 UTC (rev 38260)
@@ -114,7 +114,6 @@
'color' : (255, 255, 255, 255),
},
'projection' : {
- 'enabled' : False,
'proj4' : '',
'epsg' : '',
},
@@ -1143,17 +1142,17 @@
gridSizer.AddGrowableCol(1)
row = 0
- useProj = wx.CheckBox(parent=panel, id=wx.ID_ANY,
- label=_("Use defined projection"),
- name="IsChecked")
- useProj.SetValue(self.settings.Get(group='display', key='projection', subkey='enabled'))
- self.winId['display:projection:enabled'] = useProj.GetId()
+ # useProj = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+ # label=_("Use defined projection"),
+ # name="IsChecked")
+ # useProj.SetValue(self.settings.Get(group='display', key='projection', subkey='enabled'))
+ # self.winId['display:projection:enabled'] = useProj.GetId()
+ #
+ # gridSizer.Add(item=useProj,
+ # pos=(row, 0), span=(1, 3))
- gridSizer.Add(item=useProj,
- pos=(row, 0), span=(1, 3))
-
# epsg
- row += 1
+ #row += 1
label = wx.StaticText(parent=panel, id=wx.ID_ANY,
label=_("EPSG code:"))
epsgCode = wx.ComboBox(parent=panel, id=wx.ID_ANY,
@@ -1196,10 +1195,6 @@
label=_("&Load EPSG codes"))
self.winId['display:projection:projFile'] = projFile.GetId()
- if not useProj.IsChecked():
- projString.Enable(False)
- epsgCode.Enable(False)
-
gridSizer.Add(item=label,
pos=(row, 0),
flag = wx.ALIGN_CENTER_VERTICAL)
@@ -1219,7 +1214,6 @@
epsgLoad.Bind(wx.EVT_BUTTON, self.OnLoadEpsgCodes)
epsgCode.Bind(wx.EVT_COMBOBOX, self.OnSetEpsgCode)
epsgCode.Bind(wx.EVT_TEXT_ENTER, self.OnSetEpsgCode)
- useProj.Bind(wx.EVT_CHECKBOX, self.OnSetProj)
return panel
@@ -1610,17 +1604,7 @@
list.SetSelection(0)
code = int(list.GetStringSelection())
win.SetValue(self.epsgCodeDict[code][1])
-
- def OnSetProj(self, event):
- """!Enable mapdisplay window statusbar projection"""
- checked = event.IsChecked()
-
- winCode = self.FindWindowById(self.winId['display:projection:epsg'])
- winString = self.FindWindowById(self.winId['display:projection:proj4'])
-
- winCode.Enable(checked)
- winString.Enable(checked)
-
+
def OnSetEpsgCode(self, event):
"""!EPSG code selected"""
winCode = self.FindWindowById(event.GetId())
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py 2009-07-05 17:23:24 UTC (rev 38259)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py 2009-07-05 17:31:02 UTC (rev 38260)
@@ -133,6 +133,15 @@
else:
extent = None
+ # projection
+ node_projection = display.find('projection')
+ if node_projection is not None:
+ projection = { 'enabled' : True,
+ 'epsg' : node_projection.get('epsg', ''),
+ 'proj' : self.__getNodeText(node_projection, 'value') }
+ else:
+ projection = { 'enabled' : False }
+
self.displays.append( {
"render" : bool(int(display.get('render', "0"))),
"mode" : int(display.get('mode', 0)),
@@ -140,7 +149,8 @@
"pos" : pos,
"size" : size,
"extent" : extent,
- "constrainRes" : bool(int(display.get('constrainRes', "0"))) } )
+ "constrainRes" : bool(int(display.get('constrainRes', "0"))),
+ "projection" : projection, } )
# process all layers/groups in the display
self.__processLayers(display)
@@ -695,6 +705,21 @@
region['e'],
region['n']
))
+ # projection statusbar info
+ if mapTree.mapdisplay.statusbarWin['projection'].IsChecked() and \
+ UserSettings.Get(group='display', key='projection', subkey='proj4'):
+ self.indent += 4
+ file.write('%s<projection' % (' ' * self.indent))
+ epsg = UserSettings.Get(group='display', key='projection', subkey='epsg')
+ if epsg:
+ file.write(' epsg="%s"' % epsg)
+ file.write('>\n')
+ proj = UserSettings.Get(group='display', key='projection', subkey='proj4')
+ self.indent += 4
+ file.write('%s<value>%s</value>\n' % (' ' * self.indent, proj))
+ self.indent -= 4
+ file.write('%s</projection>\n' % (' ' * self.indent))
+ self.indent -= 4
# list of layers
item = mapTree.GetFirstChild(mapTree.root)[0]
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2009-07-05 17:23:24 UTC (rev 38259)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2009-07-05 17:31:02 UTC (rev 38260)
@@ -638,7 +638,16 @@
mapdisplay[-1].SetProperties(render=display['render'],
mode=display['mode'],
showCompExtent=display['showCompExtent'],
- constrainRes=display['constrainRes'])
+ constrainRes=display['constrainRes'],
+ projection=display['projection']['enabled'])
+
+ if display['projection']['enabled']:
+ if display['projection']['epsg']:
+ UserSettings.Set(group = 'display', key = 'projection', subkey = 'epsg',
+ value = display['projection']['epsg'])
+ if display['projection']['proj']:
+ UserSettings.Set(group = 'display', key = 'projection', subkey = 'proj4',
+ value = display['projection']['proj'])
# set position and size of map display
if UserSettings.Get(group='workspace', key='posDisplay', subkey='enabled') is False:
Modified: grass/branches/develbranch_6/gui/wxpython/xml/grass-gxw.dtd
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/grass-gxw.dtd 2009-07-05 17:23:24 UTC (rev 38259)
+++ grass/branches/develbranch_6/gui/wxpython/xml/grass-gxw.dtd 2009-07-05 17:31:02 UTC (rev 38260)
@@ -30,7 +30,7 @@
render, mode and showCompExtent (added 2004/08)
-->
-<!ELEMENT display ((group|layer)*)>
+<!ELEMENT display (projection?, (group|layer)*)>
<!ATTLIST display render (0 | 1) #IMPLIED>
<!ATTLIST display mode (0 | 1 | 2 | 3 | 4 | 5 | 6) #IMPLIED>
<!ATTLIST display showCompExtent (0 | 1) #IMPLIED>
@@ -39,6 +39,11 @@
<!ATTLIST display dim CDATA #IMPLIED>
<!ATTLIST display extent CDATA #IMPLIED>
+<!-- projection (statusbar coordinates)
+-->
+<!ELEMENT projection (value?)>
+<!ATTLIST projection epsg CDATA #IMPLIED>
+
<!-- group of map layers
-->
<!ELEMENT group (layer*)>
More information about the grass-commit
mailing list