[GRASS-SVN] r57352 - in grass/trunk/gui/wxpython: animation core gcp gui_core iclass lmgr mapdisp mapswipe vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 1 14:30:50 PDT 2013
Author: wenzeslaus
Date: 2013-08-01 14:30:50 -0700 (Thu, 01 Aug 2013)
New Revision: 57352
Modified:
grass/trunk/gui/wxpython/animation/mapwindow.py
grass/trunk/gui/wxpython/core/workspace.py
grass/trunk/gui/wxpython/gcp/mapdisplay.py
grass/trunk/gui/wxpython/gui_core/mapdisp.py
grass/trunk/gui/wxpython/gui_core/mapwindow.py
grass/trunk/gui/wxpython/iclass/digit.py
grass/trunk/gui/wxpython/iclass/frame.py
grass/trunk/gui/wxpython/lmgr/frame.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/mapdisp/mapwindow.py
grass/trunk/gui/wxpython/mapdisp/statusbar.py
grass/trunk/gui/wxpython/mapswipe/frame.py
grass/trunk/gui/wxpython/mapswipe/mapwindow.py
grass/trunk/gui/wxpython/vdigit/mapwindow.py
Log:
wxGUI/mapwindow: introducing object with map window properties (and showRegion SbItem simplified)
Modified: grass/trunk/gui/wxpython/animation/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/animation/mapwindow.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/animation/mapwindow.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -105,7 +105,7 @@
class AnimationWindow(BufferedWindow):
- def __init__(self, parent, id = wx.ID_ANY,
+ def __init__(self, parent, id=wx.ID_ANY,
style = wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE | wx.BORDER_RAISED):
Debug.msg(2, "AnimationWindow.__init__()")
@@ -113,7 +113,7 @@
self.text = ''
self.parent = parent
- BufferedWindow.__init__(self, parent = parent, id = id, style = style)
+ BufferedWindow.__init__(self, parent=parent, id=id, style=style)
self.SetBackgroundColour(wx.BLACK)
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.Bind(wx.EVT_SIZE, self.OnSize)
Modified: grass/trunk/gui/wxpython/core/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/core/workspace.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/core/workspace.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -603,11 +603,11 @@
'extent="%f,%f,%f,%f" '
'viewMode="%s" >\n' % (' ' * self.indent,
dispName.encode('utf8'),
- int(mapdisp.GetProperty('render')),
+ int(mapdisp.mapWindowProperties.autoRender),
mapdisp.statusbarManager.GetMode(),
- int(mapdisp.GetProperty('region')),
- int(mapdisp.GetProperty('alignExtent')),
- int(mapdisp.GetProperty('resolution')),
+ int(mapdisp.mapWindowProperties.showRegion),
+ int(mapdisp.mapWindowProperties.alignExtent),
+ int(mapdisp.mapWindowProperties.resolution),
displayPos[0],
displayPos[1],
displaySize[0],
Modified: grass/trunk/gui/wxpython/gcp/mapdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/mapdisplay.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/gcp/mapdisplay.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -32,6 +32,7 @@
from gui_core.mapdisp import SingleMapFrame
from core.settings import UserSettings
from mapdisp.mapwindow import BufferedWindow
+from gui_core.mapwindow import MapWindowProperties
import mapdisp.statusbar as sb
import gcp.statusbar as sbgcp
@@ -62,6 +63,10 @@
Map = Map, auimgr = auimgr, name = name, **kwargs)
self._giface = giface
+ # properties are shared in other objects, so defining here
+ self.mapWindowProperties = MapWindowProperties()
+ self.mapWindowProperties.setValuesFromUserSettings()
+ self.mapWindowProperties.alignExtent = True
#
# Add toolbars
@@ -112,10 +117,12 @@
#
self.grwiz.SwitchEnv('source')
self.SrcMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
+ properties=self.mapWindowProperties,
Map=self.SrcMap, frame=self)
self.grwiz.SwitchEnv('target')
self.TgtMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
+ properties=self.mapWindowProperties,
Map=self.TgtMap, frame=self)
self.MapWindow = self.SrcMapWindow
self.Map = self.SrcMap
Modified: grass/trunk/gui/wxpython/gui_core/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapdisp.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/gui_core/mapdisp.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -256,7 +256,11 @@
def IsAutoRendered(self):
"""!Check if auto-rendering is enabled"""
- return self.GetProperty('render')
+ # TODO: this is now not the right place to access this attribute
+ # TODO: add mapWindowProperties to init parameters
+ # and pass the right object in the init of derived class?
+ # or do not use this method at all, let mapwindow decide
+ return self.mapWindowProperties.autoRender
def CoordinatesChanged(self):
"""!Shows current coordinates on statusbar.
Modified: grass/trunk/gui/wxpython/gui_core/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapwindow.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/gui_core/mapwindow.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -25,7 +25,73 @@
from core.utils import _
from grass.script import core as grass
+from grass.pydispatch.signal import Signal
+
+class MapWindowProperties(object):
+ def __init__(self):
+ self._resolution = None
+ self.resolutionChanged = Signal('MapWindowProperties.resolutionChanged')
+ self._autoRender = None
+ self.autoRenderChanged = Signal('MapWindowProperties.autoRenderChanged')
+ self._showRegion = None
+ self.showRegionChanged = Signal('MapWindowProperties.showRegionChanged')
+ self._alignExtent = None
+ self.alignExtentChanged = Signal('MapWindowProperties.alignExtentChanged')
+
+ def setValuesFromUserSettings(self):
+ """Convenient function to get values from user settings into this object."""
+ self._resolution = UserSettings.Get(group='display',
+ key='compResolution',
+ subkey='enabled')
+ self._autoRender = UserSettings.Get(group='display',
+ key='autoRendering',
+ subkey='enabled')
+ self._showRegion = False # in statusbar.py was not from settings
+ self._alignExtent = UserSettings.Get(group='display',
+ key='alignExtent',
+ subkey='enabled')
+ @property
+ def resolution(self):
+ return self._resolution
+
+ @resolution.setter
+ def resolution(self, value):
+ if value != self._resolution:
+ self._resolution = value
+ self.resolutionChanged.emit(value=value)
+
+ @property
+ def autoRender(self):
+ return self._autoRender
+
+ @autoRender.setter
+ def autoRender(self, value):
+ if value != self._autoRender:
+ self._autoRender = value
+ self.autoRenderChanged.emit(value=value)
+
+ @property
+ def showRegion(self):
+ return self._showRegion
+
+ @showRegion.setter
+ def showRegion(self, value):
+ if value != self._showRegion:
+ self._showRegion = value
+ self.showRegionChanged.emit(value=value)
+
+ @property
+ def alignExtent(self):
+ return self._alignExtent
+
+ @alignExtent.setter
+ def alignExtent(self, value):
+ if value != self._alignExtent:
+ self._alignExtent = value
+ self.alignExtentChanged.emit(value=value)
+
+
class MapWindow(object):
"""!Abstract map display window class
Modified: grass/trunk/gui/wxpython/iclass/digit.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/digit.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/iclass/digit.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -34,7 +34,7 @@
class IClassVDigitWindow(VDigitWindow):
"""! Class similar to VDigitWindow but specialized for wxIClass."""
- def __init__(self, parent, giface, map, frame):
+ def __init__(self, parent, giface, map, frame, properties):
"""!
@a parent should has toolbar providing current class (category).
@@ -42,7 +42,8 @@
@param parent gui parent
@param map map renderer instance
"""
- VDigitWindow.__init__(self, parent = parent, giface = giface, Map = map, frame = frame)
+ VDigitWindow.__init__(self, parent=parent, giface=giface,
+ Map=map, frame=frame, properties=properties)
def _onLeftDown(self, event):
action = self.toolbar.GetAction()
Modified: grass/trunk/gui/wxpython/iclass/frame.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/frame.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/iclass/frame.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -51,6 +51,7 @@
from core.render import Map, MapLayer
from core.gcmd import RunCommand, GMessage, GError, GWarning
from gui_core.dialogs import SetOpacityDialog
+from gui_core.mapwindow import MapWindowProperties
from dbmgr.vinfo import VectorDBInfo
import grass.script as grass
@@ -87,9 +88,16 @@
firstMap = Map(), secondMap = Map(),
**kwargs)
self._giface = giface
+ self.mapWindowProperties = MapWindowProperties()
+ self.mapWindowProperties.setValuesFromUserSettings()
+ # show computation region by defaut
+ self.mapWindowProperties.showRegion = True
+
self.firstMapWindow = IClassVDigitWindow(parent = self, giface = self._giface,
+ properties=self.mapWindowProperties,
map = self.firstMap, frame = self)
self.secondMapWindow = BufferedWindow(parent = self, giface = self._giface,
+ properties=self.mapWindowProperties,
Map = self.secondMap, frame = self)
self.MapWindow = self.firstMapWindow # current by default
@@ -143,7 +151,6 @@
self.statusbarManager.AddStatusbarItem(sb.SbRender(self, statusbar = statusbar, position = 3))
self.statusbarManager.Update()
- self.SetProperty('region', True) # show computation region by defaut
self.trainingMapManager = MapManager(self, mapWindow = self.GetFirstWindow(),
Map = self.GetFirstMap())
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -1821,12 +1821,13 @@
def OnAddRasterArrow(self, event):
"""!Add flow arrows raster map to the current layer tree"""
self.notebook.SetSelectionByName('layers')
+ # here it seems that it should be retrieved from the mapwindow
mapdisplay = self.GetMapDisplay()
- resolution = mapdisplay.GetProperty('resolution')
+ resolution = mapdisplay.mapWindowProperties.resolution
if not resolution:
dlg = self.MsgDisplayResolution()
if dlg.ShowModal() == wx.ID_YES:
- mapdisplay.SetProperty('resolution', True)
+ mapdisplay.mapWindowProperties.resolution = True
dlg.Destroy()
self.GetLayerTree().AddLayer('rastarrow')
@@ -1835,13 +1836,13 @@
"""!Add cell number raster map to the current layer tree"""
self.notebook.SetSelectionByName('layers')
mapdisplay = self.GetMapDisplay()
- resolution = mapdisplay.GetProperty('resolution')
+ resolution = mapdisplay.mapWindowProperties.resolution
if not resolution:
limitText = _("Note that cell values can only be displayed for "
"regions of less than 10,000 cells.")
dlg = self.MsgDisplayResolution(limitText)
if dlg.ShowModal() == wx.ID_YES:
- mapdisplay.SetProperty('resolution', True)
+ mapdisplay.mapWindowProperties.resolution = True
dlg.Destroy()
# region = tree.GetMap().GetCurrentRegion()
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -49,6 +49,7 @@
from core.debug import Debug
from core.settings import UserSettings
from gui_core.mapdisp import SingleMapFrame
+from gui_core.mapwindow import MapWindowProperties
from gui_core.query import QueryDialog, PrepareQueryResults
from mapdisp.mapwindow import BufferedWindow
from mapdisp.overlays import LegendController, BarscaleController
@@ -91,6 +92,11 @@
self.tree = tree # Layer Manager layer tree object
self.page = page # Notebook page holding the layer tree
self.layerbook = notebook # Layer Manager layer tree notebook
+
+ # properties are shared in other objects, so defining here
+ self.mapWindowProperties = MapWindowProperties()
+ self.mapWindowProperties.setValuesFromUserSettings()
+
#
# Add toolbars
#
@@ -128,8 +134,6 @@
self.statusbarManager.AddStatusbarItemsByClass(self.statusbarItems, mapframe = self, statusbar = statusbar)
self.statusbarManager.AddStatusbarItem(sb.SbMask(self, statusbar = statusbar, position = 2))
sbRender = sb.SbRender(self, statusbar = statusbar, position = 3)
- sbRender.autoRender.connect(lambda state: self.OnRender(None) if state else None)
-
self.statusbarManager.AddStatusbarItem(sbRender)
self.statusbarManager.Update()
@@ -144,11 +148,16 @@
self.decorations[self.legend.id] = self.legend
self.decorations[self.barscale.id] = self.barscale
+ self.mapWindowProperties.autoRenderChanged.connect(
+ lambda value:
+ self.OnRender(None) if value else None)
+
#
# Init map display (buffered DC & set default cursor)
#
self.MapWindow2D = BufferedWindow(self, giface = self._giface, id = wx.ID_ANY,
Map=self.Map, frame=self,
+ properties=self.mapWindowProperties,
overlays=self.decorations)
self.MapWindow2D.mapQueried.connect(self.Query)
# enable or disable zoom history tool
@@ -242,6 +251,7 @@
self.MapWindowVDigit = VDigitWindow(parent = self, giface = self._giface,
id = wx.ID_ANY, frame = self,
Map = self.Map, tree = self.tree,
+ properties=self.mapWindowProperties,
lmgr = self._layerManager)
self.MapWindowVDigit.Show()
self._mgr.AddPane(self.MapWindowVDigit, wx.aui.AuiPaneInfo().CentrePane().
@@ -1266,12 +1276,12 @@
def SetProperties(self, render = False, mode = 0, showCompExtent = False,
constrainRes = False, projection = False, alignExtent = True):
"""!Set properies of map display window"""
- self.SetProperty('render', render)
+ self.mapWindowProperties.autoRender = render
self.statusbarManager.SetMode(mode)
self.StatusbarUpdate()
- self.SetProperty('region', showCompExtent)
- self.SetProperty('alignExtent', alignExtent)
- self.SetProperty('resolution', constrainRes)
+ self.mapWindowProperties.showRegion = showCompExtent
+ self.mapWindowProperties.alignExtent = alignExtent
+ self.mapWindowProperties.resolution = constrainRes
self.SetProperty('projection', projection)
def IsStandalone(self):
Modified: grass/trunk/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/mapwindow.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/mapdisp/mapwindow.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -55,7 +55,7 @@
can also save the drawing to file by calling the
SaveToFile() method.
"""
- def __init__(self, parent, giface, Map, frame,
+ def __init__(self, parent, giface, Map, frame, properties,
id=wx.ID_ANY, overlays=None,
style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
"""!
@@ -71,6 +71,8 @@
frame = frame, **kwargs)
wx.Window.__init__(self, parent = parent, id = id, style = style, **kwargs)
+ self._properties = properties
+
# flags
self.resize = False # indicates whether or not a resize event has taken place
self.dragimg = None # initialize variable for map panning
@@ -519,7 +521,7 @@
self.Map.ChangeMapSize((width, height))
ibuffer = wx.EmptyBitmap(max(1, width), max(1, height))
- self.Map.Render(force = True, windres = self.frame.GetProperty('resolution'))
+ self.Map.Render(force = True, windres = self._properties.resolution)
img = self.GetImage()
self.pdc.RemoveAll()
self.Draw(self.pdc, img, drawid = 99)
@@ -646,7 +648,7 @@
if render:
# update display size
self.Map.ChangeMapSize(self.GetClientSize())
- if self.frame.GetProperty('resolution'):
+ if self._properties.resolution:
# use computation region resolution for rendering
windres = True
else:
@@ -755,7 +757,7 @@
Display region is drawn as a blue box inside the computational region,
computational region inside a display region as a red box).
"""
- if hasattr(self, "regionCoords"):
+ if self._properties.showRegion:
compReg = self.Map.GetRegion()
dispReg = self.Map.GetCurrentRegion()
reg = None
@@ -766,15 +768,15 @@
self.polypen = wx.Pen(colour = wx.Colour(255, 0, 0, 128),
width = 3, style = wx.SOLID)
reg = compReg
-
- self.regionCoords = []
- self.regionCoords.append((reg['w'], reg['n']))
- self.regionCoords.append((reg['e'], reg['n']))
- self.regionCoords.append((reg['e'], reg['s']))
- self.regionCoords.append((reg['w'], reg['s']))
- self.regionCoords.append((reg['w'], reg['n']))
+
+ regionCoords = []
+ regionCoords.append((reg['w'], reg['n']))
+ regionCoords.append((reg['e'], reg['n']))
+ regionCoords.append((reg['e'], reg['s']))
+ regionCoords.append((reg['w'], reg['s']))
+ regionCoords.append((reg['w'], reg['n']))
# draw region extent
- self.DrawLines(pdc = self.pdcDec, polycoords = self.regionCoords)
+ self.DrawLines(pdc=self.pdcDec, polycoords=regionCoords)
def IsInRegion(self, region, refRegion):
"""!
@@ -1469,8 +1471,7 @@
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 not self.frame.HasProperty('alignExtent') or \
- self.frame.GetProperty('alignExtent'):
+ if self._properties.alignExtent:
self.Map.AlignExtentFromDisplay()
else:
for k in ('n', 's', 'e', 'w'):
Modified: grass/trunk/gui/wxpython/mapdisp/statusbar.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/statusbar.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/mapdisp/statusbar.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -381,20 +381,31 @@
def __init__(self, mapframe, statusbar, position = 0):
SbItem.__init__(self, mapframe, statusbar, position)
self.name = 'render'
-
+ self._properties = mapframe.mapWindowProperties
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.SetValue(self._properties.autoRender)
self.widget.Hide()
self.widget.SetToolTip(wx.ToolTip (_("Enable/disable auto-rendering")))
-
- self.autoRender = Signal('SbRender.autoRender')
- self.widget.Bind(wx.EVT_CHECKBOX, lambda evt:
- self.autoRender.emit(state = self.GetValue()))
+ self._connectAutoRender()
+ self.widget.Bind(wx.EVT_CHECKBOX, self._onCheckbox)
+
+ def _setValue(self, value):
+ self.widget.SetValue(value)
+
+ def _connectAutoRender(self):
+ self._properties.autoRenderChanged.connect(self._setValue)
+
+ def _disconnectAutoRender(self):
+ self._properties.autoRenderChanged.disconnect(self._setValue)
+
+ def _onCheckbox(self, event):
+ self._disconnectAutoRender()
+ self._properties.autoRender = self.widget.GetValue()
+ self._connectAutoRender()
+
def Update(self):
self.Show()
@@ -402,18 +413,16 @@
"""!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._properties = mapframe.mapWindowProperties
+
self.widget = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
label = _("Show computational extent"))
-
- self.widget.SetValue(False)
+ self.widget.SetValue(self._properties.showRegion)
self.widget.Hide()
self.widget.SetToolTip(wx.ToolTip (_("Show/hide computational "
"region extent (set with g.region). "
@@ -421,9 +430,18 @@
"computational region, "
"computational region inside a display region "
"as a red box).")))
-
self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleShowRegion)
-
+ self._connectShowRegion()
+
+ def _setValue(self, value):
+ self.widget.SetValue(value)
+
+ def _connectShowRegion(self):
+ self._properties.showRegionChanged.connect(self._setValue)
+
+ def _disconnectShowRegion(self):
+ self._properties.showRegionChanged.disconnect(self._setValue)
+
def OnToggleShowRegion(self, event):
"""!Shows/Hides extent (comp. region) in map canvas.
@@ -431,28 +449,21 @@
@todo needs refactoring
"""
- if self.widget.GetValue():
- # show extent
- for mapWindow in self.mapFrame.GetWindows():
- mapWindow.regionCoords = []
- elif hasattr(self.mapFrame.GetWindow(), 'regionCoords'):
- for mapWindow in self.mapFrame.GetWindows():
- del mapWindow.regionCoords
+ self._disconnectShowRegion()
+ self._properties.showRegion = self.widget.GetValue()
+ self._connectShowRegion()
# redraw map if auto-rendering is enabled
if self.mapFrame.IsAutoRendered():
self.mapFrame.OnRender(None)
def SetValue(self, value):
+ self._disconnectShowRegion()
+ self._properties.showRegion = value
SbItem.SetValue(self, value)
- if value:
- for mapWindow in self.mapFrame.GetWindows():
- mapWindow.regionCoords = []
- elif hasattr(self.mapFrame.GetWindow(), 'regionCoords'):
- # TODO: this maybe never happends
- for mapWindow in self.mapFrame.GetWindows():
- mapWindow.regionCoords = []
-
+ self._connectShowRegion()
+
+
class SbAlignExtent(SbItem):
"""!Checkbox to select zoom behavior.
@@ -463,17 +474,37 @@
SbItem.__init__(self, mapframe, statusbar, position)
self.name = 'alignExtent'
self.label = _("Display mode")
-
+ self._properties = mapframe.mapWindowProperties
+
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.SetValue(self._properties.alignExtent)
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.")))
-
+ self._connectAlignExtent()
+ self.widget.Bind(wx.EVT_CHECKBOX, self._onCheckbox)
+
+ # TODO: these four methods are in many stitems
+ # some generalization?
+ # passing properties as stings and set/get attr would work, but it is nice?
+ def _setValue(self, value):
+ self.widget.SetValue(value)
+
+ def _connectAlignExtent(self):
+ self._properties.alignExtentChanged.connect(self._setValue)
+
+ def _disconnectAlignExtent(self):
+ self._properties.alignExtentChanged.disconnect(self._setValue)
+
+ def _onCheckbox(self, event):
+ self._disconnectAlignExtent()
+ self._properties.alignExtent = self.widget.GetValue()
+ self._connectAlignExtent()
+
+
class SbResolution(SbItem):
"""!Checkbox to select used display resolution.
@@ -483,11 +514,10 @@
SbItem.__init__(self, mapframe, statusbar, position)
self.name = 'resolution'
self.label = _("Display resolution")
-
+ self._properties = self.mapFrame.mapWindowProperties
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.SetValue(self._properties.resolution)
self.widget.Hide()
self.widget.SetToolTip(wx.ToolTip (_("Constrain display resolution "
"to computational region settings. "
@@ -495,10 +525,23 @@
"be set up in 'User GUI settings' dialog.")))
self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleUpdateMap)
-
+ self._connectResolutionChange()
+
+ def _setValue(self, value):
+ self.widget.SetValue(value)
+
+ def _connectResolutionChange(self):
+ self._properties.resolutionChanged.connect(self._setValue)
+
+ def _disconnectResolutionChange(self):
+ self._properties.resolutionChanged.disconnect(self._setValue)
+
def OnToggleUpdateMap(self, event):
"""!Update display when toggle display mode
"""
+ self._disconnectResolutionChange()
+ self._properties.resolution = self.widget.GetValue()
+ self._connectResolutionChange()
# redraw map if auto-rendering is enabled
if self.mapFrame.IsAutoRendered():
self.mapFrame.OnRender(None)
@@ -798,7 +841,7 @@
def Show(self):
region = copy.copy(self.mapFrame.GetMap().GetCurrentRegion())
- if self.mapFrame.GetProperty('resolution'):
+ if self.mapFrame.mapWindowProperties.resolution:
compRegion = self.mapFrame.GetMap().GetRegion(add3d = False)
region['rows'] = abs(int((region['n'] - region['s']) / compRegion['nsres']) + 0.5)
region['cols'] = abs(int((region['e'] - region['w']) / compRegion['ewres']) + 0.5)
Modified: grass/trunk/gui/wxpython/mapswipe/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/frame.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/mapswipe/frame.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -23,6 +23,7 @@
from gui_core.mapdisp import DoubleMapFrame
from gui_core.dialogs import GetImageHandlers
+from gui_core.mapwindow import MapWindowProperties
from core.render import Map
from mapdisp import statusbar as sb
from core.debug import Debug
@@ -60,9 +61,14 @@
self.sliderH = wx.Slider(self, id = wx.ID_ANY, style = wx.SL_HORIZONTAL)
self.sliderV = wx.Slider(self, id = wx.ID_ANY, style = wx.SL_VERTICAL)
+ self.mapWindowProperties = MapWindowProperties()
+ self.mapWindowProperties.setValuesFromUserSettings()
+ self.mapWindowProperties.autoRenderChanged.connect(self.OnAutoRenderChanged)
self.firstMapWindow = SwipeBufferedWindow(parent = self.splitter, giface = self._giface,
+ properties=self.mapWindowProperties,
Map = self.firstMap, frame = self)
self.secondMapWindow = SwipeBufferedWindow(parent = self.splitter, giface = self._giface,
+ properties=self.mapWindowProperties,
Map = self.secondMap, frame = self)
self.MapWindow = self.firstMapWindow # current by default
self.firstMapWindow.zoomhistory = self.secondMapWindow.zoomhistory
@@ -162,7 +168,6 @@
self.statusbarManager.AddStatusbarItemsByClass(self.statusbarItems, mapframe = self, statusbar = statusbar)
self.statusbarManager.AddStatusbarItem(sb.SbMask(self, statusbar = statusbar, position = 2))
sbRender = sb.SbRender(self, statusbar = statusbar, position = 3)
- sbRender.autoRender.connect(self.OnAutoRenderChanged)
self.statusbarManager.AddStatusbarItem(sbRender)
self.statusbarManager.Update()
@@ -237,7 +242,7 @@
self.ResetSlider()
self.resize = False
- def OnAutoRenderChanged(self, state):
+ def OnAutoRenderChanged(self, value):
"""!Auto rendering state changed."""
style = self.splitter.GetWindowStyle()
style ^= wx.SP_LIVE_UPDATE
Modified: grass/trunk/gui/wxpython/mapswipe/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/mapwindow.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/mapswipe/mapwindow.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -36,9 +36,10 @@
Enables to draw the image translated.
Special mouse events with changed coordinates are used.
"""
- def __init__(self, parent, giface, Map, frame, **kwargs):
+ def __init__(self, parent, giface, Map, properties, frame, **kwargs):
BufferedWindow.__init__(self, parent = parent, giface = giface,
- Map=Map, frame=frame, **kwargs)
+ Map=Map, frame=frame,
+ properties=properties, **kwargs)
Debug.msg(2, "SwipeBufferedWindow.__init__()")
self.specialSize = super(SwipeBufferedWindow, self).GetClientSize()
Modified: grass/trunk/gui/wxpython/vdigit/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/mapwindow.py 2013-08-01 21:02:25 UTC (rev 57351)
+++ grass/trunk/gui/wxpython/vdigit/mapwindow.py 2013-08-01 21:30:50 UTC (rev 57352)
@@ -30,10 +30,11 @@
class VDigitWindow(BufferedWindow):
"""!A Buffered window extended for vector digitizer.
"""
- def __init__(self, parent, giface, Map, frame, tree=None,
+ def __init__(self, parent, giface, Map, frame, properties, tree=None,
id=wx.ID_ANY, lmgr=None,
style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
BufferedWindow.__init__(self, parent = parent, giface = giface, id = id, Map = Map,
+ properties=properties,
frame=frame, style=style, **kwargs)
self.lmgr = lmgr
self.tree = tree
More information about the grass-commit
mailing list