[GRASS-SVN] r52360 - in grass/trunk/gui/wxpython: core gui_core mapdisp nviz psmap
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 10 09:09:35 PDT 2012
Author: annakrat
Date: 2012-07-10 09:09:34 -0700 (Tue, 10 Jul 2012)
New Revision: 52360
Modified:
grass/trunk/gui/wxpython/core/settings.py
grass/trunk/gui/wxpython/gui_core/preferences.py
grass/trunk/gui/wxpython/mapdisp/mapwindow.py
grass/trunk/gui/wxpython/nviz/mapwindow.py
grass/trunk/gui/wxpython/psmap/frame.py
Log:
wxGUI: change default zoom behaviour - from zoom and recenter to zoom to mouse cursor - and added to settings
Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py 2012-07-10 11:15:59 UTC (rev 52359)
+++ grass/trunk/gui/wxpython/core/settings.py 2012-07-10 16:09:34 UTC (rev 52360)
@@ -190,7 +190,9 @@
'color' : (255, 255, 255, 255),
},
'mouseWheelZoom' : {
- 'enabled' : True,
+ 'selection' : 1,
+ },
+ 'scrollDirection' : {
'selection' : 0,
},
},
@@ -822,7 +824,10 @@
self.internalSettings['display']['driver']['choices'] = ['cairo', 'png']
self.internalSettings['display']['statusbarMode']['choices'] = None # set during MapFrame init
- self.internalSettings['display']['mouseWheelZoom']['choices'] = (_('Scroll forward to zoom in'),
+ self.internalSettings['display']['mouseWheelZoom']['choices'] = (_('Zoom and recenter'),
+ _('Zoom to mouse cursor'),
+ _('Nothing'))
+ self.internalSettings['display']['scrollDirection']['choices'] = (_('Scroll forward to zoom in'),
_('Scroll back to zoom in'))
self.internalSettings['nviz']['view'] = {}
Modified: grass/trunk/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/preferences.py 2012-07-10 11:15:59 UTC (rev 52359)
+++ grass/trunk/gui/wxpython/gui_core/preferences.py 2012-07-10 16:09:34 UTC (rev 52360)
@@ -39,6 +39,7 @@
import wx
import wx.lib.colourselect as csel
import wx.lib.mixins.listctrl as listmix
+import wx.lib.scrolledpanel as SP
from wx.lib.newevent import NewEvent
@@ -55,7 +56,7 @@
class PreferencesBaseDialog(wx.Dialog):
"""!Base preferences dialog"""
def __init__(self, parent, settings, title = _("User settings"),
- size = (500, 375),
+ size = (500, 425),
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
self.parent = parent # ModelerFrame
self.title = title
@@ -256,7 +257,8 @@
def _createGeneralPage(self, notebook):
"""!Create notebook page for general settings"""
- panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False, scroll_y = True)
notebook.AddPage(page = panel, text = _("General"))
border = wx.BoxSizer(wx.VERTICAL)
@@ -386,8 +388,8 @@
def _createAppearancePage(self, notebook):
"""!Create notebook page for display settings"""
-
- panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False, scroll_y = True)
notebook.AddPage(page = panel, text = _("Appearance"))
border = wx.BoxSizer(wx.VERTICAL)
@@ -560,7 +562,8 @@
def _createDisplayPage(self, notebook):
"""!Create notebook page for display settings"""
- panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False, scroll_y = True)
notebook.AddPage(page = panel, text = _("Map Display"))
border = wx.BoxSizer(wx.VERTICAL)
@@ -715,26 +718,35 @@
# mouse wheel zoom
#
row += 1
- wheelZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
- label = _("Enable zooming by mouse wheel"),
- name = "IsChecked")
- wheelZooming.SetValue(self.settings.Get(group = 'display', key = 'mouseWheelZoom',
- subkey = 'enabled'))
- self.winId['display:mouseWheelZoom:enabled'] = wheelZooming.GetId()
-
- gridSizer.Add(item = wheelZooming,
- pos = (row, 0), flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
-
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Mouse wheel action:")),
+ flag = wx.ALIGN_LEFT |
+ wx.ALIGN_CENTER_VERTICAL,
+ pos = (row, 0))
listOfModes = self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'choices', internal = True)
- zoomMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
- choices = listOfModes,
- name = "GetSelection")
- zoomMode.SetSelection(self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'selection'))
- self.winId['display:mouseWheelZoom:selection'] = zoomMode.GetId()
-
- gridSizer.Add(item = zoomMode,
+ zoomAction = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
+ choices = listOfModes,
+ name = "GetSelection")
+ zoomAction.SetSelection(self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'selection'))
+ self.winId['display:mouseWheelZoom:selection'] = zoomAction.GetId()
+ gridSizer.Add(item = zoomAction,
flag = wx.ALIGN_RIGHT,
pos = (row, 1))
+ row += 1
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Mouse scrolling direction:")),
+ flag = wx.ALIGN_LEFT |
+ wx.ALIGN_CENTER_VERTICAL,
+ pos = (row, 0))
+ listOfModes = self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'choices', internal = True)
+ scrollDir = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
+ choices = listOfModes,
+ name = "GetSelection")
+ scrollDir.SetSelection(self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'selection'))
+ self.winId['display:scrollDirection:selection'] = scrollDir.GetId()
+ gridSizer.Add(item = scrollDir,
+ flag = wx.ALIGN_RIGHT,
+ pos = (row, 1))
sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
@@ -743,7 +755,7 @@
# bindings
fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
- wheelZooming.Bind(wx.EVT_CHECKBOX, self.OnEnableWheelZoom)
+ zoomAction.Bind(wx.EVT_CHOICE, self.OnEnableWheelZoom)
# enable/disable controls according to settings
self.OnEnableWheelZoom(None)
@@ -752,7 +764,8 @@
def _createCmdPage(self, notebook):
"""!Create notebook page for commad dialog settings"""
- panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False, scroll_y = True)
notebook.AddPage(page = panel, text = _("Command"))
border = wx.BoxSizer(wx.VERTICAL)
@@ -831,7 +844,8 @@
def _createLayersPage(self, notebook):
"""!Create notebook page for layer settings"""
- panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False, scroll_y = True)
notebook.AddPage(page = panel, text = _("Layers"))
border = wx.BoxSizer(wx.VERTICAL)
@@ -1001,7 +1015,8 @@
def _createAttributeManagerPage(self, notebook):
"""!Create notebook page for 'Attribute Table Manager' settings"""
- panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False, scroll_y = True)
notebook.AddPage(page = panel, text = _("Attributes"))
pageSizer = wx.BoxSizer(wx.VERTICAL)
@@ -1130,7 +1145,8 @@
def _createProjectionPage(self, notebook):
"""!Create notebook page for workspace settings"""
- panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+ panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+ panel.SetupScrolling(scroll_x = False, scroll_y = True)
notebook.AddPage(page = panel, text = _("Projection"))
border = wx.BoxSizer(wx.VERTICAL)
@@ -1404,10 +1420,14 @@
def OnEnableWheelZoom(self, event):
"""!Enable/disable wheel zoom mode control"""
- checkId = self.winId['display:mouseWheelZoom:enabled']
choiceId = self.winId['display:mouseWheelZoom:selection']
- enable = self.FindWindowById(checkId).IsChecked()
- self.FindWindowById(choiceId).Enable(enable)
+ choice = self.FindWindowById(choiceId)
+ if choice.GetSelection() == 2:
+ enable = False
+ else:
+ enable = True
+ scrollId = self.winId['display:scrollDirection:selection']
+ self.FindWindowById(scrollId).Enable(enable)
class DefaultFontDialog(wx.Dialog):
"""
Modified: grass/trunk/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/mapwindow.py 2012-07-10 11:15:59 UTC (rev 52359)
+++ grass/trunk/gui/wxpython/mapdisp/mapwindow.py 2012-07-10 16:09:34 UTC (rev 52360)
@@ -970,9 +970,10 @@
def OnMouseWheel(self, event):
"""!Mouse wheel moved
"""
- if not UserSettings.Get(group = 'display',
- key = 'mouseWheelZoom',
- subkey = 'enabled'):
+ zoomBehaviour = UserSettings.Get(group = 'display',
+ key = 'mouseWheelZoom',
+ subkey = 'selection')
+ if zoomBehaviour == 2:
event.Skip()
return
@@ -980,19 +981,24 @@
current = event.GetPositionTuple()[:]
wheel = event.GetWheelRotation()
Debug.msg (5, "BufferedWindow.MouseAction(): wheel=%d" % wheel)
- # zoom 1/2 of the screen, centered to current mouse position (TODO: settings)
- begin = (current[0] - self.Map.width / 4,
- current[1] - self.Map.height / 4)
- end = (current[0] + self.Map.width / 4,
- current[1] + self.Map.height / 4)
-
+ # zoom 1/2 of the screen (TODO: settings)
+ if zoomBehaviour == 0: # zoom and recenter
+ # TODO: fix zooming out
+ begin = (current[0] - self.Map.width / 4,
+ current[1] - self.Map.height / 4)
+ end = (current[0] + self.Map.width / 4,
+ current[1] + self.Map.height / 4)
+ elif zoomBehaviour == 1: # zoom to current cursor position
+ begin = (current[0]/2, current[1]/2)
+ end = ((self.Map.width - current[0])/2 + current[0],
+ (self.Map.height - current[1])/2 + current[1])
if wheel > 0:
zoomtype = 1
else:
zoomtype = -1
if UserSettings.Get(group = 'display',
- key = 'mouseWheelZoom',
+ key = 'scrollDirection',
subkey = 'selection'):
zoomtype *= -1
Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py 2012-07-10 11:15:59 UTC (rev 52359)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py 2012-07-10 16:09:34 UTC (rev 52360)
@@ -624,9 +624,9 @@
def OnMouseWheel(self, event):
"""!Change perspective"""
- if not UserSettings.Get(group = 'display',
- key = 'mouseWheelZoom',
- subkey = 'enabled'):
+ if UserSettings.Get(group = 'display',
+ key = 'mouseWheelZoom',
+ subkey = 'selection') == 2:
event.Skip()
return
@@ -639,7 +639,7 @@
self.ChangeFlySpeed(increase = False)
else:
if UserSettings.Get(group = 'display',
- key = 'mouseWheelZoom',
+ key = 'scrollDirection',
subkey = 'selection'):
wheel *= -1
self.DoZoom(zoomtype = wheel, pos = event.GetPositionTuple())
Modified: grass/trunk/gui/wxpython/psmap/frame.py
===================================================================
--- grass/trunk/gui/wxpython/psmap/frame.py 2012-07-10 11:15:59 UTC (rev 52359)
+++ grass/trunk/gui/wxpython/psmap/frame.py 2012-07-10 16:09:34 UTC (rev 52360)
@@ -1287,9 +1287,9 @@
"""!Mouse wheel scrolled.
Changes zoom."""
- if not UserSettings.Get(group = 'display',
- key = 'mouseWheelZoom',
- subkey = 'enabled'):
+ if UserSettings.Get(group = 'display',
+ key = 'mouseWheelZoom',
+ subkey = 'selection') == 2:
event.Skip()
return
@@ -1298,7 +1298,7 @@
self.mouse['begin'] = event.GetPosition()
if UserSettings.Get(group = 'display',
- key = 'mouseWheelZoom',
+ key = 'scrollDirection',
subkey = 'selection'):
zoom *= -1
More information about the grass-commit
mailing list