[GRASS-SVN] r48703 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 10 08:46:42 EDT 2011
Author: annakrat
Date: 2011-10-10 05:46:41 -0700 (Mon, 10 Oct 2011)
New Revision: 48703
Added:
grass/trunk/gui/wxpython/gui_modules/mapdisp_statusbar.py
Modified:
grass/trunk/gui/wxpython/gui_modules/__init__.py
grass/trunk/gui/wxpython/gui_modules/globalvar.py
grass/trunk/gui/wxpython/gui_modules/layertree.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/render.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/gui_modules/vdigit.py
grass/trunk/gui/wxpython/gui_modules/workspace.py
Log:
wxGUI: first steps in creating base class for mapdisp.MapFrame -- reorganization of statusbar
Modified: grass/trunk/gui/wxpython/gui_modules/__init__.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/__init__.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/__init__.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -19,6 +19,7 @@
"location_wizard.py",
"mapdisp_window.py",
"mapdisp.py",
+ "mapdisp_statusbar.py",
"mcalc_builder.py",
"menu.py",
"menudata.py",
Modified: grass/trunk/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/globalvar.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/globalvar.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -105,16 +105,6 @@
HIST_WINDOW_SIZE = (500, 350)
GM_WINDOW_SIZE = (500, 600)
-MAP_DISPLAY_STATUSBAR_MODE = [_("Coordinates"),
- _("Extent"),
- _("Comp. region"),
- _("Show comp. extent"),
- _("Display mode"),
- _("Display resolution"),
- _("Display geometry"),
- _("Map scale"),
- _("Go to"),
- _("Projection"),]
"""!File name extension binaries/scripts"""
if sys.platform == 'win32':
Modified: grass/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -232,7 +232,7 @@
vector = True
else:
vector = False
- if self.mapdisplay.statusbarWin['render'].GetValue():
+ if self.mapdisplay.IsAutoRendered():
self.mapdisplay.MapWindow.UpdateMap(render = True, renderVector = vector)
if self.lmgr.IsPaneShown('toolbarNviz'): # nviz
self.mapdisplay.MapWindow3D.UpdateMap(render = True)
@@ -933,7 +933,7 @@
# updated progress bar range (mapwindow statusbar)
if checked:
- self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active = True)))
+ self.mapdisplay.GetProgressBar().SetRange(len(self.Map.GetListOfLayers(l_active = True)))
return layer
@@ -1088,7 +1088,7 @@
self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers (updateTool = True)
# update progress bar range (mapwindow statusbar)
- self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active = True)))
+ self.mapdisplay.GetProgressBar().SetRange(len(self.Map.GetListOfLayers(l_active = True)))
#
# nviz
@@ -1138,7 +1138,7 @@
#
# update progress bar range (mapwindow statusbar)
#
- self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active = True)))
+ self.mapdisplay.GetProgressBar().SetRange(len(self.Map.GetListOfLayers(l_active = True)))
#
# nviz
@@ -1249,7 +1249,7 @@
UserSettings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'):
mapLayer = self.GetPyData(layer)[0]['maplayer']
if mapLayer.GetType() in ('raster', 'vector'):
- render = self.mapdisplay.statusbarWin['render'].IsChecked()
+ render = self.mapdisplay.IsAutoRendered()
self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
render = render)
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -7,8 +7,9 @@
Can be used either from Layer Manager or as d.mon backend.
Classes:
-- MapFrame
-- MapApp
+ - MapFrameBase
+ - MapFrame
+ - MapApp
Usage:
python mapdisp.py monitor-identifier /path/to/map/file /path/to/command/file /path/to/env/file
@@ -21,6 +22,8 @@
@author Michael Barton
@author Jachym Cepicky
@author Martin Landa <landa.martin gmail.com>
+ at author Vaclav Petras <wenzeslaus gmail.com> (MapFrameBase)
+ at author Anna Kratochvilova <kratochanna gmail.com> (MapFrameBase)
"""
import os
@@ -48,6 +51,7 @@
import globalvar
import utils
import gdialogs
+import mapdisp_statusbar as sb
from debug import Debug
from icon import Icons
from preferences import globalSettings as UserSettings
@@ -68,16 +72,19 @@
haveCtypes = False
-class MapFrame(wx.Frame):
- """!Main frame for map display window. Drawing takes place in
- child double buffered drawing window.
+class MapFrameBase(wx.Frame):
+ """!Base class for map display window
+
+ Derived class must use statusbarManager or override
+ GetProperty, SetProperty and HasProperty methods.
+ If derived class enables and disables auto-rendering,
+ it should override IsAutoRendered method.
"""
- def __init__(self, parent = None, id = wx.ID_ANY, title = _("GRASS GIS - Map display"),
- style = wx.DEFAULT_FRAME_STYLE, toolbars = ["map"],
+ def __init__(self, parent = None, id = wx.ID_ANY, title = None,
+ style = wx.DEFAULT_FRAME_STYLE, toolbars = None,
tree = None, notebook = None, lmgr = None, page = None,
- Map = None, auimgr = None, **kwargs):
- """!Main map display window with toolbars, statusbar and
- BufferedWindow (map canvas)
+ Map = None, auimgr = None, name = None, **kwargs):
+ """!
@param toolbars array of activated toolbars, e.g. ['map', 'digit']
@param tree reference to layer tree
@@ -86,8 +93,10 @@
@param page notebook page with layer tree
@param Map instance of render.Map
@param auimgs AUI manager
- @param kwargs wx.Frame attribures
+ @param name frame name
+ @param kwargs wx.Frame attributes
"""
+
self._layerManager = lmgr # Layer Manager object
self.Map = Map # instance of render.Map
self.tree = tree # Layer Manager layer tree object
@@ -95,9 +104,7 @@
self.layerbook = notebook # Layer Manager layer tree notebook
self.parent = parent
- if 'name' not in kwargs:
- kwargs['name'] = 'MapWindow'
- wx.Frame.__init__(self, parent, id, title, style = style, **kwargs)
+ wx.Frame.__init__(self, parent, id, title, style = style, name = name, **kwargs)
# available cursors
self.cursors = {
@@ -109,7 +116,7 @@
"pencil" : wx.StockCursor(wx.CURSOR_PENCIL),
"sizenwse": wx.StockCursor(wx.CURSOR_SIZENWSE)
}
-
+
#
# set the size & system icon
#
@@ -117,124 +124,176 @@
self.iconsize = (16, 16)
self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_map.ico'), wx.BITMAP_TYPE_ICO))
-
+
#
# Fancy gui
#
self._mgr = wx.aui.AuiManager(self)
+
+ def IsAutoRendered(self):
+ """!Checks if auto-rendering is enabled"""
+ return True
+
+ def SetProperty(self, name, value):
+ """!Sets property"""
+ self.statusbarManager.SetProperty(name, value)
+
+ def GetProperty(self, name):
+ """!Returns property"""
+ return self.statusbarManager.GetProperty(name)
+
+ def HasProperty(self, name):
+ """!Checks whether object has property"""
+ return self.statusbarManager.HasProperty(name)
+
+ def GetPPM(self):
+ """! Get pixel per meter
+
+ @todo now computed every time, is it necessary?
+ @todo enable user to specify ppm (and store it in UserSettings)
+ """
+ # TODO: need to be fixed...
+ ### screen X region problem
+ ### user should specify ppm
+ dc = wx.ScreenDC()
+ dpSizePx = wx.DisplaySize() # display size in pixels
+ dpSizeMM = wx.DisplaySizeMM() # display size in mm (system)
+ dpSizeIn = (dpSizeMM[0] / 25.4, dpSizeMM[1] / 25.4) # inches
+ sysPpi = dc.GetPPI()
+ comPpi = (dpSizePx[0] / dpSizeIn[0],
+ dpSizePx[1] / dpSizeIn[1])
+ ppi = comPpi # pixel per inch
+ ppm = ((ppi[0] / 2.54) * 100, # pixel per meter
+ (ppi[1] / 2.54) * 100)
+
+ Debug.msg(4, "MapFrameBase.GetPPM(): size: px=%d,%d mm=%f,%f "
+ "in=%f,%f ppi: sys=%d,%d com=%d,%d; ppm=%f,%f" % \
+ (dpSizePx[0], dpSizePx[1], dpSizeMM[0], dpSizeMM[1],
+ dpSizeIn[0], dpSizeIn[1],
+ sysPpi[0], sysPpi[1], comPpi[0], comPpi[1],
+ ppm[0], ppm[1]))
+
+ return ppm
+
+ def SetMapScale(self, value, map = None):
+ """! Set current map scale
+
+ @param value scale value (n if scale is 1:n)
+ @param map Map instance (if none self.Map is used)
+ """
+ if not map:
+ map = self.Map
+
+ region = self.Map.region
+ dEW = value * (region['cols'] / self.GetPPM()[0])
+ dNS = value * (region['rows'] / self.GetPPM()[1])
+ region['n'] = region['center_northing'] + dNS / 2.
+ region['s'] = region['center_northing'] - dNS / 2.
+ region['w'] = region['center_easting'] - dEW / 2.
+ region['e'] = region['center_easting'] + dEW / 2.
+
+ # add to zoom history
+ self.GetWindow().ZoomHistory(region['n'], region['s'],
+ region['e'], region['w'])
+
+ def GetMapScale(self, map = None):
+ """! Get current map scale
+
+ @param map Map instance (if none self.Map is used)
+ """
+ if not map:
+ map = self.Map
+
+ region = map.region
+ ppm = self.GetPPM()
+
+ heightCm = region['rows'] / ppm[1] * 100
+ widthCm = region['cols'] / ppm[0] * 100
+
+ Debug.msg(4, "MapFrame.GetMapScale(): width_cm=%f, height_cm=%f" %
+ (widthCm, heightCm))
+
+ xscale = (region['e'] - region['w']) / (region['cols'] / ppm[0])
+ yscale = (region['n'] - region['s']) / (region['rows'] / ppm[1])
+ scale = (xscale + yscale) / 2.
+
+ Debug.msg(3, "MapFrame.GetMapScale(): xscale=%f, yscale=%f -> scale=%f" % \
+ (xscale, yscale, scale))
+
+ return scale
+
+
+class MapFrame(MapFrameBase):
+ """!Main frame for map display window. Drawing takes place in
+ child double buffered drawing window.
+ """
+ def __init__(self, parent = None, title = _("GRASS GIS - Map display"),
+ toolbars = ["map"], tree = None, notebook = None, lmgr = None,
+ page = None, Map = None, auimgr = None, name = 'MapWindow', **kwargs):
+ """!Main map display window with toolbars, statusbar and
+ BufferedWindow (map canvas)
+
+ @param toolbars array of activated toolbars, e.g. ['map', 'digit']
+ @param tree reference to layer tree
+ @param notebook control book ID in Layer Manager
+ @param lmgr Layer Manager
+ @param page notebook page with layer tree
+ @param Map instance of render.Map
+ @param auimgs AUI manager
+ @param name frame name
+ @param kwargs wx.Frame attributes
+ """
+ MapFrameBase.__init__(self, parent = parent, title = title, toolbars = toolbars,
+ tree = tree, notebook = notebook, lmgr = lmgr, page = page,
+ Map = Map, auimgr = auimgr, name = name, **kwargs)
+
#
# Add toolbars
#
self.toolbars = { 'map' : None,
'vdigit' : None,
- 'georect' : None,
- 'gcpdisp' : None,
+ 'georect' : None,
+ 'gcpdisp' : None,
+ 'gcpman' : None,
'nviz' : None }
+
for toolb in toolbars:
self.AddToolbar(toolb)
-
+
#
# Add statusbar
#
- self.statusbar = self.CreateStatusBar(number = 4, style = 0)
- self.statusbar.SetStatusWidths([-5, -2, -1, -1])
- self.statusbarWin = dict()
- self.statusbarWin['toggle'] = wx.Choice(self.statusbar, wx.ID_ANY,
- choices = globalvar.MAP_DISPLAY_STATUSBAR_MODE)
- self.statusbarWin['toggle'].SetSelection(UserSettings.Get(group = 'display',
- key = 'statusbarMode',
- subkey = 'selection'))
- self.statusbar.Bind(wx.EVT_CHOICE, self.OnToggleStatus, self.statusbarWin['toggle'])
- # auto-rendering checkbox
- self.statusbarWin['render'] = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
- label = _("Render"))
- self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleRender, self.statusbarWin['render'])
- self.statusbarWin['render'].SetValue(UserSettings.Get(group = 'display',
- key = 'autoRendering',
- subkey = 'enabled'))
- self.statusbarWin['render'].SetToolTip(wx.ToolTip (_("Enable/disable auto-rendering")))
- # show region
- self.statusbarWin['region'] = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
- label = _("Show computational extent"))
- self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleShowRegion, self.statusbarWin['region'])
- self.statusbarWin['region'].SetValue(False)
- self.statusbarWin['region'].Hide()
- self.statusbarWin['region'].SetToolTip(wx.ToolTip (_("Show/hide computational "
- "region extent (set with g.region). "
- "Display region drawn as a blue box inside the "
- "computational region, "
- "computational region inside a display region "
- "as a red box).")))
- # set mode
- self.statusbarWin['alignExtent'] = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
- label = _("Align region extent based on display size"))
- self.statusbarWin['alignExtent'].SetValue(UserSettings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
- self.statusbarWin['alignExtent'].Hide()
- self.statusbarWin['alignExtent'].SetToolTip(wx.ToolTip (_("Align region extent based on display "
- "size from center point. "
- "Default value for new map displays can "
- "be set up in 'User GUI settings' dialog.")))
- # set resolution
- self.statusbarWin['resolution'] = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
- label = _("Constrain display resolution to computational settings"))
- self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleUpdateMap, self.statusbarWin['resolution'])
- self.statusbarWin['resolution'].SetValue(UserSettings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
- self.statusbarWin['resolution'].Hide()
- self.statusbarWin['resolution'].SetToolTip(wx.ToolTip (_("Constrain display resolution "
- "to computational region settings. "
- "Default value for new map displays can "
- "be set up in 'User GUI settings' dialog.")))
- # map scale
- self.statusbarWin['mapscale'] = wx.ComboBox(parent = self.statusbar, id = wx.ID_ANY,
- style = wx.TE_PROCESS_ENTER,
- size = (150, -1))
- self.statusbarWin['mapscale'].SetItems(['1:1000',
- '1:5000',
- '1:10000',
- '1:25000',
- '1:50000',
- '1:100000',
- '1:1000000'])
- self.statusbarWin['mapscale'].Hide()
- self.statusbarWin['mapscale'].SetToolTip(wx.ToolTip (_("As everyone's monitors and resolutions "
- "are set differently these values are not "
- "true map scales, but should get you into "
- "the right neighborhood.")))
- self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnChangeMapScale, self.statusbarWin['mapscale'])
- self.statusbar.Bind(wx.EVT_COMBOBOX, self.OnChangeMapScale, self.statusbarWin['mapscale'])
-
- # go to
- self.statusbarWin['goto'] = wx.TextCtrl(parent = self.statusbar, id = wx.ID_ANY,
- value = "", style = wx.TE_PROCESS_ENTER,
- size = (300, -1))
- 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 'Projection')")))
- self.statusbarWin['projection'].Hide()
+ # items for choice
+ self.statusbarItems = [sb.SbCoordinates,
+ sb.SbRegionExtent,
+ sb.SbCompRegionExtent,
+ sb.SbShowRegion,
+ sb.SbAlignExtent,
+ sb.SbResolution,
+ sb.SbDisplayGeometry,
+ sb.SbMapScale,
+ sb.SbGoTo,
+ sb.SbProjection]
+
+ self.statusbarItemsHiddenInNviz = (sb.SbAlignExtent,
+ sb.SbDisplayGeometry,
+ sb.SbShowRegion,
+ sb.SbResolution,
+ sb.SbMapScale)
- # mask
- self.statusbarWin['mask'] = wx.StaticText(parent = self.statusbar, id = wx.ID_ANY,
- label = '')
- self.statusbarWin['mask'].SetForegroundColour(wx.Colour(255, 0, 0))
+ # create statusbar and its manager
+ statusbar = self.CreateStatusBar(number = 4, style = 0)
+ statusbar.SetStatusWidths([-5, -2, -1, -1])
+ self.statusbarManager = sb.SbManager(mapframe = self, statusbar = statusbar)
- # on-render gauge
- self.statusbarWin['progress'] = wx.Gauge(parent = self.statusbar, id = wx.ID_ANY,
- range = 0, style = wx.GA_HORIZONTAL)
- self.statusbarWin['progress'].Hide()
+ # fill statusbar manager
+ self.statusbarManager.AddStatusbarItemsByClass(self.statusbarItems, mapframe = self, statusbar = statusbar)
+ self.statusbarManager.AddStatusbarItem(sb.SbMask(self, statusbar = statusbar, position = 2))
+ self.statusbarManager.AddStatusbarItem(sb.SbRender(self, statusbar = statusbar, position = 3))
- self.StatusbarReposition() # reposition statusbar
+ self.statusbarManager.Update()
#
# Init map display (buffered DC & set default cursor)
@@ -293,7 +352,8 @@
self.dialogs['legend'] = None
self.decorationDialog = None # decoration/overlays
-
+
+
def _addToolbarVDigit(self):
"""!Add vector digitizer toolbar
"""
@@ -386,17 +446,16 @@
self.OnRotate, wx.ITEM_CHECK,7),)) # 7 is position
self.toolbars['map'].ChangeToolsDesc(mode2d = False)
# update status bar
- choice = globalvar.MAP_DISPLAY_STATUSBAR_MODE
- self.statusbarWin['toggle'].SetItems((choice[0], choice[1], choice[2],
- choice[8], choice[9]))
- self.statusbarWin['toggle'].SetSelection(0)
+ self.statusbarManager.HideStatusbarChoiceItemsByClass(self.statusbarItemsHiddenInNviz)
+ self.statusbarManager.SetMode(0)
+
# erase map window
self.MapWindow.EraseMap()
self._layerManager.goutput.WriteCmdLog(_("Starting 3D view mode..."),
switchPage = False)
- self.statusbar.SetStatusText(_("Please wait, loading data..."), 0)
+ self.SetStatusText(_("Please wait, loading data..."), 0)
# create GL window
if not self.MapWindow3D:
@@ -442,11 +501,11 @@
"""!Restore 2D view"""
self.toolbars['map'].RemoveTool(self.toolbars['map'].rotate)
# update status bar
- self.statusbarWin['toggle'].SetItems(globalvar.MAP_DISPLAY_STATUSBAR_MODE)
- self.statusbarWin['toggle'].SetSelection(UserSettings.Get(group = 'display',
- key = 'statusbarMode',
- subkey = 'selection'))
- self.statusbar.SetStatusText(_("Please wait, unloading data..."), 0)
+ self.statusbarManager.ShowStatusbarChoiceItemsByClass(self.statusbarItemsHiddenInNviz)
+ self.statusbarManager.SetMode(UserSettings.Get(group = 'display',
+ key = 'statusbarMode',
+ subkey = 'selection'))
+ self.SetStatusText(_("Please wait, unloading data..."), 0)
self._layerManager.goutput.WriteCmdLog(_("Switching back to 2D view mode..."),
switchPage = False)
self.MapWindow3D.UnloadDataLayers(force = True)
@@ -549,7 +608,7 @@
def OnUpdateProgress(self, event):
"""!Update progress bar info
"""
- self.statusbarWin['progress'].SetValue(event.value)
+ self.GetProgressBar().SetValue(event.value)
event.Skip()
@@ -721,390 +780,21 @@
self.Map.alignRegion = False
# event.Skip()
- def OnToggleRender(self, event):
- """!Enable/disable auto-rendering
- """
- if self.statusbarWin['render'].GetValue():
- self.OnRender(None)
-
def IsAutoRendered(self):
"""!Check if auto-rendering is enabled"""
- return self.statusbarWin['render'].IsChecked()
-
- def OnToggleShowRegion(self, event):
- """!Show/Hide extent in map canvas
- """
- if self.statusbarWin['region'].GetValue():
- # show extent
- self.MapWindow.regionCoords = []
- else:
- del self.MapWindow.regionCoords
-
- # redraw map if auto-rendering is enabled
- if self.statusbarWin['render'].GetValue():
- self.OnRender(None)
-
- def OnToggleUpdateMap(self, event):
- """!Update display when toggle display mode
- """
- # redraw map if auto-rendering is enabled
- if self.statusbarWin['render'].GetValue():
- self.OnRender(None)
+ return self.GetProperty('render')
+
+ def CoordinatesChanged(self):
+ """!Shows current coordinates on statusbar.
- def OnToggleStatus(self, event):
- """!Toggle status text
+ Used in BufferedWindow to report change of map coordinates (under mouse cursor).
"""
- self.StatusbarUpdate()
-
- def OnChangeMapScale(self, event):
- """!Map scale changed by user
- """
- scale = event.GetString()
-
- try:
- if scale[:2] != '1:':
- raise ValueError
- value = int(scale[2:])
- except ValueError:
- self.statusbarWin['mapscale'].SetValue('1:%ld' % int(self.mapScaleValue))
- return
-
- dEW = value * (self.Map.region['cols'] / self.ppm[0])
- dNS = value * (self.Map.region['rows'] / self.ppm[1])
- self.Map.region['n'] = self.Map.region['center_northing'] + dNS / 2.
- self.Map.region['s'] = self.Map.region['center_northing'] - dNS / 2.
- self.Map.region['w'] = self.Map.region['center_easting'] - dEW / 2.
- self.Map.region['e'] = self.Map.region['center_easting'] + dEW / 2.
+ self.statusbarManager.ShowItem('coordinates')
- # add to zoom history
- self.MapWindow.ZoomHistory(self.Map.region['n'], self.Map.region['s'],
- self.Map.region['e'], self.Map.region['w'])
-
- # redraw a map
- self.MapWindow.UpdateMap()
- self.statusbarWin['mapscale'].SetFocus()
-
- def OnGoTo(self, event):
- """
- Go to position
- """
- try:
- if self.statusbarWin['projection'].IsChecked():
- if not UserSettings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4'):
- self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
- else:
- # reproject values
- projIn = UserSettings.Get(group = 'projection',
- key = 'statusbar',
- 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(';')
- else:
- e, n = map(float, self.statusbarWin['goto'].GetValue().split(';'))
-
- region = self.Map.GetCurrentRegion()
- if self.statusbarWin['projection'].IsChecked():
- if not UserSettings.Get(group = 'projection', key = 'statusbar', 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)
- else:
- region['center_easting'], region['center_northing'] = e, n
- except ValueError:
- region = self.Map.GetCurrentRegion()
- precision = int(UserSettings.Get(group = 'projection', key = 'format',
- subkey = 'precision'))
- format = UserSettings.Get(group = 'projection', key = 'format',
- subkey = 'll')
- if self.Map.projinfo['proj'] == 'll' and format == 'DMS':
- self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(region['center_easting'],
- region['center_northing'],
- precision = precision))
- else:
- self.statusbarWin['goto'].SetValue("%.*f; %.*f" % \
- (precision, region['center_easting'],
- precision, region['center_northing']))
- return
-
- if self.IsPaneShown('3d'):
- self.MapWindow.GoTo(e, n)
- return
-
- dn = (region['nsres'] * region['rows']) / 2.
- region['n'] = region['center_northing'] + dn
- region['s'] = region['center_northing'] - dn
- de = (region['ewres'] * region['cols']) / 2.
- region['e'] = region['center_easting'] + de
- region['w'] = region['center_easting'] - de
-
- self.Map.AdjustRegion()
-
- # add to zoom history
- self.MapWindow.ZoomHistory(region['n'], region['s'],
- region['e'], region['w'])
-
- # redraw a map
- self.MapWindow.UpdateMap()
- self.statusbarWin['goto'].SetFocus()
-
def StatusbarUpdate(self):
"""!Update statusbar content"""
+ self.statusbarManager.Update()
- self.statusbarWin['region'].Hide()
- self.statusbarWin['alignExtent'].Hide()
- self.statusbarWin['resolution'].Hide()
- self.statusbarWin['mapscale'].Hide()
- self.statusbarWin['goto'].Hide()
- self.statusbarWin['projection'].Hide()
- self.mapScaleValue = self.ppm = None
- choice = globalvar.MAP_DISPLAY_STATUSBAR_MODE
-
- if self.statusbarWin['toggle'].GetStringSelection() == choice[0]: # Coordinates
- self.statusbar.SetStatusText("", 0)
- # enable long help
- self.StatusbarEnableLongHelp()
-
- elif self.statusbarWin['toggle'].GetStringSelection() in (choice[1], choice[2]): # Extent
- sel = self.statusbarWin['toggle'].GetStringSelection()
- if sel == choice[1]:
- region = self.Map.region
- else:
- region = self.Map.GetRegion() # computation region
-
- precision = int(UserSettings.Get(group = 'projection', key = 'format',
- subkey = 'precision'))
- format = UserSettings.Get(group = 'projection', key = 'format',
- subkey = 'll')
-
- if self.statusbarWin['projection'].IsChecked():
- if not UserSettings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4'):
- self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
- else:
- projOut = UserSettings.Get(group = 'projection',
- key = 'statusbar',
- 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')
- 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') and format == 'DMS':
- w, s = utils.Deg2DMS(coord1[0], coord1[1], string = False,
- precision = precision)
- e, n = utils.Deg2DMS(coord2[0], coord2[1], string = False,
- precision = precision)
- if sel == choice[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,
- precision = precision)
- 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 == choice[1]:
- self.statusbar.SetStatusText("%.*f - %.*f, %.*f - %.*f" %
- (precision, w, precision, e,
- precision, s, precision, n), 0)
- else:
- ewres, nsres = coord3
- self.statusbar.SetStatusText("%.*f - %.*f, %.*f - %.*f (%.*f, %.*f)" %
- (precision, w, precision, e,
- precision, s, precision, n,
- precision, ewres, precision, nsres), 0)
- else:
- self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
- else:
- if self.Map.projinfo['proj'] == 'll' and format == 'DMS':
- w, s = utils.Deg2DMS(region["w"], region["s"],
- string = False, precision = precision)
- e, n = utils.Deg2DMS(region["e"], region["n"],
- string = False, precision = precision)
- if sel == choice[1]:
- self.statusbar.SetStatusText("%s - %s, %s - %s" %
- (w, e, s, n), 0)
- else:
- ewres, nsres = utils.Deg2DMS(region['ewres'], region['nsres'],
- string = False, precision = precision)
- self.statusbar.SetStatusText("%s - %s, %s - %s (%s, %s)" %
- (w, e, s, n, ewres, nsres), 0)
- else:
- w, s = region["w"], region["s"]
- e, n = region["e"], region["n"]
- if sel == choice[1]:
- self.statusbar.SetStatusText("%.*f - %.*f, %.*f - %.*f" %
- (precision, w, precision, e,
- precision, s, precision, n), 0)
- else:
- ewres, nsres = region['ewres'], region['nsres']
- self.statusbar.SetStatusText("%.*f - %.*f, %.*f - %.*f (%.*f, %.*f)" %
- (precision, w, precision, e,
- precision, s, precision, n,
- precision, ewres, precision, nsres), 0)
- # enable long help
- self.StatusbarEnableLongHelp()
-
- elif self.statusbarWin['toggle'].GetStringSelection() == choice[3]: # Show comp. extent
- self.statusbar.SetStatusText("", 0)
- self.statusbarWin['region'].Show()
- # disable long help
- self.StatusbarEnableLongHelp(False)
-
- elif self.statusbarWin['toggle'].GetStringSelection() == choice[4]: # Align extent
- self.statusbar.SetStatusText("", 0)
- self.statusbarWin['alignExtent'].Show()
- # disable long help
- self.StatusbarEnableLongHelp(False)
-
- elif self.statusbarWin['toggle'].GetStringSelection() == choice[5]: # Display resolution
- self.statusbar.SetStatusText("", 0)
- self.statusbarWin['resolution'].Show()
- # disable long help
- self.StatusbarEnableLongHelp(False)
-
- elif self.statusbarWin['toggle'].GetStringSelection() == choice[6]: # Display geometry
- self.statusbar.SetStatusText("rows=%d; cols=%d; nsres=%.2f; ewres=%.2f" %
- (self.Map.region["rows"], self.Map.region["cols"],
- self.Map.region["nsres"], self.Map.region["ewres"]), 0)
- # enable long help
- self.StatusbarEnableLongHelp()
-
- elif self.statusbarWin['toggle'].GetStringSelection() == choice[7]: # Map scale
- # TODO: need to be fixed...
- ### screen X region problem
- ### user should specify ppm
- dc = wx.ScreenDC()
- dpSizePx = wx.DisplaySize() # display size in pixels
- dpSizeMM = wx.DisplaySizeMM() # display size in mm (system)
- dpSizeIn = (dpSizeMM[0] / 25.4, dpSizeMM[1] / 25.4) # inches
- sysPpi = dc.GetPPI()
- comPpi = (dpSizePx[0] / dpSizeIn[0],
- dpSizePx[1] / dpSizeIn[1])
-
- ppi = comPpi # pixel per inch
- self.ppm = ((ppi[0] / 2.54) * 100, # pixel per meter
- (ppi[1] / 2.54) * 100)
-
- Debug.msg(4, "MapFrame.StatusbarUpdate(mapscale): size: px=%d,%d mm=%f,%f "
- "in=%f,%f ppi: sys=%d,%d com=%d,%d; ppm=%f,%f" % \
- (dpSizePx[0], dpSizePx[1], dpSizeMM[0], dpSizeMM[1],
- dpSizeIn[0], dpSizeIn[1],
- sysPpi[0], sysPpi[1], comPpi[0], comPpi[1],
- self.ppm[0], self.ppm[1]))
-
- region = self.Map.region
-
- heightCm = region['rows'] / self.ppm[1] * 100
- widthCm = region['cols'] / self.ppm[0] * 100
-
- Debug.msg(4, "MapFrame.StatusbarUpdate(mapscale): width_cm=%f, height_cm=%f" %
- (widthCm, heightCm))
-
- xscale = (region['e'] - region['w']) / (region['cols'] / self.ppm[0])
- yscale = (region['n'] - region['s']) / (region['rows'] / self.ppm[1])
- scale = (xscale + yscale) / 2.
-
- Debug.msg(3, "MapFrame.StatusbarUpdate(mapscale): xscale=%f, yscale=%f -> scale=%f" % \
- (xscale, yscale, scale))
-
- self.statusbar.SetStatusText("")
- try:
- self.statusbarWin['mapscale'].SetValue("1:%ld" % (scale + 0.5))
- except TypeError:
- pass
- self.mapScaleValue = scale
- self.statusbarWin['mapscale'].Show()
-
- # disable long help
- self.StatusbarEnableLongHelp(False)
-
- elif self.statusbarWin['toggle'].GetStringSelection() == choice[8]: # go to
- self.statusbar.SetStatusText("")
- region = self.Map.GetCurrentRegion()
- precision = int(UserSettings.Get(group = 'projection', key = 'format',
- subkey = 'precision'))
- format = UserSettings.Get(group = 'projection', key = 'format',
- subkey = 'll')
-
- if self.statusbarWin['projection'].IsChecked():
- if not UserSettings.Get(group='projection', key='statusbar', 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 = 'projection',
- key = 'statusbar',
- subkey = 'proj4'),
- flags = 'd')
- if coord:
- if proj in ('ll', 'latlong', 'longlat') and format == 'DMS':
- self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(coord[0],
- coord[1],
- precision = precision))
- else:
- self.statusbarWin['goto'].SetValue("%.*f; %.*f" % (precision, coord[0],
- precision, coord[1]))
- else:
- self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
- else:
- if self.Map.projinfo['proj'] == 'll' and format == 'DMS':
- self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(region['center_easting'],
- region['center_northing'],
- precision = precision))
- else:
- self.statusbarWin['goto'].SetValue("%.*f; %.*f" % (precision, region['center_easting'],
- precision, region['center_northing']))
- self.statusbarWin['goto'].Show()
-
- # disable long help
- self.StatusbarEnableLongHelp(False)
-
- elif self.statusbarWin['toggle'].GetStringSelection() == choice[9]: # projection
- self.statusbar.SetStatusText("")
- epsg = UserSettings.Get(group = 'projection', key = 'statusbar', 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)
-
def StatusbarEnableLongHelp(self, enable = True):
"""!Enable/disable toolbars long help"""
for toolbar in self.toolbars.itervalues():
@@ -1112,42 +802,9 @@
toolbar.EnableLongHelp(enable)
def StatusbarReposition(self):
- """!Reposition checkbox in statusbar"""
- # reposition checkbox
- widgets = [(0, self.statusbarWin['region']),
- (0, self.statusbarWin['alignExtent']),
- (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'])]
- for idx, win in widgets:
- rect = self.statusbar.GetFieldRect(idx)
- if idx == 0: # show region / mapscale / process bar
- # -> size
- wWin, hWin = win.GetBestSize()
- if win == self.statusbarWin['progress']:
- wWin = rect.width - 6
- # -> position
- # if win == self.statusbarWin['region']:
- # x, y = rect.x + rect.width - wWin, rect.y - 1
- # align left
- # else:
- x, y = rect.x + 3, rect.y - 1
- w, h = wWin, rect.height + 2
- else: # choice || auto-rendering
- x, y = rect.x, rect.y - 1
- w, h = rect.width, rect.height + 2
- if idx == 2: # mask
- x += 5
- y += 4
- elif idx == 3: # render
- x += 5
- win.SetPosition((x, y))
- win.SetSize((w, h))
-
+ """!Reposition items in statusbar"""
+ self.statusbarManager.Reposition()
+
def SaveToFile(self, event):
"""!Save map to image
"""
@@ -1244,13 +901,27 @@
def GetRender(self):
"""!Returns current instance of render.Map()
+
+ @todo make this method obsolate (name GetMap is better)
"""
return self.Map
+ def GetMap(self):
+ """!Returns current Map instance
+ """
+ return self.Map
+
def GetWindow(self):
"""!Get map window"""
return self.MapWindow
+
+ def GetProgressBar(self):
+ """!Returns progress bar
+ Progress bar can be used by other classes.
+ """
+ return self.statusbarManager.GetProgressBar()
+
def QueryMap(self, x, y):
"""!Query raster or vector map layers by r/v.what
@@ -1991,19 +1662,17 @@
# will be called before PopupMenu returns.
self.PopupMenu(zoommenu)
zoommenu.Destroy()
-
+
def SetProperties(self, render = False, mode = 0, showCompExtent = False,
constrainRes = False, projection = False, alignExtent = True):
"""!Set properies of map display window"""
- self.statusbarWin['render'].SetValue(render)
- self.statusbarWin['toggle'].SetSelection(mode)
+ self.SetProperty('render', render)
+ self.statusbarManager.SetMode(mode)
self.StatusbarUpdate()
- self.statusbarWin['region'].SetValue(showCompExtent)
- self.statusbarWin['alignExtent'].SetValue(alignExtent)
- self.statusbarWin['resolution'].SetValue(constrainRes)
- self.statusbarWin['projection'].SetValue(projection)
- if showCompExtent:
- self.MapWindow.regionCoords = []
+ self.SetProperty('region', showCompExtent)
+ self.SetProperty('alignExtent', alignExtent)
+ self.SetProperty('resolution', constrainRes)
+ self.SetProperty('projection', projection)
def IsStandalone(self):
"""!Check if Map display is standalone"""
Added: grass/trunk/gui/wxpython/gui_modules/mapdisp_statusbar.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_statusbar.py (rev 0)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_statusbar.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -0,0 +1,960 @@
+"""!
+ at package mapdisp_statusbar.py
+
+ at brief Classes for statusbar management
+
+Classes:
+ - SbException
+ - SbManager
+ - SbItem
+ - SbRender
+ - SbShowRegion
+ - SbAlignExtent
+ - SbResolution
+ - SbMapScale
+ - SbGoTo
+ - SbProjection
+ - SbMask
+ - SbTextItem
+ - SbDisplayGeometry
+ - SbCoordinates
+ - SbRegionExtent
+ - SbCompRegionExtent
+ - SbProgress
+
+
+(C) 2006-2011 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author Vaclav Petras <wenzeslaus gmail.com>
+ at author Anna Kratochvilova <kratochanna gmail.com>
+"""
+
+import wx
+
+import utils
+import gcmd
+from grass.script import core as grass
+from preferences import globalSettings as UserSettings
+
+class SbException:
+ """! Exception class used in SbManager and SbItems"""
+ def __init__(self, message):
+ self.message = message
+ def __str__(self):
+ return self.message
+
+
+class SbManager:
+ """!Statusbar manager for wx.Statusbar and SbItems.
+
+ Statusbar manager manages items added by AddStatusbarItem method.
+ Provides progress bar (SbProgress) and choice (wx.Choice).
+ Items with position 0 are shown according to choice selection.
+ Only one item of the same class is supposed to be in statusbar.
+ Manager user have to create statusbar on his own, add items to manager
+ and call Update method to show particular widgets.
+ User settings (group = 'display', key = 'statusbarMode', subkey = 'selection')
+ are taken into account.
+ """
+ def __init__(self, mapframe, statusbar):
+ """!Connects manager to statusbar
+
+ Creates choice and progress bar.
+ """
+ self.mapFrame = mapframe
+ self.statusbar = statusbar
+
+ self.choice = wx.Choice(self.statusbar, wx.ID_ANY)
+
+ self.statusbar.Bind(wx.EVT_CHOICE, self.OnToggleStatus)
+
+ self.statusbarItems = dict()
+
+ self._postInitialized = False
+
+ self.progressbar = SbProgress(self.mapFrame, self.statusbar)
+
+ self._hiddenItems = {}
+
+ def SetProperty(self, name, value):
+ """!Sets property represented by one of contained SbItems
+
+ @param name name of SbItem (from name attribute)
+ @param value value to be set
+ """
+ self.statusbarItems[name].SetValue(value)
+
+ def GetProperty(self, name):
+ """!Returns property represented by one of contained SbItems
+
+ @param name name of SbItem (from name attribute)
+ """
+ return self.statusbarItems[name].GetValue()
+
+ def HasProperty(self, name):
+ """!Checks whether property is represented by one of contained SbItems
+
+ @param name name of SbItem (from name attribute)
+
+ @returns True if particular SbItem is contained, False otherwise
+ """
+ if name in self.statusbarItems:
+ return True
+ return False
+
+ def AddStatusbarItem(self, item):
+ """!Adds item to statusbar
+
+ If item position is 0, item is managed by choice.
+
+ @see AddStatusbarItemsByClass
+ """
+ self.statusbarItems[item.name] = item
+ if item.GetPosition() == 0:
+ self.choice.Append(item.label, clientData = item) #attrError?
+
+ def AddStatusbarItemsByClass(self, itemClasses, **kwargs):
+ """!Adds items to statusbar
+
+ @param itemClasses list of classes of items to be add
+ @param kwargs SbItem constructor parameters
+
+ @see AddStatusbarItem
+ """
+ for Item in itemClasses:
+ item = Item(**kwargs)
+ self.AddStatusbarItem(item)
+
+ def HideStatusbarChoiceItemsByClass(self, itemClasses):
+ """!Hides items showed in choice
+
+ Hides items with position 0 (items showed in choice) by removing
+ them from choice.
+
+ @param itemClasses list of classes of items to be hided
+
+ @see ShowStatusbarChoiceItemsByClass
+ @todo consider adding similar function which would take item names
+ """
+ for itemClass in itemClasses:
+ for i in range(0, self.choice.GetCount() - 1):
+ item = self.choice.GetClientData(i)
+ if item.__class__ == itemClass:
+ self.choice.Delete(i)
+ self._hiddenItems[item] = i
+
+ def ShowStatusbarChoiceItemsByClass(self, itemClasses):
+ """!Shows items showed in choice
+
+ Shows items with position 0 (items showed in choice) by adding
+ them to choice.
+ Items are restored in their old positions.
+
+ @param itemClasses list of classes of items to be showed
+
+ @see HideStatusbarChoiceItemsByClass
+ """
+ for itemClass in itemClasses:
+ for item in self.statusbarItems.values():
+ if item.__class__ == itemClass:
+ if self.choice.FindString(item.label) != wx.NOT_FOUND:
+ return # item already in choice
+ pos = self._hiddenItems[item]
+ self.choice.Insert(item.label, pos, item)
+
+ def ShowItem(self, itemName):
+ """!Invokes showing of particular item
+
+ @see Update
+ """
+ self.statusbarItems[itemName].Show()
+
+ def _postInit(self):
+ """!Post-initialization method
+
+ It sets internal user settings,
+ set choice's selection (from user settings) and does reposition.
+ It needs choice filled by items.
+ it is called automatically.
+ """
+ UserSettings.Set(group = 'display',
+ key = 'statusbarMode',
+ subkey = 'choices',
+ value = self.choice.GetItems(),
+ internal = True)
+
+ self.choice.SetSelection(UserSettings.Get(group = 'display',
+ key = 'statusbarMode',
+ subkey = 'selection'))
+ self.Reposition()
+
+ self._postInitialized = True
+
+ def Update(self):
+ """!Updates statusbar
+
+ It always updates mask.
+ """
+ if not self._postInitialized:
+ self._postInit()
+
+ for item in self.statusbarItems.values():
+ if item.GetPosition() == 0:
+ item.Hide()
+ else:
+ item.Update() # mask, render
+
+ if self.choice.GetCount() > 0:
+ item = self.choice.GetClientData(self.choice.GetSelection())
+ item.Update()
+
+ def Reposition(self):
+ """!Reposition items in statusbar
+
+ Set positions to all items managed by statusbar manager.
+ It should not be necessary to call it manually.
+ """
+
+ widgets = []
+ for item in self.statusbarItems.values():
+ widgets.append((item.GetPosition(), item.GetWidget()))
+
+ widgets.append((1, self.choice))
+ widgets.append((0, self.progressbar.GetWidget()))
+
+ for idx, win in widgets:
+ if not win:
+ continue
+ rect = self.statusbar.GetFieldRect(idx)
+ if idx == 0: # show region / mapscale / process bar
+ # -> size
+ wWin, hWin = win.GetBestSize()
+ if win == self.progressbar.GetWidget():
+ wWin = rect.width - 6
+ # -> position
+ # if win == self.statusbarWin['region']:
+ # x, y = rect.x + rect.width - wWin, rect.y - 1
+ # align left
+ # else:
+ x, y = rect.x + 3, rect.y - 1
+ w, h = wWin, rect.height + 2
+ else: # choice || auto-rendering
+ x, y = rect.x, rect.y - 1
+ w, h = rect.width, rect.height + 2
+ if idx == 2: # mask
+ x += 5
+ y += 4
+ elif idx == 3: # render
+ x += 5
+ win.SetPosition((x, y))
+ win.SetSize((w, h))
+
+ def GetProgressBar(self):
+ """!Returns progress bar"""
+ return self.progressbar
+
+ def OnToggleStatus(self, event):
+ """!Toggle status text
+ """
+ self.Update()
+
+ def SetMode(self, modeIndex):
+ """!Sets current mode
+
+ Mode is usually driven by user through choice.
+ """
+ self.choice.SetSelection(modeIndex)
+
+ def GetMode(self):
+ """!Returns current mode"""
+ return self.choice.GetSelection()
+
+class SbItem:
+ """!Base class for statusbar items.
+
+ Each item represents functionality (or action) controlled by statusbar
+ and related to MapFrame.
+ One item is usually connected with one widget but it is not necessary.
+ Item can represent property (depends on manager).
+ Items are not widgets but can provide interface to them.
+ Items usually has requirements to MapFrame instance
+ (specified as MapFrame.methodname or MapWindow.methodname).
+
+ @todo consider externalizing position (see SbProgress use in SbManager)
+ """
+ def __init__(self, mapframe, statusbar, position = 0):
+ """!
+
+ @param mapframe instance of class with MapFrame interface
+ @param statusbar statusbar instance (wx.Statusbar)
+ @param position item position in statusbar
+
+ @todo rewrite Update also in derived classes to take in account item position
+ """
+ self.mapFrame = mapframe
+ self.statusbar = statusbar
+ self.position = position
+
+ def Show(self):
+ """!Invokes showing of underlying widget.
+
+ In derived classes it can do what is appropriate for it,
+ e.g. showing text on statusbar (only).
+ """
+ self.widget.Show()
+
+ def Hide(self):
+ self.widget.Hide()
+
+ def SetValue(self, value):
+ self.widget.SetValue(value)
+
+ def GetValue(self):
+ return self.widget.GetValue()
+
+ def GetPosition(self):
+ return self.position
+
+ def GetWidget(self):
+ """!Returns underlaying winget.
+
+ @return widget or None if doesn't exist
+ """
+ return self.widget
+
+ def _update(self, longHelp):
+ """!Default implementation for Update method.
+
+ @param longHelp True to enable long help (help from toolbars)
+ """
+ self.statusbar.SetStatusText("", 0)
+ self.Show()
+ self.mapFrame.StatusbarEnableLongHelp(longHelp)
+
+ def Update(self):
+ """!Called when statusbar action is activated (e.g. through wx.Choice).
+ """
+ self._update(longHelp = False)
+
+class SbRender(SbItem):
+ """!Checkbox to enable and disable auto-rendering.
+
+ Requires MapFrame.OnRender method.
+ """
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'render'
+
+ self.widget = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
+ label = _("Render"))
+
+ self.widget.SetValue(UserSettings.Get(group = 'display',
+ key = 'autoRendering',
+ subkey = 'enabled'))
+ self.widget.Hide()
+ self.widget.SetToolTip(wx.ToolTip (_("Enable/disable auto-rendering")))
+
+ self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleRender)
+
+ def OnToggleRender(self, event):
+ # (other items should call self.mapFrame.IsAutoRendered())
+ if self.GetValue():
+ self.mapFrame.OnRender(None)
+
+ def Update(self):
+ self.Show()
+
+class SbShowRegion(SbItem):
+ """!Checkbox to enable and disable showing of computational region.
+
+ Requires MapFrame.OnRender, MapFrame.IsAutoRendered, MapFrame.GetWindow.
+ Expects that instance returned by MapFrame.GetWindow will handle
+ regionCoords attribute.
+ """
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'region'
+ self.label = _("Show comp. extent")
+
+ self.widget = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
+ label = _("Show computational extent"))
+
+ self.widget.SetValue(False)
+ self.widget.Hide()
+ self.widget.SetToolTip(wx.ToolTip (_("Show/hide computational "
+ "region extent (set with g.region). "
+ "Display region drawn as a blue box inside the "
+ "computational region, "
+ "computational region inside a display region "
+ "as a red box).")))
+
+ self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleShowRegion)
+
+ def OnToggleShowRegion(self, event):
+ """!Shows/Hides extent (comp. region) in map canvas.
+
+ Shows or hides according to checkbox value.
+ """
+ if self.widget.GetValue():
+ # show extent
+ self.mapFrame.GetWindow().regionCoords = []
+ elif hasattr(self.mapFrame.GetWindow(), 'regionCoords'):
+ del self.mapFrame.GetWindow().regionCoords
+
+ # redraw map if auto-rendering is enabled
+ if self.mapFrame.IsAutoRendered():
+ self.mapFrame.OnRender(None)
+
+ def SetValue(self, value):
+ SbItem.SetValue(self, value)
+ if value:
+ self.mapFrame.GetWindow().regionCoords = []
+ elif hasattr(self.mapFrame.GetWindow(), 'regionCoords'):
+ del self.mapFrame.GetWindow().regionCoords
+
+class SbAlignExtent(SbItem):
+ """!Checkbox to select zoom behavior.
+
+ Used by BufferedWindow (through MapFrame property).
+ See tooltip for explanation.
+ """
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'alignExtent'
+ self.label = _("Display mode")
+
+ self.widget = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
+ label = _("Align region extent based on display size"))
+
+ self.widget.SetValue(UserSettings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
+ self.widget.Hide()
+ self.widget.SetToolTip(wx.ToolTip (_("Align region extent based on display "
+ "size from center point. "
+ "Default value for new map displays can "
+ "be set up in 'User GUI settings' dialog.")))
+
+class SbResolution(SbItem):
+ """!Checkbox to select used display resolution.
+
+ Requires MapFrame.OnRender method.
+ """
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'resolution'
+ self.label = _("Display resolution")
+
+ self.widget = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
+ label = _("Constrain display resolution to computational settings"))
+
+ self.widget.SetValue(UserSettings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
+ self.widget.Hide()
+ self.widget.SetToolTip(wx.ToolTip (_("Constrain display resolution "
+ "to computational region settings. "
+ "Default value for new map displays can "
+ "be set up in 'User GUI settings' dialog.")))
+
+ self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleUpdateMap)
+
+ def OnToggleUpdateMap(self, event):
+ """!Update display when toggle display mode
+ """
+ # redraw map if auto-rendering is enabled
+ if self.mapFrame.IsAutoRendered():
+ self.mapFrame.OnRender(None)
+
+
+class SbMapScale(SbItem):
+ """!Editable combobox to get/set current map scale.
+
+ Requires MapFrame.GetMapScale, MapFrame.SetMapScale
+ and MapFrame.GetWindow (and GetWindow().UpdateMap()).
+ """
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'mapscale'
+ self.label = _("Map scale")
+
+ self.widget = wx.ComboBox(parent = self.statusbar, id = wx.ID_ANY,
+ style = wx.TE_PROCESS_ENTER,
+ size = (150, -1))
+
+ self.widget.SetItems(['1:1000',
+ '1:5000',
+ '1:10000',
+ '1:25000',
+ '1:50000',
+ '1:100000',
+ '1:1000000'])
+ self.widget.Hide()
+ self.widget.SetToolTip(wx.ToolTip (_("As everyone's monitors and resolutions "
+ "are set differently these values are not "
+ "true map scales, but should get you into "
+ "the right neighborhood.")))
+
+ self.widget.Bind(wx.EVT_TEXT_ENTER, self.OnChangeMapScale)
+ self.widget.Bind(wx.EVT_COMBOBOX, self.OnChangeMapScale)
+
+ self.lastMapScale = None
+
+ def Update(self):
+ scale = self.mapFrame.GetMapScale()
+ self.statusbar.SetStatusText("")
+ try:
+ self.SetValue("1:%ld" % (scale + 0.5))
+ except TypeError:
+ pass # FIXME, why this should happen?
+
+ self.lastMapScale = scale
+ self.Show()
+
+ # disable long help
+ self.mapFrame.StatusbarEnableLongHelp(False)
+
+ def OnChangeMapScale(self, event):
+ """!Map scale changed by user
+ """
+ scale = event.GetString()
+
+ try:
+ if scale[:2] != '1:':
+ raise ValueError
+ value = int(scale[2:])
+ except ValueError:
+ self.SetValue('1:%ld' % int(self.lastMapScale))
+ return
+
+ self.mapFrame.SetMapScale(value)
+
+ # redraw a map
+ self.mapFrame.GetWindow().UpdateMap()
+ self.GetWidget().SetFocus()
+
+
+class SbGoTo(SbItem):
+ """!Textctrl to set coordinates which to focus on.
+
+ Requires MapFrame.GetWindow, MapWindow.GoTo method.
+ """
+
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'goto'
+ self.label = _("Go to")
+
+ self.widget = wx.TextCtrl(parent = self.statusbar, id = wx.ID_ANY,
+ value = "", style = wx.TE_PROCESS_ENTER,
+ size = (300, -1))
+
+ self.widget.Hide()
+
+ self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnGoTo)
+
+ def ReprojectENToMap(self, e, n, useDefinedProjection):
+ """!Reproject east, north from user defined projection
+
+ @param e,n coordinate (for DMS string, else float or string)
+ @param useDefinedProjection projection defined by user in settings dialog
+
+ @throws SbException if useDefinedProjection is True and projection is not defined in UserSettings
+ """
+ if useDefinedProjection:
+ settings = UserSettings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4')
+ if not settings:
+ raise SbException(_("Projection not defined (check the settings)"))
+ else:
+ # reproject values
+ projIn = settings
+ projOut = gcmd.RunCommand('g.proj',
+ flags = 'jf',
+ read = True)
+ proj = projIn.split(' ')[0].split('=')[1]
+ if proj in ('ll', 'latlong', 'longlat'):
+ 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 = float(e), float(n)
+ proj, coord1 = utils.ReprojectCoordinates(coord = (e, n),
+ projIn = projIn,
+ projOut = projOut, flags = 'd')
+ e, n = coord1
+ elif self.mapFrame.GetMap().projinfo['proj'] == 'll':
+ e, n = utils.DMS2Deg(e, n)
+ else:
+ e, n = float(e), float(n)
+ return e, n
+
+ def OnGoTo(self, event):
+ """!Go to position
+ """
+ try:
+ e, n = self.GetValue().split(';')
+ e, n = self.ReprojectENToMap(e, n, self.mapFrame.GetProperty('projection'))
+ self.mapFrame.GetWindow().GoTo(e, n)
+ self.widget.SetFocus()
+ except ValueError:
+ # FIXME: move this code to MapWindow/BufferedWindow/MapFrame
+ region = self.mapFrame.GetMap().GetCurrentRegion()
+ precision = int(UserSettings.Get(group = 'projection', key = 'format',
+ subkey = 'precision'))
+ format = UserSettings.Get(group = 'projection', key = 'format',
+ subkey = 'll')
+ if self.mapFrame.GetMap().projinfo['proj'] == 'll' and format == 'DMS':
+ self.SetValue("%s" % utils.Deg2DMS(region['center_easting'],
+ region['center_northing'],
+ precision = precision))
+ else:
+ self.SetValue("%.*f; %.*f" % \
+ (precision, region['center_easting'],
+ precision, region['center_northing']))
+ except SbException, e:
+ # FIXME: this may be useless since statusbar update checks user defined projection and this exception raises when user def proj does not exists
+ self.statusbar.SetStatusText(str(e), 0)
+
+ def GetCenterString(self, map):
+ """!Get current map center in appropriate format"""
+ region = map.GetCurrentRegion()
+ precision = int(UserSettings.Get(group = 'projection', key = 'format',
+ subkey = 'precision'))
+ format = UserSettings.Get(group = 'projection', key = 'format',
+ subkey = 'll')
+ projection = UserSettings.Get(group='projection', key='statusbar', subkey='proj4')
+
+ if self.mapFrame.GetProperty('projection'):
+ if not projection:
+ raise SbException(_("Projection not defined (check the settings)"))
+ else:
+ proj, coord = utils.ReprojectCoordinates(coord = (region['center_easting'],
+ region['center_northing']),
+ projOut = projection,
+ flags = 'd')
+ if coord:
+ if proj in ('ll', 'latlong', 'longlat') and format == 'DMS':
+ return "%s" % utils.Deg2DMS(coord[0],
+ coord[1],
+ precision = precision)
+ else:
+ return "%.*f; %.*f" % (precision, coord[0], precision, coord[1])
+ else:
+ raise SbException(_("Error in projection (check the settings)"))
+ else:
+ if self.mapFrame.GetMap().projinfo['proj'] == 'll' and format == 'DMS':
+ return "%s" % utils.Deg2DMS(region['center_easting'], region['center_northing'],
+ precision = precision)
+ else:
+ return "%.*f; %.*f" % (precision, region['center_easting'], precision, region['center_northing'])
+
+
+ def SetCenter(self):
+ """!Set current map center as item value"""
+ center = self.GetCenterString(self.mapFrame.GetMap())
+ self.SetValue(center)
+
+ def Update(self):
+ self.statusbar.SetStatusText("")
+
+ try:
+ self.SetCenter()
+ self.Show()
+ except SbException, e:
+ self.statusbar.SetStatusText(str(e), 0)
+
+ # disable long help
+ self.mapFrame.StatusbarEnableLongHelp(False)
+
+
+class SbProjection(SbItem):
+ """!Checkbox to enable user defined projection (can be set in settings)"""
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'projection'
+ self.label = _("Projection")
+
+ self.defaultLabel = _("Use defined projection")
+
+ self.widget = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
+ label = self.defaultLabel)
+
+ self.widget.SetValue(False)
+
+ # necessary?
+ size = self.widget.GetSize()
+ self.widget.SetMinSize((size[0] + 150, size[1]))
+
+ self.widget.Hide()
+ self.widget.SetToolTip(wx.ToolTip (_("Reproject coordinates displayed "
+ "in the statusbar. Projection can be "
+ "defined in GUI preferences dialog "
+ "(tab 'Projection')")))
+
+ def Update(self):
+ self.statusbar.SetStatusText("")
+ epsg = UserSettings.Get(group = 'projection', key = 'statusbar', subkey = 'epsg')
+ if epsg:
+ label = '%s (EPSG: %s)' % (self.defaultLabel, epsg)
+ self.widget.SetLabel(label)
+ else:
+ self.widget.SetLabel(self.defaultLabel)
+ self.Show()
+
+ # disable long help
+ self.mapFrame.StatusbarEnableLongHelp(False)
+
+
+class SbMask(SbItem):
+ """!StaticText to show whether mask is activated."""
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'mask'
+
+ self.widget = wx.StaticText(parent = self.statusbar, id = wx.ID_ANY, label = _('MASK'))
+ self.widget.SetForegroundColour(wx.Colour(255, 0, 0))
+ self.widget.Hide()
+
+ def Update(self):
+ if grass.find_file(name = 'MASK', element = 'cell')['name']:
+ self.Show()
+ else:
+ self.Hide()
+
+class SbTextItem(SbItem):
+ """!Base class for items without widgets.
+
+ Only sets statusbar text.
+ """
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+
+ self.text = None
+
+ def Show(self):
+ self.statusbar.SetStatusText(self.GetValue(), self.position)
+
+ def Hide(self):
+ self.statusbar.SetStatusText("", self.position)
+
+ def SetValue(self, value):
+ self.text = value
+
+ def GetValue(self):
+ return self.text
+
+ def GetWidget(self):
+ return None
+
+ def Update(self):
+ self._update(longHelp = True)
+
+class SbDisplayGeometry(SbTextItem):
+ """!Show current display resolution."""
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbTextItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'displayGeometry'
+ self.label = _("Display geometry")
+
+ def Show(self):
+ region = self.mapFrame.GetMap().GetCurrentRegion()
+ self.SetValue("rows=%d; cols=%d; nsres=%.2f; ewres=%.2f" %
+ (region["rows"], region["cols"],
+ region["nsres"], region["ewres"]))
+ SbTextItem.Show(self)
+
+class SbCoordinates(SbTextItem):
+ """!Show map coordinates when mouse moves.
+
+ Requires MapWindow.GetLastEN method."""
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbTextItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'coordinates'
+ self.label = _("Coordinates")
+
+ def Show(self):
+ precision = int(UserSettings.Get(group = 'projection', key = 'format',
+ subkey = 'precision'))
+ format = UserSettings.Get(group = 'projection', key = 'format',
+ subkey = 'll')
+ projection = self.mapFrame.GetProperty('projection')
+ try:
+ e, n = self.mapFrame.GetWindow().GetLastEN()
+ self.SetValue(self.ReprojectENFromMap(e, n, projection, precision, format))
+ except SbException, e:
+ self.SetValue(e)
+ except TypeError, e:
+ self.SetValue("")
+ except AttributeError:
+ self.SetValue("") # during initialization MapFrame has no MapWindow
+ SbTextItem.Show(self)
+
+ def ReprojectENFromMap(self, e, n, useDefinedProjection, precision, format):
+ """!Reproject east, north to user defined projection.
+
+ @param e,n coordinate
+
+ @throws SbException if useDefinedProjection is True and projection is not defined in UserSettings
+ """
+ if useDefinedProjection:
+ settings = UserSettings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4')
+ if not settings:
+ raise SbException(_("Projection not defined (check the settings)"))
+ else:
+ # reproject values
+ proj, coord = utils.ReprojectCoordinates(coord = (e, n),
+ projOut = settings,
+ flags = 'd')
+ if coord:
+ e, n = coord
+ if proj in ('ll', 'latlong', 'longlat') and format == 'DMS':
+ return utils.Deg2DMS(e, n, precision = precision)
+ else:
+ return "%.*f; %.*f" % (precision, e, precision, n)
+ else:
+ raise SbException(_("Error in projection (check the settings)"))
+ else:
+ if self.mapFrame.GetMap().projinfo['proj'] == 'll' and format == 'DMS':
+ return utils.Deg2DMS(e, n, precision = precision)
+ else:
+ return "%.*f; %.*f" % (precision, e, precision, n)
+
+class SbRegionExtent(SbTextItem):
+ """!Shows current display region"""
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbTextItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'displayRegion'
+ self.label = _("Extent")
+
+ def Show(self):
+ precision = int(UserSettings.Get(group = 'projection', key = 'format',
+ subkey = 'precision'))
+ format = UserSettings.Get(group = 'projection', key = 'format',
+ subkey = 'll')
+ projection = self.mapFrame.GetProperty('projection')
+ region = self._getRegion()
+ try:
+ regionReprojected = self.ReprojectRegionFromMap(region, projection, precision, format)
+ self.SetValue(regionReprojected)
+ except SbException, e:
+ self.SetValue(e)
+ SbTextItem.Show(self)
+
+ def _getRegion(self):
+ """!Get current display region"""
+ return self.mapFrame.GetMap().GetCurrentRegion() # display region
+
+ def _formatRegion(self, w, e, s, n, nsres, ewres, precision = None):
+ """!Format display region string for statusbar
+
+ @param nsres,ewres unused
+ """
+ if precision is not None:
+ return "%.*f - %.*f, %.*f - %.*f" % (precision, w, precision, e,
+ precision, s, precision, n)
+ else:
+ return "%s - %s, %s - %s" % (w, e, s, n)
+
+
+ def ReprojectRegionFromMap(self, region, useDefinedProjection, precision, format):
+ """!Reproject region values
+
+ @todo reorganize this method to remove code useful only for derived class SbCompRegionExtent
+ """
+ if useDefinedProjection:
+ settings = UserSettings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4')
+
+ if not settings:
+ raise SbException(_("Projection not defined (check the settings)"))
+ else:
+ projOut = settings
+ 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')
+ # useless, used in derived class
+ 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') and format == 'DMS':
+ w, s = utils.Deg2DMS(coord1[0], coord1[1], string = False,
+ precision = precision)
+ e, n = utils.Deg2DMS(coord2[0], coord2[1], string = False,
+ precision = precision)
+ ewres, nsres = utils.Deg2DMS(abs(coord3[0]) - abs(coord4[0]),
+ abs(coord3[1]) - abs(coord4[1]),
+ string = False, hemisphere = False,
+ precision = precision)
+ return self._formatRegion(w = w, s = s, e = e, n = n, ewres = ewres, nsres = nsres)
+ else:
+ w, s = coord1
+ e, n = coord2
+ ewres, nsres = coord3
+ return self._formatRegion(w = w, s = s, e = e, n = n, ewres = ewres,
+ nsres = nsres, precision = precision)
+ else:
+ raise SbException(_("Error in projection (check the settings)"))
+
+ else:
+ if self.mapFrame.GetMap().projinfo['proj'] == 'll' and format == 'DMS':
+ w, s = utils.Deg2DMS(region["w"], region["s"],
+ string = False, precision = precision)
+ e, n = utils.Deg2DMS(region["e"], region["n"],
+ string = False, precision = precision)
+ ewres, nsres = utils.Deg2DMS(region['ewres'], region['nsres'],
+ string = False, precision = precision)
+ return self._formatRegion(w = w, s = s, e = e, n = n, ewres = ewres, nsres = nsres)
+ else:
+ w, s = region["w"], region["s"]
+ e, n = region["e"], region["n"]
+ ewres, nsres = region['ewres'], region['nsres']
+ return self._formatRegion(w = w, s = s, e = e, n = n, ewres = ewres,
+ nsres = nsres, precision = precision)
+
+
+class SbCompRegionExtent(SbRegionExtent):
+ """!Shows computational region."""
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbRegionExtent.__init__(self, mapframe, statusbar, position)
+ self.name = 'computationalRegion'
+ self.label = _("Comp. region")
+
+ def _formatRegion(self, w, e, s, n, ewres, nsres, precision = None):
+ """!Format computational region string for statusbar"""
+ if precision is not None:
+ return "%.*f - %.*f, %.*f - %.*f (%.*f, %.*f)" % (precision, w, precision, e,
+ precision, s, precision, n,
+ precision, ewres, precision, nsres)
+ else:
+ return "%s - %s, %s - %s (%s, %s)" % (w, e, s, n, ewres, nsres)
+
+ def _getRegion(self):
+ """!Returns computational region."""
+ return self.mapFrame.GetMap().GetRegion() # computational region
+
+
+class SbProgress(SbItem):
+ """!General progress bar to show progress.
+
+ Underlaying widget is wx.Gauge.
+ """
+ def __init__(self, mapframe, statusbar, position = 0):
+ SbItem.__init__(self, mapframe, statusbar, position)
+ self.name = 'progress'
+
+ # on-render gauge
+ self.widget = wx.Gauge(parent = self.statusbar, id = wx.ID_ANY,
+ range = 0, style = wx.GA_HORIZONTAL)
+ self.widget.Hide()
+
+ def GetRange(self):
+ """!Returns progress range."""
+ return self.widget.GetRange()
+
+ def SetRange(self, range):
+ """!Sets progress range."""
+ self.widget.SetRange(range)
+
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -71,7 +71,7 @@
distance_tot += self.Distance(self.polycoords[idx-1],
self.polycoords[idx],
screen = False)[0]
- self.parent.statusbar.SetStatusText("%.*f, %.*f (seg: %.*f; tot: %.*f)" % \
+ self.parent.SetStatusText("%.*f, %.*f (seg: %.*f; tot: %.*f)" % \
(precision, e, precision, n,
precision, distance_seg,
precision, distance_tot), 0)
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -50,8 +50,11 @@
Superclass for BufferedWindow class (2D display mode), and GLWindow
(3D display mode).
- Subclasses have to define _bindMouseEvents() method which binds
- MouseEvent handlers.
+ Subclasses have to define
+ - _bindMouseEvents method which binds MouseEvent handlers
+ - Pixel2Cell
+ - Cell2Pixel (if it is possible)
+
"""
def __init__(self, parent, id = wx.ID_ANY,
Map = None, tree = None, lmgr = None, **kwargs):
@@ -68,9 +71,11 @@
'use' : "pointer",
'box' : "point"
}
+ # last east, north coordinates, changes on mouse motion
+ self.lastEN = None
- # stores overriden cursor
- self._overridenCursor = None
+ # stores overridden cursor
+ self._overriddenCursor = None
def RegisterMouseEventHandler(self, event, handler, cursor = None):
"""!Binds event handler
@@ -101,7 +106,7 @@
@param handler function to handle event
@param cursor cursor which temporary overrides current cursor
- @return True if successfull
+ @return True if successful
@return False if event cannot be bind
"""
@@ -115,7 +120,7 @@
self.mouse['use'] = 'genericEvent'
if cursor:
- self._overridenCursor = self.GetCursor()
+ self._overriddenCursor = self.GetCursor()
self.SetCursor(cursor)
return True
@@ -129,13 +134,13 @@
@param event event to unbind
- @return True if successfull
+ @return True if successful
@return False if event cannot be unbind
"""
if hasattr(self, "digit"):
return False
- # it is not yet posible in wxPython to unbind exact event
+ # it is not yet possible in wxPython to unbind exact event
ret = self.Unbind(event)
# restore bind state
@@ -144,63 +149,45 @@
# restore mouse use (previous state)
self.mouse['use'] = self.mouse['useBeforeGenericEvent']
- # restore overriden cursor
- if self._overridenCursor:
- self.SetCursor(self._overridenCursor)
+ # restore overridden cursor
+ if self._overriddenCursor:
+ self.SetCursor(self._overriddenCursor)
return ret
+
+ def Pixel2Cell(self, (x, y)):
+ raise NotImplementedError()
+
+ def Cell2Pixel(self, (east, north)):
+ raise NotImplementedError()
-
def OnMotion(self, event):
- """!Track mouse motion and update statusbar
+ """!Tracks mouse motion and update statusbar
+
+ @see GetLastEN
"""
- if self.parent.statusbarWin['toggle'].GetSelection() == 0: # Coordinates
- precision = int(UserSettings.Get(group = 'projection', key = 'format',
- subkey = 'precision'))
- format = UserSettings.Get(group = 'projection', key = 'format',
- subkey = 'll')
- try:
- e, n = self.Pixel2Cell(event.GetPositionTuple())
- except (TypeError, ValueError):
- self.parent.statusbar.SetStatusText("", 0)
- event.Skip()
- return
-
+ try:
+ self.lastEN = self.Pixel2Cell(event.GetPositionTuple())
+ except (ValueError):
+ self.lastEN = None
+ # FIXME: special case for vdigit and access to statusbarManager
+ if self.parent.statusbarManager.GetMode() == 0: # Coordinates
updated = False
if hasattr(self, "digit"):
updated = self._onMotion((e, n), precision)
if not updated:
- if self.parent.statusbarWin['projection'].IsChecked():
- if not UserSettings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4'):
- self.parent.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
- else:
- proj, coord = utils.ReprojectCoordinates(coord = (e, n),
- projOut = UserSettings.Get(group = 'projection',
- key = 'statusbar',
- subkey = 'proj4'),
- flags = 'd')
-
- if coord:
- e, n = coord
- if proj in ('ll', 'latlong', 'longlat') and format == 'DMS':
- self.parent.statusbar.SetStatusText(utils.Deg2DMS(e, n, precision = precision),
- 0)
- else:
- self.parent.statusbar.SetStatusText("%.*f; %.*f" % \
- (precision, e, precision, n), 0)
- else:
- self.parent.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
- else:
- if self.parent.Map.projinfo['proj'] == 'll' and format == 'DMS':
- self.parent.statusbar.SetStatusText(utils.Deg2DMS(e, n, precision = precision),
- 0)
- else:
- self.parent.statusbar.SetStatusText("%.*f; %.*f" % \
- (precision, e, precision, n), 0)
+ self.parent.CoordinatesChanged()
event.Skip()
+ def GetLastEN(self):
+ """!Returns last coordinates of mouse cursor.
+
+ @see OnMotion
+ """
+ return self.lastEN
+
def GetLayerByName(self, name, mapType, dataType = 'layer'):
"""!Get layer from layer tree by nam
@@ -227,7 +214,7 @@
return self.tree.GetPyData(item)[0]['nviz']
return item
-
+
def GetSelectedLayer(self, type = 'layer', multi = False):
"""!Get selected layer from layer tree
@@ -747,9 +734,9 @@
# initialize process bar (only on 'render')
#
if render or renderVector:
- self.parent.statusbarWin['progress'].Show()
- if self.parent.statusbarWin['progress'].GetRange() > 0:
- self.parent.statusbarWin['progress'].SetValue(1)
+ self.parent.GetProgressBar().Show()
+ if self.parent.GetProgressBar().GetRange() > 0:
+ self.parent.GetProgressBar().SetValue(1)
#
# render background image if needed
@@ -766,7 +753,7 @@
if render:
# update display size
self.Map.ChangeMapSize(self.GetClientSize())
- if self.parent.statusbarWin['resolution'].IsChecked():
+ if self.parent.GetProperty('resolution'):
# use computation region resolution for rendering
windres = True
else:
@@ -869,18 +856,13 @@
#
# hide process bar
#
- self.parent.statusbarWin['progress'].Hide()
+ self.parent.GetProgressBar().Hide()
#
# update statusbar
#
### self.Map.SetRegion()
self.parent.StatusbarUpdate()
- if grass.find_file(name = 'MASK', element = 'cell')['name']:
- # mask found
- self.parent.statusbarWin['mask'].SetLabel(_('MASK'))
- else:
- self.parent.statusbarWin['mask'].SetLabel('')
Debug.msg (1, "BufferedWindow.UpdateMap(): render=%s, renderVector=%s -> time=%g" % \
@@ -1648,8 +1630,8 @@
self.Map.region['center_northing'] = cn
self.Map.region['ewres'] = (newreg['e'] - newreg['w']) / self.Map.width
self.Map.region['nsres'] = (newreg['n'] - newreg['s']) / self.Map.height
- if 'alignExtent' not in self.parent.statusbarWin or \
- self.parent.statusbarWin['alignExtent'].IsChecked():
+ if not self.parent.HasProperty('alignExtent') or \
+ self.parent.GetProperty('alignExtent'):
self.Map.AlignExtentFromDisplay()
else:
for k in ('n', 's', 'e', 'w'):
@@ -1810,7 +1792,27 @@
self.UpdateMap()
self.parent.StatusbarUpdate()
+
+
+ def GoTo(self, e, n):
+ region = self.Map.GetCurrentRegion()
+
+ region['center_easting'], region['center_northing'] = e, n
+ dn = (region['nsres'] * region['rows']) / 2.
+ region['n'] = region['center_northing'] + dn
+ region['s'] = region['center_northing'] - dn
+ de = (region['ewres'] * region['cols']) / 2.
+ region['e'] = region['center_easting'] + de
+ region['w'] = region['center_easting'] - de
+
+ self.Map.AdjustRegion()
+
+ # add to zoom history
+ self.ZoomHistory(region['n'], region['s'],
+ region['e'], region['w'])
+ self.UpdateMap()
+
def DisplayToWind(self):
"""!Set computational region (WIND file) to match display
extents
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -132,7 +132,7 @@
os.environ['GRASS_REGION'] = self.Map.SetRegion(windres = True)
self.nvizThread = NvizThread(logerr,
- self.parent.statusbarWin['progress'],
+ self.parent.GetProgressBar(),
logmsg)
self.nvizThread.start()
time.sleep(.1)
@@ -823,12 +823,12 @@
self.resize = False
if self.render['quick'] is False:
- self.parent.statusbarWin['progress'].Show()
- self.parent.statusbarWin['progress'].SetRange(2)
- self.parent.statusbarWin['progress'].SetValue(0)
+ self.parent.GetProgressBar().Show()
+ self.parent.GetProgressBar().SetRange(2)
+ self.parent.GetProgressBar().SetValue(0)
if self.render['quick'] is False:
- self.parent.statusbarWin['progress'].SetValue(1)
+ self.parent.GetProgressBar().SetValue(1)
self._display.Draw(False, -1)
if self.saveHistory:
self.ViewHistory(view = self.view, iview = self.iview)
@@ -864,9 +864,9 @@
stop = time.clock()
if self.render['quick'] is False:
- self.parent.statusbarWin['progress'].SetValue(2)
+ self.parent.GetProgressBar().SetValue(2)
# hide process bar
- self.parent.statusbarWin['progress'].Hide()
+ self.parent.GetProgressBar().Hide()
Debug.msg(3, "GLWindow.UpdateMap(): quick = %d, -> time = %g" % \
(self.render['quick'], (stop-start)))
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -1982,7 +1982,7 @@
checklist = self.FindWindowById(self.win['vector'][vtype]['surface'])
checklist.Delete(checklist.FindString(name))
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnConstantSelection(self, event):
@@ -2016,7 +2016,7 @@
# update properties
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnFringe(self, event):
@@ -2424,7 +2424,7 @@
color = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
self._display.SetBgColor(str(color))
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSetSurface(self, event):
@@ -2510,7 +2510,7 @@
self.mapWindow.render['quick'] = True
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
event.Skip()
@@ -2584,7 +2584,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnLookFrom(self, event):
@@ -2689,7 +2689,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def EnablePage(self, name, enabled = True):
@@ -2802,14 +2802,14 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSurfaceResolution(self, event):
"""!Draw resolution changed"""
self.SetSurfaceResolution()
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
@@ -2855,7 +2855,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSurfaceModeAll(self, event):
@@ -2886,7 +2886,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def _getColorString(self, color):
@@ -2939,7 +2939,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSurfaceAxis(self, event):
@@ -3008,7 +3008,7 @@
wx.PostEvent(self.mapWindow, event)
self.mapWindow.render['quick'] = True
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
# self.UpdatePage('surface')
@@ -3082,7 +3082,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
event.Skip()
@@ -3148,7 +3148,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnVectorHeight(self, event):
@@ -3223,7 +3223,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
@@ -3253,7 +3253,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnCheckThematic(self, event):
@@ -3296,7 +3296,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSetThematic(self, event):
@@ -3400,7 +3400,7 @@
data['draw']['shading']['slice']['desc'] = 'flat'
data['draw']['shading']['slice']['value'] = mode
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnVolumeResolution(self, event):
@@ -3419,7 +3419,7 @@
self._display.SetSliceRes(id, res)
data['draw']['resolution']['slice']['value'] = res
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnInOutMode(self, event):
@@ -3432,7 +3432,7 @@
if ret == 1:
data['isosurface'][isosurfId]['inout'] = event.GetInt()
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
@@ -3481,7 +3481,7 @@
# disable -> make transparent
self._display.SetSliceTransp(vid, id, 255)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnVolumeSelect(self, event):
@@ -3586,7 +3586,7 @@
else:
self.UpdateVolumeSlicePage(sliceData)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
event.Skip()
@@ -3633,7 +3633,7 @@
self.UpdateVolumeSlicePage(None)
self.UpdateIsosurfButtons(list)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
event.Skip()
@@ -3674,7 +3674,7 @@
# update buttons
self.UpdateIsosurfButtons(list)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
event.Skip()
@@ -3715,7 +3715,7 @@
# update buttons
self.UpdateIsosurfButtons(list)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
event.Skip()
@@ -3764,7 +3764,7 @@
wx.PostEvent(self.mapWindow, event)
self.mapWindow.render['quick'] = True
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnVolumeAxis(self, event):
@@ -3817,7 +3817,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnVolumeSliceAxes(self, event):
@@ -3840,7 +3840,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSliceTransparency(self, event):
@@ -3860,7 +3860,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSliceReset(self, event):
@@ -3881,7 +3881,7 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSlicePositionChange(self, event):
@@ -3905,13 +3905,13 @@
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnSlicePositionChanged(self, event):
"""!Slice position is changed"""
self.mapWindow.render['quick'] = False
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnCPlaneSelection(self, event):
@@ -3924,7 +3924,7 @@
planeIndex = -1
self.EnablePage("cplane", enabled = False)
self.mapWindow.SelectCPlane(planeIndex)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
self.UpdateCPlanePage(planeIndex)
@@ -3948,13 +3948,13 @@
event = wxUpdateCPlane(update = (action,), current = planeIndex)
wx.PostEvent(self.mapWindow, event)
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnCPlaneChangeDone(self, event):
"""!Cutting plane change done"""
self.mapWindow.render['quick'] = False
- if self.mapDisplay.statusbarWin['render'].IsChecked():
+ if self.mapDisplay.IsAutoRendered():
self.mapWindow.Refresh(False)
def OnCPlaneChangeText(self, event):
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -758,7 +758,7 @@
self.internalSettings['appearance']['gSelectPopupHeight']['max'] = 1000
self.internalSettings['display']['driver']['choices'] = ['cairo', 'png']
- self.internalSettings['display']['statusbarMode']['choices'] = globalvar.MAP_DISPLAY_STATUSBAR_MODE
+ self.internalSettings['display']['statusbarMode']['choices'] = None # set during MapFrame init
self.internalSettings['nviz']['view'] = {}
self.internalSettings['nviz']['view']['twist'] = {}
Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -605,6 +605,8 @@
@return region settings as directory, e.g. {
'n':'4928010', 's':'4913700', 'w':'589980',...}
+
+ @see GetCurrentRegion()
"""
region = {}
@@ -687,7 +689,10 @@
return region
def GetCurrentRegion(self):
- """!Get current display region settings"""
+ """!Get current display region settings
+
+ @see GetRegion()
+ """
return self.region
def SetRegion(self, windres = False):
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -1075,9 +1075,9 @@
UserSettings.Set(group = 'vdigit', key = 'bgmap',
subkey = 'value', value = '', internal = True)
- self.parent.statusbar.SetStatusText(_("Please wait, "
- "opening vector map <%s> for editing...") % mapLayer.GetName(),
- 0)
+ self.parent.SetStatusText(_("Please wait, "
+ "opening vector map <%s> for editing...") % mapLayer.GetName(),
+ 0)
self.parent.MapWindow.pdcVector = wx.PseudoDC()
self.digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
@@ -1162,10 +1162,10 @@
self.digit.Undo(0)
dlg.Destroy()
- self.parent.statusbar.SetStatusText(_("Please wait, "
- "closing and rebuilding topology of "
- "vector map <%s>...") % self.mapLayer.GetName(),
- 0)
+ self.parent.SetStatusText(_("Please wait, "
+ "closing and rebuilding topology of "
+ "vector map <%s>...") % self.mapLayer.GetName(),
+ 0)
self.digit.CloseMap()
lmgr = self.parent.GetLayerManager()
Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -811,7 +811,7 @@
self.digit.UpdateSettings()
# redraw map if auto-rendering is enabled
- if self.parent.statusbarWin['render'].GetValue():
+ if self.parent.IsAutoRendered():
self.parent.OnRender(None)
class VDigitCategoryDialog(wx.Dialog, listmix.ColumnSorterMixin):
Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-10-09 22:35:07 UTC (rev 48702)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-10-10 12:46:41 UTC (rev 48703)
@@ -916,11 +916,11 @@
'dim="%d,%d,%d,%d" '
'extent="%f,%f,%f,%f" '
'viewMode="%s" >\n' % (' ' * self.indent,
- int(mapTree.mapdisplay.statusbarWin['render'].IsChecked()),
- mapTree.mapdisplay.statusbarWin['toggle'].GetSelection(),
- int(mapTree.mapdisplay.statusbarWin['region'].IsChecked()),
- int(mapTree.mapdisplay.statusbarWin['alignExtent'].IsChecked()),
- int(mapTree.mapdisplay.statusbarWin['resolution'].IsChecked()),
+ int(mapTree.mapdisplay.GetProperty('render')),
+ mapTree.mapdisplay.statusbarManager.GetMode(),
+ int(mapTree.mapdisplay.GetProperty('region')),
+ int(mapTree.mapdisplay.GetProperty('alignExtent')),
+ int(mapTree.mapdisplay.GetProperty('resolution')),
displayPos[0],
displayPos[1],
displaySize[0],
@@ -932,7 +932,7 @@
viewmode
))
# projection statusbar info
- if mapTree.mapdisplay.statusbarWin['projection'].IsChecked() and \
+ if mapTree.mapdisplay.GetProperty('projection') and \
UserSettings.Get(group='display', key='projection', subkey='proj4'):
self.indent += 4
file.write('%s<projection' % (' ' * self.indent))
More information about the grass-commit
mailing list