[GRASS-SVN] r50138 - in grass/trunk/gui/wxpython: core gui_core mapdisp nviz psmap

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 11 15:26:43 EST 2012


Author: annakrat
Date: 2012-01-11 12:26:43 -0800 (Wed, 11 Jan 2012)
New Revision: 50138

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/nviz/workspace.py
   grass/trunk/gui/wxpython/psmap/frame.py
Log:
wxGUI/preferences: added possibility to switch on/off zooming by mouse wheel (requested by Michael Barton)

Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py	2012-01-11 14:29:07 UTC (rev 50137)
+++ grass/trunk/gui/wxpython/core/settings.py	2012-01-11 20:26:43 UTC (rev 50138)
@@ -182,6 +182,10 @@
                 'bgcolor': {
                     'color' : (255, 255, 255, 255),
                     },
+                'mouseWheelZoom' : {
+                    'enabled' : True,
+                    'selection' : 0,
+                    },
                 },
             #
             # projection
@@ -775,6 +779,8 @@
         
         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'),
+                                                                         _('Scroll back to zoom in'))
 
         self.internalSettings['nviz']['view'] = {}
         self.internalSettings['nviz']['view']['twist'] = {}

Modified: grass/trunk/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/preferences.py	2012-01-11 14:29:07 UTC (rev 50137)
+++ grass/trunk/gui/wxpython/gui_core/preferences.py	2012-01-11 20:26:43 UTC (rev 50138)
@@ -706,7 +706,32 @@
 
         gridSizer.Add(item = autoZooming,
                       pos = (row, 0), span = (1, 2))
+        
+        #
+        # 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)
+                      
+        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,
+                      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)
         
@@ -714,7 +739,11 @@
                 
         # bindings
         fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
+        wheelZooming.Bind(wx.EVT_CHECKBOX, self.OnEnableWheelZoom)
         
+        # enable/disable controls according to settings
+        self.OnEnableWheelZoom(None)
+        
         return panel
 
     def _createCmdPage(self, notebook):
@@ -787,7 +816,7 @@
         self.winId['cmd:verbosity:selection'] = verbosity.GetId()
         
         gridSizer.Add(item = verbosity,
-                      pos = (row, 1))
+                      pos = (row, 1), flag = wx.ALIGN_RIGHT)
         
         sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
@@ -1259,6 +1288,13 @@
 
         event.Skip()
 
+    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)
+        
 class DefaultFontDialog(wx.Dialog):
     """
     Opens a file selection dialog to select default font

Modified: grass/trunk/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/mapwindow.py	2012-01-11 14:29:07 UTC (rev 50137)
+++ grass/trunk/gui/wxpython/mapdisp/mapwindow.py	2012-01-11 20:26:43 UTC (rev 50138)
@@ -912,6 +912,12 @@
     def OnMouseWheel(self, event):
         """!Mouse wheel moved
         """
+        if not UserSettings.Get(group = 'display',
+                                key = 'mouseWheelZoom',
+                                subkey = 'enabled'):
+            event.Skip()
+            return
+            
         self.processMouse = False
         current  = event.GetPositionTuple()[:]
         wheel = event.GetWheelRotation()
@@ -927,6 +933,11 @@
         else:
             zoomtype = -1
         
+        if UserSettings.Get(group = 'display',
+                            key = 'mouseWheelZoom',
+                            subkey = 'selection'):
+            zoomtype *= -1
+            
         # zoom
         self.Zoom(begin, end, zoomtype)
         

Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py	2012-01-11 14:29:07 UTC (rev 50137)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py	2012-01-11 20:26:43 UTC (rev 50138)
@@ -624,6 +624,12 @@
 
     def OnMouseWheel(self, event):
         """!Change perspective"""
+        if not UserSettings.Get(group = 'display',
+                                key = 'mouseWheelZoom',
+                                subkey = 'enabled'):
+            event.Skip()
+            return
+            
         wheel = event.GetWheelRotation()
         Debug.msg (5, "GLWindow.OnMouseMotion(): wheel = %d" % wheel)
         if self.timerFly.IsRunning() and self.fly['mouseControl']:
@@ -632,6 +638,10 @@
             else:
                 self.ChangeFlySpeed(increase = False)
         else:
+            if UserSettings.Get(group = 'display',
+                                key = 'mouseWheelZoom',
+                                subkey = 'selection'):
+                wheel *= -1
             self.DoZoom(zoomtype = wheel, pos = event.GetPositionTuple())
             
         # update statusbar

Modified: grass/trunk/gui/wxpython/nviz/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/workspace.py	2012-01-11 14:29:07 UTC (rev 50137)
+++ grass/trunk/gui/wxpython/nviz/workspace.py	2012-01-11 20:26:43 UTC (rev 50138)
@@ -25,9 +25,7 @@
 
 class NvizSettings(object):
     def __init__(self):
-        """Default 3D settings"""
-        UserSettings.Reset('nviz')
-        UserSettings.ReadSettingsFile()
+        pass
         
     def SetConstantDefaultProp(self):
         """Set default constant data properties"""

Modified: grass/trunk/gui/wxpython/psmap/frame.py
===================================================================
--- grass/trunk/gui/wxpython/psmap/frame.py	2012-01-11 14:29:07 UTC (rev 50137)
+++ grass/trunk/gui/wxpython/psmap/frame.py	2012-01-11 20:26:43 UTC (rev 50138)
@@ -42,6 +42,7 @@
 from gui_core.goutput import CmdThread, EVT_CMD_DONE
 from psmap.toolbars   import PsMapToolbar
 from core.gcmd        import RunCommand, GError, GMessage
+from core.settings    import UserSettings
 from gui_core.forms   import GUI
 from psmap.menudata   import PsMapData
 
@@ -1132,10 +1133,18 @@
         
     def OnMouse(self, event):
 
-        if event.GetWheelRotation():
+        if event.GetWheelRotation() and UserSettings.Get(group = 'display',
+                                                         key = 'mouseWheelZoom',
+                                                         subkey = 'enabled'):
             zoom = event.GetWheelRotation()
             use = self.mouse['use']
             self.mouse['begin'] = event.GetPosition()
+            
+            if UserSettings.Get(group = 'display',
+                                key = 'mouseWheelZoom',
+                                subkey = 'selection'):
+                zoom *= -1
+                
             if zoom > 0:
                 self.mouse['use'] = 'zoomin'
             else:



More information about the grass-commit mailing list